Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to fetch dependency version in <profile> when the dependency is managed by <dependencyManagement> #145

Closed
stephaniewang526 opened this issue Apr 27, 2020 · 0 comments · Fixed by #155
Milestone

Comments

@stephaniewang526
Copy link
Contributor

stephaniewang526 commented Apr 27, 2020

We're trying to implement flatten plugin in GCP cloud clients and we ran into the following issue where the dependency version in <profile> is not correctly added when the dependency is managed by <dependencyManagement>. Here's a common scenario found in numerous GCP clients:

In the parent pom (below example taken from google-cloud-pubsub-parent):

 <properties>
   <javax.annotations.version>1.3.2</javax.annotations.version>
 </properties>
 
 <dependencyManagement>
   <dependencies>
     <dependency>
       <groupId>javax.annotation</groupId>
       <artifactId>javax.annotation-api</artifactId>
       <version>${javax.annotations.version}</version>
     </dependency>
   </dependencies>
 </dependencyManagement>

In the cloud client pom (below example taken from google-cloud-pubsub)

  <profiles>
    <profile>
      <id>java9</id>
      <activation>
        <jdk>[9,)</jdk>
      </activation>
      <dependencies>
        <dependency>
          <groupId>javax.annotation</groupId>
          <artifactId>javax.annotation-api</artifactId>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

Adding flatten plugin to the cloud client, in this instance, results in an invalid pom file since <version> for javax-annotaions-api will be missing.

Does anyone know if there's an existing configuration change that could resolve this issue? Or if this should be a new fix/feature?

We're currently addressing this issue by manually adding <version> in <profile> as such:

  <profiles>
    <profile>
      <id>java9</id>
      <activation>
        <jdk>[9,)</jdk>
      </activation>
      <dependencies>
        <dependency>
          <groupId>javax.annotation</groupId>
          <artifactId>javax.annotation-api</artifactId>
          **<version>${javax.annotations.version}</version>**
        </dependency>
      </dependencies>
    </profile>
  </profiles>

However, this is not ideal since it is manual there fore we cannot go GA with the current limitation -- please opine.

Thank you.
cc @saturnism

yangnuoyu pushed a commit to yangnuoyu/flatten-maven-plugin that referenced this issue May 27, 2020
… the dependency in profile which is managed by <dependencyManagement>
@olamy olamy closed this as completed in #155 Jun 5, 2020
olamy pushed a commit that referenced this issue Jun 5, 2020
…in profile which is managed by <dependencyManagement> (#155)

* Fixes #145, #148 add codes to parse the <version> for the dependency in profile which is managed by <dependencyManagement>

* remove redundant code

* add empty line at the end of files

* remove profile-with-deps-inherit-parent-depMgmt-ci test

* consolidate two blocks of code change into createCleanPom method

* restore import change

* restore import change

* add test profile-with-deps-inherit-parent-depMgmt-flatten-dep-all-oss

* change test profile-with-deps-inherit-parent-depMgmt-flatten-dep-all-oss to profile-with-deps-inherit-parent-depMgmt-flatten-dep-all-oss-bom

* code style fix

* fix indents and licenses declaration in verify.groovy

* set scope as compile and optional as false if not specified

* fix scope and optional - code style

Co-authored-by: yangnuoyu <yangnuoyu@penguin>
@olamy olamy modified the milestones: release:1.2.2, release:1.2.3 Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants