-
Notifications
You must be signed in to change notification settings - Fork 192
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
JENKINS-70032 : Make maven-plugin an optional dependency #244
Conversation
(Resolve SpotBugs warnings about NPE)
@alecharp - could you review this or point me to someone that could review this, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the test is valid.
If the maven-plugin
is not installed, the object cannot be an instance of MavenModuleSetBuild
. However, the class could not exists in that case.
How the plugin would behave it that case? The class couldn't be loaded and still the code would try to use it for the test.
Could you test that?
@@ -217,7 +222,7 @@ public void perform(@Nonnull Run<?, ?> dst, @Nonnull FilePath targetDir, @Nonnul | |||
|
|||
excludeFilter = env.expand(excludeFilter); | |||
|
|||
if (src instanceof MavenModuleSetBuild) { | |||
if (isMavenPluginInstalled() && src instanceof MavenModuleSetBuild) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the plugin is not installed, can the src
be an instance of MavenModelSetBuild
? This seems redundant, no?
: (item instanceof MatrixProject | ||
? FormValidation.warning(Messages.CopyArtifact_MatrixProject()) | ||
: FormValidation.ok()); | ||
if (isMavenPluginInstalled() && item instanceof MavenModuleSet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito.
Sure, I'll retest it and confirm that the s3CopyArtifact steps works without the maven plugin. My understanding of how this works is ... The plugin compiles without errors because maven-plugin is still listed as a dependency, just with an additional property, optional = true. At runtime, if the plugin is not installed, it'll exit the conditional statement before running src instanceof MavenModuleSetBuild, preventing a ClassNotFoundException. |
This article confirms the intent here. This class can execute properly without the I'd love this PR to be approved, as I don't want to bundle the maven-plugin anymore, but I'd like to continue to support the s3-plugin. |
Confirmed, the copy artifact from s3 step works:
|
Sorry, I was out. My question about the |
Correct, src cannot be of type |
This makes sense. Thank you for taking the time to point this and test it. |
@aah9 which JVM have you used to do your tests? |
@alecharp - My test jenkins instances were running jdk 11. |
This change makes maven-plugin an optional dependency, for the reasons explained in JENKINS-70032.
The copy artifact plugin already does this, so I just copied its plugin checks:
https://github.com/jenkinsci/copyartifact-plugin/blob/master/src/main/java/hudson/plugins/copyartifact/CopyArtifact.java#L525
https://github.com/jenkinsci/copyartifact-plugin/blob/master/src/main/java/hudson/plugins/copyartifact/CopyArtifact.java#L848
cc @alecharp since you last committed to the repo.