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

Fix scope for some git plugin transitive dependencies getting pulled as 'compile' instead of 'test' #592

Merged
merged 3 commits into from
Sep 10, 2019

Conversation

Vlatombe
Copy link
Member

@Vlatombe Vlatombe commented Sep 9, 2019

hpi plugin bug?

@Vlatombe Vlatombe requested a review from jglick September 9, 2019 12:29
@jglick
Copy link
Member

jglick commented Sep 9, 2019

Typically this is not a mojo bug but a POM mistake; it means that the dependency would also have been pulled in from some other source, and the currently visible test-scoped dependency trail is merely the closest to root. For example, mvn dependency:tree after

diff --git a/pom.xml b/pom.xml
index f7099517..65c1e9c6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -154,12 +154,24 @@
       <groupId>org.jenkins-ci.plugins</groupId>
       <artifactId>git</artifactId>
       <scope>test</scope>
+      <exclusions>
+          <exclusion>
+              <groupId>joda-time</groupId>
+              <artifactId>joda-time</artifactId>
+          </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.jenkins-ci.plugins</groupId>
       <artifactId>git</artifactId>
       <classifier>tests</classifier>
       <scope>test</scope>
+      <exclusions>
+          <exclusion>
+              <groupId>joda-time</groupId>
+              <artifactId>joda-time</artifactId>
+          </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.jenkins-ci.plugins</groupId>

gives

[INFO] +- org.jenkinsci.plugins:pipeline-model-extensions:jar:1.3.7:compile (optional) 
[INFO] |  +- org.jenkinsci.plugins:pipeline-model-api:jar:1.3.7:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-json-org:jar:2.9.8:compile
[INFO] |  |  |  \- org.json:json:jar:20171018:compile
[INFO] |  |  \- com.github.fge:json-schema-validator:jar:2.0.4:compile
[INFO] |  |     +- com.github.fge:json-schema-core:jar:1.0.4:compile
[INFO] |  |     |  \- org.mozilla:rhino:jar:1.7R4:compile
[INFO] |  |     +- javax.mail:mailapi:jar:1.4.3:compile
[INFO] |  |     +- joda-time:joda-time:jar:2.1:compile

@jglick
Copy link
Member

jglick commented Sep 9, 2019

Therefore the better fix is to decide which trail you want to use, and add <exclusions> for the other(s). There is also a mojo bug contributing to this: JENKINS-58771

…roblem

Also get rid of pluginFirstClassLoader=true, which predated jackson2-api (I guess)
@Vlatombe Vlatombe merged commit 2fd9ae0 into jenkinsci:master Sep 10, 2019
@Vlatombe Vlatombe deleted the fix-packaging-test-dependencies branch September 10, 2019 07:50
@Vlatombe Vlatombe added the chore Maintenance label Sep 10, 2019
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:460)
at io.fabric8.kubernetes.client.utils.Serialization.<clinit>(Serialization.java:37)
-->
<pluginFirstClassLoader>true</pluginFirstClassLoader>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be sure to test this live, not just mvn hpi:run.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't see any problem. Looking at the git blame for this, I see this was added back in the day where jackson was packaged directly in the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants