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

JENKINS-70032 : Make maven-plugin an optional dependency #244

Merged
merged 2 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>3.16</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-io</groupId>
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/hudson/plugins/s3/S3CopyArtifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ private void setResult(@Nonnull Run<?, ?> run, boolean isOk) {
else
run.setResult(Result.FAILURE);
}

private static boolean isMavenPluginInstalled() {
Jenkins instance = Jenkins.getInstanceOrNull();
return instance != null && instance.getPlugin("maven-plugin") != null;
}

@Override
public void perform(@Nonnull Run<?, ?> dst, @Nonnull FilePath targetDir, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException {
Expand Down Expand Up @@ -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) {
Copy link
Member

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?

// Copy artifacts from the build (ArchiveArtifacts build step)
boolean ok = perform(src, dst, includeFilter, excludeFilter, targetDir, console);

Expand Down Expand Up @@ -335,12 +340,13 @@ public FormValidation doCheckProjectName(
final FormValidation result;
final Item item = new JobResolver(value).job;
if (item != null) {

result = item instanceof MavenModuleSet
? FormValidation.warning(Messages.CopyArtifact_MavenProject())
: (item instanceof MatrixProject
? FormValidation.warning(Messages.CopyArtifact_MatrixProject())
: FormValidation.ok());
if (isMavenPluginInstalled() && item instanceof MavenModuleSet) {
Copy link
Member

Choose a reason for hiding this comment

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

dito.

result = FormValidation.warning(Messages.CopyArtifact_MavenProject());
} else {
result = (item instanceof MatrixProject)
? FormValidation.warning(Messages.CopyArtifact_MatrixProject())
: FormValidation.ok();
}
}
else if (value.indexOf('$') >= 0) {
result = FormValidation.warning(Messages.CopyArtifact_ParameterizedName());
Expand Down