diff --git a/src/it/MNG-8137/invoker.properties b/src/it/MNG-8137/invoker.properties new file mode 100644 index 00000000..b0222bb1 --- /dev/null +++ b/src/it/MNG-8137/invoker.properties @@ -0,0 +1,18 @@ +# 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 = jar:jar diff --git a/src/it/MNG-8137/pom.xml b/src/it/MNG-8137/pom.xml new file mode 100644 index 00000000..4663411a --- /dev/null +++ b/src/it/MNG-8137/pom.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + + org.apache.maven.plugins.jar.it + mng-8137 + pom + 1.0 + it-mng-8137 + + Project w/ pom packaging and jar:jar invoked + + + + + org.apache.maven.plugins + maven-jar-plugin + @project.version@ + + + + + diff --git a/src/it/MNG-8137/verify.groovy b/src/it/MNG-8137/verify.groovy new file mode 100644 index 00000000..89fa8fcc --- /dev/null +++ b/src/it/MNG-8137/verify.groovy @@ -0,0 +1,21 @@ +/* + * 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. + */ + +String log = new File(basedir, 'build.log').text +assert log.contains('[WARNING] The project packaging language is NOT \'java\'; this is most probably not what you want') diff --git a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java index 9a2bc229..b8b6f7d6 100644 --- a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java @@ -26,6 +26,7 @@ import org.apache.maven.archiver.MavenArchiveConfiguration; import org.apache.maven.archiver.MavenArchiver; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -130,6 +131,9 @@ public abstract class AbstractJarMojo extends AbstractMojo { @Component private MavenProjectHelper projectHelper; + @Component + private ArtifactHandlerManager artifactHandlerManager; + /** * Require the jar plugin to build a new JAR even if none of the contents appear to have changed. By default, this * plugin looks to see if the output jar exists and inputs have not changed. If these conditions are true, the @@ -351,6 +355,14 @@ public void execute() throws MojoExecutionException { throw new MojoExecutionException("You have to use a classifier " + "to attach supplemental artifacts to the project instead of replacing them."); } + + if (!"java" + .equals(artifactHandlerManager + .getArtifactHandler(getProject().getPackaging()) + .getLanguage())) { + getLog().warn( + "The project packaging language is NOT 'java'; this is most probably not what you want"); + } getProject().getArtifact().setFile(jarFile); } }