This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 4b888dd [MJAR-293] Update Parent to 39
4b888dd is described below
commit 4b888dd8b2642f33404bcea96f203b33c7929c9c
Author: Jorge Solórzano <[email protected]>
AuthorDate: Sat Jan 28 19:56:05 2023 +0100
[MJAR-293] Update Parent to 39
Signed-off-by: Jorge Solórzano <[email protected]>
---
pom.xml | 16 +-
src/it/MJAR-70-no-recreation/pom.xml | 7 +
.../apache/maven/plugins/jar/AbstractJarMojo.java | 210 +++++++++------------
.../java/org/apache/maven/plugins/jar/JarMojo.java | 37 ++--
.../org/apache/maven/plugins/jar/TestJarMojo.java | 49 +++--
.../org/apache/maven/plugins/jar/JarMojoTest.java | 23 +--
6 files changed, 153 insertions(+), 189 deletions(-)
diff --git a/pom.xml b/pom.xml
index 73cb886..6ae8756 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -18,19 +17,18 @@
specific language governing permissions and limitations
under the License.
-->
-
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>maven-plugins</artifactId>
<groupId>org.apache.maven.plugins</groupId>
- <version>37</version>
+ <artifactId>maven-plugins</artifactId>
+ <version>39</version>
<relativePath />
</parent>
<artifactId>maven-jar-plugin</artifactId>
- <version>3.3.1-SNAPSHOT</version>
+ <version>3.4.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Apache Maven JAR Plugin</name>
@@ -42,10 +40,10 @@
<email>[email protected]</email>
<organization>CoffeeBreaks</organization>
<organizationUrl>http://www.coffeebreaks.org</organizationUrl>
- <timezone>+1</timezone>
<roles>
<role>Java Developer</role>
</roles>
+ <timezone>+1</timezone>
</contributor>
</contributors>
@@ -56,8 +54,8 @@
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-jar-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-jar-plugin.git</developerConnection>
-
<url>https://github.com/apache/maven-jar-plugin/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
+
<url>https://github.com/apache/maven-jar-plugin/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>JIRA</system>
@@ -152,8 +150,8 @@
<build>
<resources>
<resource>
- <directory>src/main/filtered-resources</directory>
<filtering>true</filtering>
+ <directory>src/main/filtered-resources</directory>
</resource>
</resources>
<pluginManagement>
diff --git a/src/it/MJAR-70-no-recreation/pom.xml
b/src/it/MJAR-70-no-recreation/pom.xml
index 24a7c66..95e29ca 100644
--- a/src/it/MJAR-70-no-recreation/pom.xml
+++ b/src/it/MJAR-70-no-recreation/pom.xml
@@ -34,6 +34,13 @@
<configuration>
</configuration>
</plugin>
+ <!-- Use a fixed version of maven-compiler-plugin, this fails with
versions [3.8.1, 3.10.1] -->
+ <!-- Fixed in https://issues.apache.org/jira/browse/MCOMPILER-525
(3.11.0) -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.11.0</version>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
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 a1483ac..ab2a50f 100644
--- a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jar;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.plugins.jar;
* "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
+ * 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
@@ -18,6 +16,12 @@ package org.apache.maven.plugins.jar;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jar;
+
+import java.io.File;
+import java.nio.file.FileSystems;
+import java.util.Arrays;
+import java.util.Map;
import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.archiver.MavenArchiver;
@@ -33,24 +37,17 @@ import
org.apache.maven.shared.model.fileset.util.FileSetManager;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.jar.JarArchiver;
-import java.io.File;
-import java.nio.file.FileSystems;
-import java.util.Arrays;
-import java.util.Map;
-
/**
* Base class for creating a jar from project classes.
*
* @author <a href="[email protected]">Emmanuel Venisse</a>
* @version $Id$
*/
-public abstract class AbstractJarMojo
- extends AbstractMojo
-{
+public abstract class AbstractJarMojo extends AbstractMojo {
- private static final String[] DEFAULT_EXCLUDES = new String[] {
"**/package.html" };
+ private static final String[] DEFAULT_EXCLUDES = new String[]
{"**/package.html"};
- private static final String[] DEFAULT_INCLUDES = new String[] { "**/**" };
+ private static final String[] DEFAULT_INCLUDES = new String[] {"**/**"};
private static final String MODULE_DESCRIPTOR_FILE_NAME =
"module-info.class";
@@ -73,13 +70,13 @@ public abstract class AbstractJarMojo
/**
* Directory containing the generated JAR.
*/
- @Parameter( defaultValue = "${project.build.directory}", required = true )
+ @Parameter(defaultValue = "${project.build.directory}", required = true)
private File outputDirectory;
/**
* Name of the generated JAR.
*/
- @Parameter( defaultValue = "${project.build.finalName}", readonly = true )
+ @Parameter(defaultValue = "${project.build.finalName}", readonly = true)
private String finalName;
/**
@@ -89,15 +86,15 @@ public abstract class AbstractJarMojo
private Map<String, Archiver> archivers;
/**
- * The {@link {MavenProject}.
+ * The {@link MavenProject}.
*/
- @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
/**
* The {@link MavenSession}.
*/
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ @Parameter(defaultValue = "${session}", readonly = true, required = true)
private MavenSession session;
/**
@@ -111,10 +108,11 @@ public abstract class AbstractJarMojo
* Using this property will fail your build cause it has been removed from
the plugin configuration. See the
* <a href="https://maven.apache.org/plugins/maven-jar-plugin/">Major
Version Upgrade to version 3.0.0</a> for the
* plugin.
- *
+ *
* @deprecated For version 3.0.0 this parameter is only defined here to
break the build if you use it!
*/
- @Parameter( property = "jar.useDefaultManifestFile", defaultValue =
"false" )
+ @Parameter(property = "jar.useDefaultManifestFile", defaultValue = "false")
+ @Deprecated
private boolean useDefaultManifestFile;
/**
@@ -134,13 +132,13 @@ public abstract class AbstractJarMojo
* Starting with <b>3.0.0</b> the property has been renamed from
<code>jar.forceCreation</code> to
* <code>maven.jar.forceCreation</code>.
*/
- @Parameter( property = "maven.jar.forceCreation", defaultValue = "false" )
+ @Parameter(property = "maven.jar.forceCreation", defaultValue = "false")
private boolean forceCreation;
/**
* Skip creating empty archives.
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean skipIfEmpty;
/**
@@ -151,16 +149,16 @@ public abstract class AbstractJarMojo
*
* @since 3.2.0
*/
- @Parameter( defaultValue = "${project.build.outputTimestamp}" )
+ @Parameter(defaultValue = "${project.build.outputTimestamp}")
private String outputTimestamp;
/**
* If the JAR contains the {@code META-INF/versions} directory it will be
detected as a multi-release JAR file
* ("MRJAR"), adding the {@code Multi-Release: true} attribute to the main
section of the JAR MANIFEST.MF.
*
- * @since 3.3.1
+ * @since 3.4.0
*/
- @Parameter( property = "maven.jar.detectMultiReleaseJar", defaultValue =
"true" )
+ @Parameter(property = "maven.jar.detectMultiReleaseJar", defaultValue =
"true")
private boolean detectMultiReleaseJar;
/**
@@ -170,10 +168,11 @@ public abstract class AbstractJarMojo
protected abstract File getClassesDirectory();
/**
- * @return the {@link #project}
+ * Return the {@link #project MavenProject}
+ *
+ * @return the MavenProject.
*/
- protected final MavenProject getProject()
- {
+ protected final MavenProject getProject() {
return project;
}
@@ -197,28 +196,17 @@ public abstract class AbstractJarMojo
* @param classifier an optional classifier
* @return the file to generate
*/
- protected File getJarFile( File basedir, String resultFinalName, String
classifier )
- {
- if ( basedir == null )
- {
- throw new IllegalArgumentException( "basedir is not allowed to be
null" );
+ protected File getJarFile(File basedir, String resultFinalName, String
classifier) {
+ if (basedir == null) {
+ throw new IllegalArgumentException("basedir is not allowed to be
null");
}
- if ( resultFinalName == null )
- {
- throw new IllegalArgumentException( "finalName is not allowed to
be null" );
+ if (resultFinalName == null) {
+ throw new IllegalArgumentException("finalName is not allowed to be
null");
}
- String fileName;
- if ( hasClassifier() )
- {
- fileName = resultFinalName + "-" + classifier + ".jar";
- }
- else
- {
- fileName = resultFinalName + ".jar";
- }
+ String fileName = resultFinalName + (hasClassifier() ? "-" +
classifier : "") + ".jar";
- return new File( basedir, fileName );
+ return new File(basedir, fileName);
}
/**
@@ -226,24 +214,22 @@ public abstract class AbstractJarMojo
* @return The instance of File for the created archive file.
* @throws MojoExecutionException in case of an error.
*/
- public File createArchive()
- throws MojoExecutionException
- {
- File jarFile = getJarFile( outputDirectory, finalName, getClassifier()
);
+ public File createArchive() throws MojoExecutionException {
+ File jarFile = getJarFile(outputDirectory, finalName, getClassifier());
FileSetManager fileSetManager = new FileSetManager();
FileSet jarContentFileSet = new FileSet();
- jarContentFileSet.setDirectory(
getClassesDirectory().getAbsolutePath() );
- jarContentFileSet.setIncludes( Arrays.asList( getIncludes() ) );
- jarContentFileSet.setExcludes( Arrays.asList( getExcludes() ) );
+
jarContentFileSet.setDirectory(getClassesDirectory().getAbsolutePath());
+ jarContentFileSet.setIncludes(Arrays.asList(getIncludes()));
+ jarContentFileSet.setExcludes(Arrays.asList(getExcludes()));
- String[] includedFiles = fileSetManager.getIncludedFiles(
jarContentFileSet );
+ String[] includedFiles =
fileSetManager.getIncludedFiles(jarContentFileSet);
- if ( detectMultiReleaseJar && Arrays.stream( includedFiles ).anyMatch(
p -> p.startsWith( "META-INF" + SEPARATOR
- + "versions" + SEPARATOR ) ) )
- {
- getLog().debug( "Adding 'Multi-Release: true' manifest entry." );
- archive.addManifestEntry( "Multi-Release", "true" );
+ if (detectMultiReleaseJar
+ && Arrays.stream(includedFiles)
+ .anyMatch(p -> p.startsWith("META-INF" + SEPARATOR +
"versions" + SEPARATOR))) {
+ getLog().debug("Adding 'Multi-Release: true' manifest entry.");
+ archive.addManifestEntry("Multi-Release", "true");
}
// May give false positives if the files is named as module descriptor
@@ -255,43 +241,36 @@ public abstract class AbstractJarMojo
// with "module-info.class" is unlikely to be included in Jar file
// unless it is a module descriptor.
boolean containsModuleDescriptor =
- Arrays.stream( includedFiles ).anyMatch( p -> p.endsWith(
MODULE_DESCRIPTOR_FILE_NAME ) );
+ Arrays.stream(includedFiles).anyMatch(p ->
p.endsWith(MODULE_DESCRIPTOR_FILE_NAME));
String archiverName = containsModuleDescriptor ? "mjar" : "jar";
MavenArchiver archiver = new MavenArchiver();
- archiver.setCreatedBy( "Maven JAR Plugin", "org.apache.maven.plugins",
"maven-jar-plugin" );
- archiver.setArchiver( (JarArchiver) archivers.get( archiverName ) );
- archiver.setOutputFile( jarFile );
+ archiver.setCreatedBy("Maven JAR Plugin", "org.apache.maven.plugins",
"maven-jar-plugin");
+ archiver.setArchiver((JarArchiver) archivers.get(archiverName));
+ archiver.setOutputFile(jarFile);
// configure for Reproducible Builds based on outputTimestamp value
- archiver.configureReproducibleBuild( outputTimestamp );
+ archiver.configureReproducibleBuild(outputTimestamp);
- archive.setForced( forceCreation );
+ archive.setForced(forceCreation);
- try
- {
+ try {
File contentDirectory = getClassesDirectory();
- if ( !contentDirectory.exists() )
- {
- if ( !forceCreation )
- {
- getLog().warn( "JAR will be empty - no content was marked
for inclusion!" );
+ if (!contentDirectory.exists()) {
+ if (!forceCreation) {
+ getLog().warn("JAR will be empty - no content was marked
for inclusion!");
}
- }
- else
- {
- archiver.getArchiver().addDirectory( contentDirectory,
getIncludes(), getExcludes() );
+ } else {
+ archiver.getArchiver().addDirectory(contentDirectory,
getIncludes(), getExcludes());
}
- archiver.createArchive( session, project, archive );
+ archiver.createArchive(session, project, archive);
return jarFile;
- }
- catch ( Exception e )
- {
+ } catch (Exception e) {
// TODO: improve error handling
- throw new MojoExecutionException( "Error assembling JAR", e );
+ throw new MojoExecutionException("Error assembling JAR", e);
}
}
@@ -299,44 +278,34 @@ public abstract class AbstractJarMojo
* Generates the JAR.
* @throws MojoExecutionException in case of an error.
*/
- public void execute()
- throws MojoExecutionException
- {
- if ( useDefaultManifestFile )
- {
- throw new MojoExecutionException( "You are using
'useDefaultManifestFile' which has been removed"
- + " from the maven-jar-plugin. "
- + "Please see the >>Major Version Upgrade to version 3.0.0<<
on the plugin site." );
+ @Override
+ public void execute() throws MojoExecutionException {
+ if (useDefaultManifestFile) {
+ throw new MojoExecutionException("You are using
'useDefaultManifestFile' which has been removed"
+ + " from the maven-jar-plugin. "
+ + "Please see the >>Major Version Upgrade to version
3.0.0<< on the plugin site.");
}
- if ( skipIfEmpty && ( !getClassesDirectory().exists() ||
getClassesDirectory().list().length < 1 ) )
- {
- getLog().info( "Skipping packaging of the " + getType() );
- }
- else
- {
+ if (skipIfEmpty
+ && (!getClassesDirectory().exists() ||
getClassesDirectory().list().length < 1)) {
+ getLog().info("Skipping packaging of the " + getType());
+ } else {
File jarFile = createArchive();
- if ( hasClassifier() )
- {
- projectHelper.attachArtifact( getProject(), getType(),
getClassifier(), jarFile );
- }
- else
- {
- if ( projectHasAlreadySetAnArtifact() )
- {
- throw new MojoExecutionException( "You have to use a
classifier "
- + "to attach supplemental artifacts to the project
instead of replacing them." );
+ if (hasClassifier()) {
+ projectHelper.attachArtifact(getProject(), getType(),
getClassifier(), jarFile);
+ } else {
+ if (projectHasAlreadySetAnArtifact()) {
+ throw new MojoExecutionException("You have to use a
classifier "
+ + "to attach supplemental artifacts to the project
instead of replacing them.");
}
- getProject().getArtifact().setFile( jarFile );
+ getProject().getArtifact().setFile(jarFile);
}
}
}
- private boolean projectHasAlreadySetAnArtifact()
- {
- if ( getProject().getArtifact().getFile() == null )
- {
+ private boolean projectHasAlreadySetAnArtifact() {
+ if (getProject().getArtifact().getFile() == null) {
return false;
}
@@ -344,26 +313,23 @@ public abstract class AbstractJarMojo
}
/**
- * @return true in case where the classifier is not {@code null} and
contains something else than white spaces.
+ * Return {@code true} in case where the classifier is not {@code null}
and contains something else than white spaces.
+ *
+ * @return {@code true} if the classifier is set.
*/
- protected boolean hasClassifier()
- {
- return getClassifier() != null && getClassifier().trim().length() > 0;
+ protected boolean hasClassifier() {
+ return getClassifier() != null && !getClassifier().trim().isEmpty();
}
- private String[] getIncludes()
- {
- if ( includes != null && includes.length > 0 )
- {
+ private String[] getIncludes() {
+ if (includes != null && includes.length > 0) {
return includes;
}
return DEFAULT_INCLUDES;
}
- private String[] getExcludes()
- {
- if ( excludes != null && excludes.length > 0 )
- {
+ private String[] getExcludes() {
+ if (excludes != null && excludes.length > 0) {
return excludes;
}
return DEFAULT_EXCLUDES;
diff --git a/src/main/java/org/apache/maven/plugins/jar/JarMojo.java
b/src/main/java/org/apache/maven/plugins/jar/JarMojo.java
index 4172028..7ce06d4 100644
--- a/src/main/java/org/apache/maven/plugins/jar/JarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jar/JarMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jar;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.plugins.jar;
* "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
+ * 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
@@ -18,35 +16,38 @@ package org.apache.maven.plugins.jar;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jar;
+
+import java.io.File;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
-import java.io.File;
-
/**
* Build a JAR from the current project.
*
* @author <a href="[email protected]">Emmanuel Venisse</a>
* @version $Id$
*/
-@Mojo( name = "jar", defaultPhase = LifecyclePhase.PACKAGE, requiresProject =
true, threadSafe = true,
- requiresDependencyResolution = ResolutionScope.RUNTIME )
-public class JarMojo
- extends AbstractJarMojo
-{
+@Mojo(
+ name = "jar",
+ defaultPhase = LifecyclePhase.PACKAGE,
+ requiresProject = true,
+ threadSafe = true,
+ requiresDependencyResolution = ResolutionScope.RUNTIME)
+public class JarMojo extends AbstractJarMojo {
/**
* Directory containing the classes and resource files that should be
packaged into the JAR.
*/
- @Parameter( defaultValue = "${project.build.outputDirectory}", required =
true )
+ @Parameter(defaultValue = "${project.build.outputDirectory}", required =
true)
private File classesDirectory;
/**
* Classifier to add to the artifact generated. If given, the artifact
will be attached
* as a supplemental artifact.
- * If not given this will create the main artifact which is the default
behavior.
+ * If not given this will create the main artifact which is the default
behavior.
* If you try to do that a second time without using a classifier the
build will fail.
*/
@Parameter
@@ -55,24 +56,24 @@ public class JarMojo
/**
* {@inheritDoc}
*/
- protected String getClassifier()
- {
+ @Override
+ protected String getClassifier() {
return classifier;
}
/**
* {@inheritDoc}
*/
- protected String getType()
- {
+ @Override
+ protected String getType() {
return "jar";
}
/**
* {@inheritDoc}
*/
- protected File getClassesDirectory()
- {
+ @Override
+ protected File getClassesDirectory() {
return classesDirectory;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/jar/TestJarMojo.java
b/src/main/java/org/apache/maven/plugins/jar/TestJarMojo.java
index 10a7c38..96b5ac3 100644
--- a/src/main/java/org/apache/maven/plugins/jar/TestJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jar/TestJarMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jar;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.plugins.jar;
* "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
+ * 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
@@ -18,8 +16,10 @@ package org.apache.maven.plugins.jar;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jar;
import java.io.File;
+
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
@@ -33,67 +33,66 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
* @version $Id$
*/
// CHECKSTYLE_OFF: LineLength
-@Mojo( name = "test-jar", defaultPhase = LifecyclePhase.PACKAGE,
requiresProject = true, threadSafe = true, requiresDependencyResolution =
ResolutionScope.TEST )
+@Mojo(
+ name = "test-jar",
+ defaultPhase = LifecyclePhase.PACKAGE,
+ requiresProject = true,
+ threadSafe = true,
+ requiresDependencyResolution = ResolutionScope.TEST)
// CHECKSTYLE_ON: LineLength
-public class TestJarMojo
- extends AbstractJarMojo
-{
+public class TestJarMojo extends AbstractJarMojo {
/**
* Set this to <code>true</code> to bypass test-jar generation. Its use is
<b>NOT RECOMMENDED</b>, but quite
* convenient on occasion.
*/
- @Parameter( property = "maven.test.skip" )
+ @Parameter(property = "maven.test.skip")
private boolean skip;
/**
* Directory containing the test classes and resource files that should be
packaged into the JAR.
*/
- @Parameter( defaultValue = "${project.build.testOutputDirectory}",
required = true )
+ @Parameter(defaultValue = "${project.build.testOutputDirectory}", required
= true)
private File testClassesDirectory;
/**
* Classifier to use for {@code test-jar}.
*/
- @Parameter( defaultValue = "tests" )
+ @Parameter(defaultValue = "tests")
private String classifier;
/**
* {@inheritDoc}
*/
- protected String getClassifier()
- {
+ @Override
+ protected String getClassifier() {
return classifier;
}
/**
* {@inheritDoc}
*/
- protected String getType()
- {
+ @Override
+ protected String getType() {
return "test-jar";
}
/**
* {@inheritDoc}
*/
- protected File getClassesDirectory()
- {
+ @Override
+ protected File getClassesDirectory() {
return testClassesDirectory;
}
/**
* {@inheritDoc}
*/
- public void execute()
- throws MojoExecutionException
- {
- if ( skip )
- {
- getLog().info( "Skipping packaging of the test-jar" );
- }
- else
- {
+ @Override
+ public void execute() throws MojoExecutionException {
+ if (skip) {
+ getLog().info("Skipping packaging of the test-jar");
+ } else {
super.execute();
}
}
diff --git a/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java
b/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java
index 8fc256c..11c0696 100644
--- a/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jar;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.plugins.jar;
* "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
+ * 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
@@ -18,35 +16,30 @@ package org.apache.maven.plugins.jar;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jar;
import java.io.File;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugins.jar.JarMojo;
/**
* Test for {@link JarMojo}
*
* @version $Id$
*/
-public class JarMojoTest
- extends AbstractMojoTestCase
-{
- private File testPom = new File( getBasedir(),
"src/test/resources/unit/jar-basic-test/pom.xml" );
+public class JarMojoTest extends AbstractMojoTestCase {
+ private File testPom = new File(getBasedir(),
"src/test/resources/unit/jar-basic-test/pom.xml");
/**
* Tests the discovery and configuration of the mojo.
*
* @throws Exception in case of an error
*/
- public void testJarTestEnvironment()
- throws Exception
- {
- JarMojo mojo = (JarMojo) lookupMojo( "jar", testPom );
+ public void testJarTestEnvironment() throws Exception {
+ JarMojo mojo = (JarMojo) lookupMojo("jar", testPom);
- assertNotNull( mojo );
+ assertNotNull(mojo);
- assertEquals( "foo", mojo.getProject().getGroupId() );
+ assertEquals("foo", mojo.getProject().getGroupId());
}
-
}