Grant Henke created YETUS-524:
---------------------------------

             Summary: audience-annotations can not be used as a dependency in a 
gradle build
                 Key: YETUS-524
                 URL: https://issues.apache.org/jira/browse/YETUS-524
             Project: Yetus
          Issue Type: Bug
          Components: Audience Annotations
    Affects Versions: 0.4.0
            Reporter: Grant Henke
             Fix For: 0.5.0


The Yetus audience-annotations module uses a jdk profile in the parent 
yetus-project pom to define the tool.jar to use in the dependency management 
section:

{code:title=audience-annotations/pom.xml}
...
<dependencies>
    <dependency>
      <!-- Version and location set in project pom -->
      <groupId>jdk.tools</groupId>
      <artifactId>jdk.tools</artifactId>
      <scope>system</scope>
      <!-- Mark as optional so that it isn't taken transitively -->
      <optional>true</optional>
    </dependency>
  </dependencies>
...
{code}

{code:title=yetus-project/pom.xml}
...
<profiles>
    <profile>
      <id>jdk1.7</id>
      <activation>
        <jdk>1.7</jdk>
      </activation>
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>jdk.tools</groupId>
            <artifactId>jdk.tools</artifactId>
            <version>1.7</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
          </dependency>
        </dependencies>
      </dependencyManagement>
    </profile>
...
{code}

This causes issues when trying to download the maven dependency via a gradle 
project because gradle does not support jdk profile activation and views 
profile activation requirements as a reproducibility anti-pattern to be 
avoided. ([source|https://blog.gradle.org/maven-pom-profiles]).

The issue seen in a gradle build is below:
{noformat}
> Could not resolve org.apache.yetus:audience-annotations:0.4.0.
     Required by: ...
      > Could not resolve org.apache.yetus:audience-annotations:0.4.0.
         > Could not parse POM 
https://repo1.maven.org/maven2/org/apache/yetus/audience-annotations/0.4.0/audience-annotations-0.4.0.pom
            > Unable to resolve version for dependency 'jdk.tools:jdk.tools:jar'
{noformat}

This occurs because without any default version and no jdk profile activated 
jdk.tools is an invalid dependency. Given that its optional, it could simply be 
ignored. However, gradle has no way to force this even if setting the 
transitive = false property.

This is easily fixed by adding a default dependency when no jdk profile is 
activated. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to