diff --git a/src/it/compile-multimodule-it/invoker.properties b/src/it/compile-multimodule-it/invoker.properties new file mode 100644 index 0000000000..1f11d01bf9 --- /dev/null +++ b/src/it/compile-multimodule-it/invoker.properties @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +invoker.goals=-Dstyle.color=always -ntp clean compile diff --git a/src/it/compile-multimodule-it/plugin1/pom.xml b/src/it/compile-multimodule-it/plugin1/pom.xml new file mode 100644 index 0000000000..469f7719e6 --- /dev/null +++ b/src/it/compile-multimodule-it/plugin1/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + + org.jenkins-ci.tools.hpi.its + compile-multimodule-it-parent + 1.0-SNAPSHOT + + + compile-multimodule-it-plugin1 + 1.0-SNAPSHOT + hpi + diff --git a/src/it/compile-multimodule-it/plugin2/pom.xml b/src/it/compile-multimodule-it/plugin2/pom.xml new file mode 100644 index 0000000000..e895d41b26 --- /dev/null +++ b/src/it/compile-multimodule-it/plugin2/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + org.jenkins-ci.tools.hpi.its + compile-multimodule-it-parent + 1.0-SNAPSHOT + + + compile-multimodule-it-plugin2 + hpi + + + + ${project.groupId} + compile-multimodule-it-plugin1 + ${project.version} + + + diff --git a/src/it/compile-multimodule-it/pom.xml b/src/it/compile-multimodule-it/pom.xml new file mode 100644 index 0000000000..8787abac84 --- /dev/null +++ b/src/it/compile-multimodule-it/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + + org.jenkins-ci.plugins + plugin + 4.25 + + + org.jenkins-ci.tools.hpi.its + compile-multimodule-it-parent + 1.0-SNAPSHOT + + pom + + 8 + + + + plugin1 + plugin2 + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + + + diff --git a/src/main/java/org/jenkinsci/maven/plugins/hpi/ValidateHpiMojo.java b/src/main/java/org/jenkinsci/maven/plugins/hpi/ValidateHpiMojo.java index 2eb5ebb9a1..d7359e488e 100644 --- a/src/main/java/org/jenkinsci/maven/plugins/hpi/ValidateHpiMojo.java +++ b/src/main/java/org/jenkinsci/maven/plugins/hpi/ValidateHpiMojo.java @@ -2,6 +2,7 @@ import com.google.common.collect.Sets; import hudson.util.VersionNumber; +import java.io.File; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -41,17 +42,24 @@ public void execute() throws MojoExecutionException, MojoFailureException { } private VersionNumber getDependencyCoreVersion(MavenArtifact artifact) throws IOException, MojoExecutionException { - Attributes mainAttributes = new JarFile(artifact.getFile()).getManifest().getMainAttributes(); - Attributes.Name jName = new Attributes.Name("Jenkins-Version"); - if (mainAttributes.containsKey(jName)) { - return new VersionNumber(mainAttributes.getValue(jName)); - } else { - Attributes.Name hName = new Attributes.Name("Hudson-Version"); - if (mainAttributes.containsKey(hName)) { - return new VersionNumber(mainAttributes.getValue(hName)); + File file = artifact.getFile(); + if (file.isFile()) { + Attributes mainAttributes = new JarFile(file).getManifest().getMainAttributes(); + Attributes.Name jName = new Attributes.Name("Jenkins-Version"); + if (mainAttributes.containsKey(jName)) { + return new VersionNumber(mainAttributes.getValue(jName)); } else { - throw new MojoExecutionException("Could not find Jenkins Version in manifest for " + artifact); + Attributes.Name hName = new Attributes.Name("Hudson-Version"); + if (mainAttributes.containsKey(hName)) { + return new VersionNumber(mainAttributes.getValue(hName)); + } else { + throw new MojoExecutionException("Could not find Jenkins Version in manifest for " + artifact); + } } + } else { + getLog().warn("Skipping jenkins-core validation for " + artifact + " since we rely on sources and don't have a manifest. Use 'package' goal to get validation"); + // Assume the version is the same + return new VersionNumber(findJenkinsVersion()); } } }