[MJLINK-71] require maven 3.6.3 (#165)
diff --git a/pom.xml b/pom.xml
index 56c7cf3..09d631e 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,14 +17,13 @@
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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
- <version>34</version>
+ <version>39</version>
<relativePath />
</parent>
@@ -45,8 +43,8 @@
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git</developerConnection>
- <url>https://github.com/apache/maven-jlink-plugin/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/maven-jlink-plugin/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
@@ -65,14 +63,31 @@
</distributionManagement>
<properties>
- <!-- required due to conflict with asm:asm:3.3.1 in Maven 3.1.0, see MNG-5499. -->
- <mavenVersion>3.1.1</mavenVersion>
+ <mavenVersion>3.6.3</mavenVersion>
<maven.compiler.release>11</maven.compiler.release>
<!-- needed for enforce-bytecode-version in maven-parent-pom. -->
<maven.compiler.target>${maven.compiler.release}</maven.compiler.target>
<project.build.outputTimestamp>2020-12-21T12:52:28Z</project.build.outputTimestamp>
</properties>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.junit</groupId>
+ <artifactId>junit-bom</artifactId>
+ <version>5.9.2</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
@@ -93,9 +108,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-archiver</artifactId>
- <version>3.5.1</version>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-utils</artifactId>
+ <version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -136,25 +151,13 @@
</dependency>
</dependencies>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.5.1</version>
- </dependency>
-
- <dependency>
- <groupId>org.junit</groupId>
- <artifactId>junit-bom</artifactId>
- <version>5.9.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/filtered-resources</directory>
+ </resource>
+ </resources>
<pluginManagement>
<plugins>
<!-- remove with next parent upgrade -->
@@ -186,12 +189,6 @@
</plugin>
</plugins>
</pluginManagement>
- <resources>
- <resource>
- <directory>src/main/filtered-resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
</build>
<reporting>
@@ -215,14 +212,6 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>mrm-maven-plugin</artifactId>
<version>1.5.0</version>
- <executions>
- <execution>
- <goals>
- <goal>start</goal>
- <goal>stop</goal>
- </goals>
- </execution>
- </executions>
<configuration>
<propertyName>mrm.repository.url</propertyName>
<repositories>
@@ -232,11 +221,19 @@
<proxyRepo />
</repositories>
</configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>start</goal>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
- <version>3.5.1</version>
+ <version>3.5.1</version>
<configuration>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<environmentVariables>
@@ -264,7 +261,7 @@
<filterProperties>
<mrm.repository.url>${mrm.repository.url}</mrm.repository.url>
</filterProperties>
- <streamLogsOnFailures>true</streamLogsOnFailures>
+ <streamLogsOnFailures>true</streamLogsOnFailures>
<goals>
<goal>clean</goal>
<goal>package</goal>
diff --git a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkExecutor.java b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkExecutor.java
index 3213736..91ec4b4 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkExecutor.java
@@ -1,3 +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.
+ */
package org.apache.maven.plugins.jlink;
/*
@@ -19,17 +37,16 @@
* under the License.
*/
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
-
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
-abstract class AbstractJLinkExecutor
-{
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+
+abstract class AbstractJLinkExecutor {
protected static final String JMODS = "jmods";
private final Log log;
@@ -37,27 +54,23 @@
private final List<String> modulesToAdd = new ArrayList<>();
private final List<String> modulePaths = new ArrayList<>();
- AbstractJLinkExecutor( Log log )
- {
+ AbstractJLinkExecutor(Log log) {
this.log = log;
}
- protected Log getLog()
- {
+ protected Log getLog() {
return this.log;
}
- public abstract Optional<File> getJmodsFolder( /* nullable */ File sourceJdkModules );
+ public abstract Optional<File> getJmodsFolder(/* nullable */ File sourceJdkModules);
- public abstract int executeJlink( List<String> jlinkArgs ) throws MojoExecutionException;
+ public abstract int executeJlink(List<String> jlinkArgs) throws MojoExecutionException;
- public void addAllModules( Collection<String> modulesToAdd )
- {
- this.modulesToAdd.addAll( modulesToAdd );
+ public void addAllModules(Collection<String> modulesToAdd) {
+ this.modulesToAdd.addAll(modulesToAdd);
}
- public void addAllModulePaths( Collection<String> pathsOfModules )
- {
- this.modulePaths.addAll( pathsOfModules );
+ public void addAllModulePaths(Collection<String> pathsOfModules) {
+ this.modulePaths.addAll(pathsOfModules);
}
}
diff --git a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
index 1ed65a0..c99ac2f 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
@@ -1,221 +1,213 @@
-package org.apache.maven.plugins.jlink;
-
-/*
- * 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.
- */
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.toolchain.Toolchain;
-import org.apache.maven.toolchain.ToolchainManager;
-
-/**
- * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
- */
-public abstract class AbstractJLinkMojo
- extends AbstractMojo
-{
- /**
- * <p>
- * Specify the requirements for this jdk toolchain. This overrules the toolchain selected by the
- * maven-toolchain-plugin.
- * </p>
- * <strong>note:</strong> requires at least Maven 3.3.1
- */
- @Parameter
- private Map<String, String> jdkToolchain;
-
- @Parameter( defaultValue = "${project}", readonly = true, required = true )
- private MavenProject project;
-
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
- private MavenSession session;
-
- @Component
- private ToolchainManager toolchainManager;
-
- /**
- * Overload this to produce a zip with another classifier, for example a jlink-zip.
- * @return get the classifier.
- */
- protected abstract String getClassifier();
-
- protected JLinkExecutor getJlinkExecutor()
- {
- return new JLinkExecutor( getToolchain().orElse( null ), getLog() );
- }
-
- protected Optional<Toolchain> getToolchain()
- {
- Toolchain tc = null;
-
- if ( jdkToolchain != null )
- {
- // Maven 3.3.1 has plugin execution scoped Toolchain Support
- try
- {
- Method getToolchainsMethod = toolchainManager.getClass().getMethod( "getToolchains",
- MavenSession.class, String.class, Map.class );
-
- @SuppressWarnings( "unchecked" )
- List<Toolchain> tcs = (List<Toolchain>) getToolchainsMethod.invoke( toolchainManager, getSession(),
- "jdk", jdkToolchain );
-
- if ( tcs != null && tcs.size() > 0 )
- {
- tc = tcs.get( 0 );
- }
- }
- catch ( ReflectiveOperationException | SecurityException | IllegalArgumentException e )
- {
- // ignore
- }
- }
-
- if ( tc == null )
- {
- // TODO: Check if we should make the type configurable?
- tc = toolchainManager.getToolchainFromBuildContext( "jdk", getSession() );
- }
-
- return Optional.ofNullable( tc );
- }
-
- protected MavenProject getProject()
- {
- return project;
- }
-
- protected MavenSession getSession()
- {
- return session;
- }
-
- /**
- * Returns the archive file to generate, based on an optional classifier.
- *
- * @param basedir the output directory
- * @param finalName the name of the ear file
- * @param classifier an optional classifier
- * @param archiveExt The extension of the file.
- * @return the file to generate
- */
- protected File getArchiveFile( File basedir, String finalName, String classifier, String archiveExt )
- {
- if ( basedir == null )
- {
- throw new IllegalArgumentException( "basedir is not allowed to be null" );
- }
- if ( finalName == null )
- {
- throw new IllegalArgumentException( "finalName is not allowed to be null" );
- }
- if ( archiveExt == null )
- {
- throw new IllegalArgumentException( "archiveExt is not allowed to be null" );
- }
-
- if ( finalName.isEmpty() )
- {
- throw new IllegalArgumentException( "finalName is not allowed to be empty." );
- }
- if ( archiveExt.isEmpty() )
- {
- throw new IllegalArgumentException( "archiveExt is not allowed to be empty." );
- }
-
- StringBuilder fileName = new StringBuilder( finalName );
-
- if ( hasClassifier( classifier ) )
- {
- fileName.append( "-" ).append( classifier );
- }
-
- fileName.append( '.' );
- fileName.append( archiveExt );
-
- return new File( basedir, fileName.toString() );
- }
-
- protected boolean hasClassifier( String classifier )
- {
- boolean result = false;
- if ( classifier != null && !classifier.isEmpty() )
- {
- result = true;
- }
-
- return result;
- }
-
- /**
- * This will convert a module path separated by either {@code :} or {@code ;} into a string which uses the platform
- * depend path separator uniformly.
- *
- * @param pluginModulePath The module path.
- * @return The platform separated module path.
- */
- protected StringBuilder convertSeparatedModulePathToPlatformSeparatedModulePath( String pluginModulePath )
- {
- StringBuilder sb = new StringBuilder();
- // Split the module path by either ":" or ";" linux/windows path separator and
- // convert uniformly to the platform used separator.
- String[] splitModule = pluginModulePath.split( "[;:]" );
- for ( String module : splitModule )
- {
- if ( sb.length() > 0 )
- {
- sb.append( File.pathSeparatorChar );
- }
- sb.append( module );
- }
- return sb;
- }
-
- /**
- * Convert a list into a string which is separated by platform depend path separator.
- *
- * @param modulePaths The list of elements.
- * @return The string which contains the elements separated by {@link File#pathSeparatorChar}.
- */
- protected String getPlatformDependSeparateList( Collection<String> modulePaths )
- {
- return String.join( Character.toString( File.pathSeparatorChar ), modulePaths );
- }
-
- /**
- * Convert a list into a
- * @param modules The list of modules.
- * @return The string with the module list which is separated by {@code ,}.
- */
- protected String getCommaSeparatedList( Collection<String> modules )
- {
- return String.join( ",", modules );
- }
-
-}
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.jlink;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.toolchain.Toolchain;
+import org.apache.maven.toolchain.ToolchainManager;
+
+/**
+ * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
+ */
+public abstract class AbstractJLinkMojo extends AbstractMojo {
+ /**
+ * <p>
+ * Specify the requirements for this jdk toolchain. This overrules the toolchain selected by the
+ * maven-toolchain-plugin.
+ * </p>
+ * <strong>note:</strong> requires at least Maven 3.3.1
+ */
+ @Parameter
+ private Map<String, String> jdkToolchain;
+
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
+ private MavenProject project;
+
+ @Parameter(defaultValue = "${session}", readonly = true, required = true)
+ private MavenSession session;
+
+ @Component
+ private ToolchainManager toolchainManager;
+
+ /**
+ * Overload this to produce a zip with another classifier, for example a jlink-zip.
+ * @return get the classifier.
+ */
+ protected abstract String getClassifier();
+
+ protected JLinkExecutor getJlinkExecutor() {
+ return new JLinkExecutor(getToolchain().orElse(null), getLog());
+ }
+
+ protected Optional<Toolchain> getToolchain() {
+ Toolchain tc = null;
+
+ if (jdkToolchain != null) {
+ // Maven 3.3.1 has plugin execution scoped Toolchain Support
+ try {
+ Method getToolchainsMethod = toolchainManager
+ .getClass()
+ .getMethod("getToolchains", MavenSession.class, String.class, Map.class);
+
+ @SuppressWarnings("unchecked")
+ List<Toolchain> tcs = (List<Toolchain>)
+ getToolchainsMethod.invoke(toolchainManager, getSession(), "jdk", jdkToolchain);
+
+ if (tcs != null && tcs.size() > 0) {
+ tc = tcs.get(0);
+ }
+ } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException e) {
+ // ignore
+ }
+ }
+
+ if (tc == null) {
+ // TODO: Check if we should make the type configurable?
+ tc = toolchainManager.getToolchainFromBuildContext("jdk", getSession());
+ }
+
+ return Optional.ofNullable(tc);
+ }
+
+ protected MavenProject getProject() {
+ return project;
+ }
+
+ protected MavenSession getSession() {
+ return session;
+ }
+
+ /**
+ * Returns the archive file to generate, based on an optional classifier.
+ *
+ * @param basedir the output directory
+ * @param finalName the name of the ear file
+ * @param classifier an optional classifier
+ * @param archiveExt The extension of the file.
+ * @return the file to generate
+ */
+ protected File getArchiveFile(File basedir, String finalName, String classifier, String archiveExt) {
+ if (basedir == null) {
+ throw new IllegalArgumentException("basedir is not allowed to be null");
+ }
+ if (finalName == null) {
+ throw new IllegalArgumentException("finalName is not allowed to be null");
+ }
+ if (archiveExt == null) {
+ throw new IllegalArgumentException("archiveExt is not allowed to be null");
+ }
+
+ if (finalName.isEmpty()) {
+ throw new IllegalArgumentException("finalName is not allowed to be empty.");
+ }
+ if (archiveExt.isEmpty()) {
+ throw new IllegalArgumentException("archiveExt is not allowed to be empty.");
+ }
+
+ StringBuilder fileName = new StringBuilder(finalName);
+
+ if (hasClassifier(classifier)) {
+ fileName.append("-").append(classifier);
+ }
+
+ fileName.append('.');
+ fileName.append(archiveExt);
+
+ return new File(basedir, fileName.toString());
+ }
+
+ protected boolean hasClassifier(String classifier) {
+ boolean result = false;
+ if (classifier != null && !classifier.isEmpty()) {
+ result = true;
+ }
+
+ return result;
+ }
+
+ /**
+ * This will convert a module path separated by either {@code :} or {@code ;} into a string which uses the platform
+ * depend path separator uniformly.
+ *
+ * @param pluginModulePath The module path.
+ * @return The platform separated module path.
+ */
+ protected StringBuilder convertSeparatedModulePathToPlatformSeparatedModulePath(String pluginModulePath) {
+ StringBuilder sb = new StringBuilder();
+ // Split the module path by either ":" or ";" linux/windows path separator and
+ // convert uniformly to the platform used separator.
+ String[] splitModule = pluginModulePath.split("[;:]");
+ for (String module : splitModule) {
+ if (sb.length() > 0) {
+ sb.append(File.pathSeparatorChar);
+ }
+ sb.append(module);
+ }
+ return sb;
+ }
+
+ /**
+ * Convert a list into a string which is separated by platform depend path separator.
+ *
+ * @param modulePaths The list of elements.
+ * @return The string which contains the elements separated by {@link File#pathSeparatorChar}.
+ */
+ protected String getPlatformDependSeparateList(Collection<String> modulePaths) {
+ return String.join(Character.toString(File.pathSeparatorChar), modulePaths);
+ }
+
+ /**
+ * Convert a list into a
+ * @param modules The list of modules.
+ * @return The string with the module list which is separated by {@code ,}.
+ */
+ protected String getCommaSeparatedList(Collection<String> modules) {
+ return String.join(",", modules);
+ }
+}
diff --git a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java
index f08406e..086492c 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java
@@ -1,3 +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.
+ */
package org.apache.maven.plugins.jlink;
/*
@@ -19,6 +37,11 @@
* under the License.
*/
+import java.io.File;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.plugin.MojoExecutionException;
@@ -28,24 +51,16 @@
import org.apache.maven.shared.utils.cli.Commandline;
import org.apache.maven.toolchain.Toolchain;
-import java.io.File;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Optional;
-
-abstract class AbstractJLinkToolchainExecutor extends AbstractJLinkExecutor
-{
+abstract class AbstractJLinkToolchainExecutor extends AbstractJLinkExecutor {
private final Toolchain toolchain;
- AbstractJLinkToolchainExecutor( Toolchain toolchain, Log log )
- {
- super( log );
+ AbstractJLinkToolchainExecutor(Toolchain toolchain, Log log) {
+ super(log);
this.toolchain = toolchain;
}
- protected Optional<Toolchain> getToolchain()
- {
- return Optional.ofNullable( this.toolchain );
+ protected Optional<Toolchain> getToolchain() {
+ return Optional.ofNullable(this.toolchain);
}
/**
@@ -54,151 +69,128 @@
* @return the exit code ({@code 0} on success).
*/
@Override
- public int executeJlink( List<String> jlinkArgs ) throws MojoExecutionException
- {
+ public int executeJlink(List<String> jlinkArgs) throws MojoExecutionException {
File jlinkExecutable = getJlinkExecutable();
- getLog().info( "Toolchain in maven-jlink-plugin: jlink [ " + jlinkExecutable + " ]" );
+ getLog().info("Toolchain in maven-jlink-plugin: jlink [ " + jlinkExecutable + " ]");
- Commandline cmd = createJLinkCommandLine( jlinkArgs );
- cmd.setExecutable( jlinkExecutable.getAbsolutePath() );
+ Commandline cmd = createJLinkCommandLine(jlinkArgs);
+ cmd.setExecutable(jlinkExecutable.getAbsolutePath());
- return executeCommand( cmd );
+ return executeCommand(cmd);
}
- private File getJlinkExecutable()
- {
- return new File( getJLinkExecutable() );
+ private File getJlinkExecutable() {
+ return new File(getJLinkExecutable());
}
@Override
- public Optional<File> getJmodsFolder( /* nullable */ File sourceJdkModules )
- {
+ public Optional<File> getJmodsFolder(/* nullable */ File sourceJdkModules) {
// Really Hacky...do we have a better solution to find the jmods directory of the JDK?
File jLinkParent = getJlinkExecutable().getParentFile().getParentFile();
File jmodsFolder;
- if ( sourceJdkModules != null && sourceJdkModules.isDirectory() )
- {
- jmodsFolder = new File( sourceJdkModules, JMODS );
- }
- else
- {
- jmodsFolder = new File( jLinkParent, JMODS );
+ if (sourceJdkModules != null && sourceJdkModules.isDirectory()) {
+ jmodsFolder = new File(sourceJdkModules, JMODS);
+ } else {
+ jmodsFolder = new File(jLinkParent, JMODS);
}
- getLog().debug( " Parent: " + jLinkParent.getAbsolutePath() );
- getLog().debug( " jmodsFolder: " + jmodsFolder.getAbsolutePath() );
+ getLog().debug(" Parent: " + jLinkParent.getAbsolutePath());
+ getLog().debug(" jmodsFolder: " + jmodsFolder.getAbsolutePath());
- return Optional.of( jmodsFolder );
+ return Optional.of(jmodsFolder);
}
- private Commandline createJLinkCommandLine( List<String> jlinkArgs )
- {
+ private Commandline createJLinkCommandLine(List<String> jlinkArgs) {
Commandline cmd = new Commandline();
- jlinkArgs.forEach( arg -> cmd.createArg().setValue( arg ) );
+ jlinkArgs.forEach(arg -> cmd.createArg().setValue(arg));
return cmd;
}
- private String getJLinkExecutable()
- {
+ private String getJLinkExecutable() {
Optional<Toolchain> toolchain = getToolchain();
- if ( !toolchain.isPresent() )
- {
- getLog().error( "Either JDK9+ or a toolchain "
- + "pointing to a JDK9+ containing a jlink binary is required." );
- getLog().info( "See https://maven.apache.org/guides/mini/guide-using-toolchains.html "
- + "for mor information." );
- throw new IllegalStateException( "Running on JDK8 and no toolchain found." );
+ if (!toolchain.isPresent()) {
+ getLog().error("Either JDK9+ or a toolchain "
+ + "pointing to a JDK9+ containing a jlink binary is required.");
+ getLog().info("See https://maven.apache.org/guides/mini/guide-using-toolchains.html "
+ + "for mor information.");
+ throw new IllegalStateException("Running on JDK8 and no toolchain found.");
}
- String jLinkExecutable = toolchain.orElseThrow( NoSuchElementException::new ).findTool( "jlink" );
+ String jLinkExecutable =
+ toolchain.orElseThrow(NoSuchElementException::new).findTool("jlink");
- if ( jLinkExecutable.isEmpty() )
- {
- throw new IllegalStateException( "The jlink executable '"
- + jLinkExecutable + "' doesn't exist or is not a file." );
+ if (jLinkExecutable.isEmpty()) {
+ throw new IllegalStateException(
+ "The jlink executable '" + jLinkExecutable + "' doesn't exist or is not a file.");
}
// TODO: Check if there exist a more elegant way?
- String jLinkCommand = "jlink" + ( SystemUtils.IS_OS_WINDOWS ? ".exe" : "" );
+ String jLinkCommand = "jlink" + (SystemUtils.IS_OS_WINDOWS ? ".exe" : "");
- File jLinkExe = new File( jLinkExecutable );
+ File jLinkExe = new File(jLinkExecutable);
- if ( jLinkExe.isDirectory() )
- {
- jLinkExe = new File( jLinkExe, jLinkCommand );
+ if (jLinkExe.isDirectory()) {
+ jLinkExe = new File(jLinkExe, jLinkCommand);
}
- if ( SystemUtils.IS_OS_WINDOWS && jLinkExe.getName().indexOf( '.' ) < 0 )
- {
- jLinkExe = new File( jLinkExe.getPath() + ".exe" );
+ if (SystemUtils.IS_OS_WINDOWS && jLinkExe.getName().indexOf('.') < 0) {
+ jLinkExe = new File(jLinkExe.getPath() + ".exe");
}
- if ( !jLinkExe.isFile() )
- {
- throw new IllegalStateException( "The jlink executable '"
- + jLinkExe + "' doesn't exist or is not a file." );
+ if (!jLinkExe.isFile()) {
+ throw new IllegalStateException("The jlink executable '" + jLinkExe + "' doesn't exist or is not a file.");
}
return jLinkExe.getAbsolutePath();
}
- private int executeCommand( Commandline cmd )
- throws MojoExecutionException
- {
- if ( getLog().isDebugEnabled() )
- {
+ private int executeCommand(Commandline cmd) throws MojoExecutionException {
+ if (getLog().isDebugEnabled()) {
// no quoted arguments ???
- getLog().debug( CommandLineUtils.toString( cmd.getCommandline() ).replaceAll( "'", "" ) );
+ getLog().debug(CommandLineUtils.toString(cmd.getCommandline()).replaceAll("'", ""));
}
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
- try
- {
- int exitCode = CommandLineUtils.executeCommandLine( cmd, out, err );
+ try {
+ int exitCode = CommandLineUtils.executeCommandLine(cmd, out, err);
- String output = StringUtils.isEmpty( out.getOutput() ) ? null : '\n' + out.getOutput().trim();
+ String output = StringUtils.isEmpty(out.getOutput())
+ ? null
+ : '\n' + out.getOutput().trim();
- if ( exitCode != 0 )
- {
+ if (exitCode != 0) {
- if ( output != null && !output.isEmpty() )
- {
+ if (output != null && !output.isEmpty()) {
// Reconsider to use WARN / ERROR ?
// getLog().error( output );
- for ( String outputLine : output.split( "\n" ) )
- {
- getLog().error( outputLine );
+ for (String outputLine : output.split("\n")) {
+ getLog().error(outputLine);
}
}
- StringBuilder msg = new StringBuilder( "\nExit code: " );
- msg.append( exitCode );
- if ( StringUtils.isNotEmpty( err.getOutput() ) )
- {
- msg.append( " - " ).append( err.getOutput() );
+ StringBuilder msg = new StringBuilder("\nExit code: ");
+ msg.append(exitCode);
+ if (StringUtils.isNotEmpty(err.getOutput())) {
+ msg.append(" - ").append(err.getOutput());
}
- msg.append( '\n' );
- msg.append( "Command line was: " ).append( cmd ).append( '\n' ).append( '\n' );
+ msg.append('\n');
+ msg.append("Command line was: ").append(cmd).append('\n').append('\n');
- throw new MojoExecutionException( msg.toString() );
+ throw new MojoExecutionException(msg.toString());
}
- if ( output != null && !output.isEmpty() )
- {
- //getLog().info( output );
- for ( String outputLine : output.split( "\n" ) )
- {
- getLog().info( outputLine );
+ if (output != null && !output.isEmpty()) {
+ // getLog().info( output );
+ for (String outputLine : output.split("\n")) {
+ getLog().info(outputLine);
}
}
return exitCode;
- }
- catch ( CommandLineException e )
- {
- throw new MojoExecutionException( "Unable to execute jlink command: " + e.getMessage(), e );
+ } catch (CommandLineException e) {
+ throw new MojoExecutionException("Unable to execute jlink command: " + e.getMessage(), e);
}
}
}
diff --git a/src/main/java/org/apache/maven/plugins/jlink/JLinkExecutor.java b/src/main/java/org/apache/maven/plugins/jlink/JLinkExecutor.java
index 9953b50..e8e72fb 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/JLinkExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkExecutor.java
@@ -1,3 +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.
+ */
package org.apache.maven.plugins.jlink;
/*
@@ -26,6 +44,7 @@
import java.util.List;
import java.util.Optional;
import java.util.spi.ToolProvider;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
@@ -37,103 +56,87 @@
* <p>This implementation uses the JDK9+ Toolprovider SPI to find and execute jlink.
* This way, no fork needs to be created.</p>
*/
-class JLinkExecutor extends AbstractJLinkToolchainExecutor
-{
+class JLinkExecutor extends AbstractJLinkToolchainExecutor {
private final ToolProvider toolProvider;
- JLinkExecutor( Toolchain toolchain, Log log )
- {
- super( toolchain, log );
+ JLinkExecutor(Toolchain toolchain, Log log) {
+ super(toolchain, log);
this.toolProvider = getJLinkExecutable();
}
- protected final ToolProvider getJLinkExecutable()
- {
- return ToolProvider
- .findFirst( "jlink" )
- .orElseThrow( () -> new IllegalStateException( "No jlink tool found." ) );
+ protected final ToolProvider getJLinkExecutable() {
+ return ToolProvider.findFirst("jlink").orElseThrow(() -> new IllegalStateException("No jlink tool found."));
}
@Override
- public int executeJlink( List<String> jlinkArgs ) throws MojoExecutionException
- {
- if ( getToolchain().isPresent() )
- {
- return super.executeJlink( jlinkArgs );
+ public int executeJlink(List<String> jlinkArgs) throws MojoExecutionException {
+ if (getToolchain().isPresent()) {
+ return super.executeJlink(jlinkArgs);
}
- if ( getLog().isDebugEnabled() )
- {
+ if (getLog().isDebugEnabled()) {
// no quoted arguments ???
- getLog().debug( this.toolProvider.name() + " " + jlinkArgs );
+ getLog().debug(this.toolProvider.name() + " " + jlinkArgs);
}
- try ( StringWriter strErr = new StringWriter();
- PrintWriter err = new PrintWriter( strErr );
- StringWriter strOut = new StringWriter();
- PrintWriter out = new PrintWriter( strOut ) )
- {
- int exitCode = this.toolProvider.run( out, err, jlinkArgs.toArray( new String[0] ) );
+ try (StringWriter strErr = new StringWriter();
+ PrintWriter err = new PrintWriter(strErr);
+ StringWriter strOut = new StringWriter();
+ PrintWriter out = new PrintWriter(strOut)) {
+ int exitCode = this.toolProvider.run(out, err, jlinkArgs.toArray(new String[0]));
out.flush();
err.flush();
String outAsString = strOut.toString();
- String output = ( StringUtils.isEmpty( outAsString ) ? null : '\n' + outAsString.trim() );
+ String output = (StringUtils.isEmpty(outAsString) ? null : '\n' + outAsString.trim());
- if ( exitCode != 0 )
- {
- if ( StringUtils.isNotEmpty( output ) )
- {
+ if (exitCode != 0) {
+ if (StringUtils.isNotEmpty(output)) {
// Reconsider to use WARN / ERROR ?
// getLog().error( output );
- for ( String outputLine : output.split( "\n" ) )
- {
- getLog().error( outputLine );
+ for (String outputLine : output.split("\n")) {
+ getLog().error(outputLine);
}
}
- StringBuilder msg = new StringBuilder( "\nExit code: " );
- msg.append( exitCode );
+ StringBuilder msg = new StringBuilder("\nExit code: ");
+ msg.append(exitCode);
String errAsString = strErr.toString();
- if ( StringUtils.isNotEmpty( errAsString ) )
- {
- msg.append( " - " ).append( errAsString );
+ if (StringUtils.isNotEmpty(errAsString)) {
+ msg.append(" - ").append(errAsString);
}
- msg.append( '\n' );
- msg.append( "Command line was: " ).append( this.toolProvider.name() ).append( ' ' ).append(
- jlinkArgs ).append( '\n' ).append( '\n' );
+ msg.append('\n');
+ msg.append("Command line was: ")
+ .append(this.toolProvider.name())
+ .append(' ')
+ .append(jlinkArgs)
+ .append('\n')
+ .append('\n');
- throw new MojoExecutionException( msg.toString() );
+ throw new MojoExecutionException(msg.toString());
}
- if ( StringUtils.isNotEmpty( output ) )
- {
- //getLog().info( output );
- for ( String outputLine : output.split( "\n" ) )
- {
- getLog().info( outputLine );
+ if (StringUtils.isNotEmpty(output)) {
+ // getLog().info( output );
+ for (String outputLine : output.split("\n")) {
+ getLog().info(outputLine);
}
}
return exitCode;
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Unable to execute jlink command: " + e.getMessage(), e );
+ } catch (IOException e) {
+ throw new MojoExecutionException("Unable to execute jlink command: " + e.getMessage(), e);
}
}
@Override
- public Optional<File> getJmodsFolder( /* nullable */ File sourceJdkModules )
- {
- if ( getToolchain().isPresent() )
- {
- return super.getJmodsFolder( sourceJdkModules );
+ public Optional<File> getJmodsFolder(/* nullable */ File sourceJdkModules) {
+ if (getToolchain().isPresent()) {
+ return super.getJmodsFolder(sourceJdkModules);
}
- if ( sourceJdkModules != null && sourceJdkModules.isDirectory() )
- {
- return Optional.of( new File( sourceJdkModules, JMODS ) );
+ if (sourceJdkModules != null && sourceJdkModules.isDirectory()) {
+ return Optional.of(new File(sourceJdkModules, JMODS));
}
// ToolProvider does not need jmods folder to be set.
diff --git a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
index b0b273b..a5f203d 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
@@ -1,3 +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.
+ */
package org.apache.maven.plugins.jlink;
/*
@@ -60,13 +78,11 @@
* The JLink goal is intended to create a Java Run Time Image file based on
* <a href="https://openjdk.java.net/jeps/282">https://openjdk.java.net/jeps/282</a>,
* <a href="https://openjdk.java.net/jeps/220">https://openjdk.java.net/jeps/220</a>.
- *
+ *
* @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
*/
-@Mojo( name = "jlink", requiresDependencyResolution = ResolutionScope.RUNTIME, defaultPhase = LifecyclePhase.PACKAGE )
-public class JLinkMojo
- extends AbstractJLinkMojo
-{
+@Mojo(name = "jlink", requiresDependencyResolution = ResolutionScope.RUNTIME, defaultPhase = LifecyclePhase.PACKAGE)
+public class JLinkMojo extends AbstractJLinkMojo {
@Component
private LocationManager locationManager;
@@ -84,7 +100,7 @@
* This is intended to strip debug information out. The command line equivalent of <code>jlink</code> is:
* <code>-G, --strip-debug</code> strip debug information.
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean stripDebug;
/**
@@ -126,7 +142,7 @@
/**
* Limit the universe of observable modules. The following gives an example of the configuration which can be used
* in the <code>pom.xml</code> file.
- *
+ *
* <pre>
* <limitModules>
* <limitModule>mod1</limitModule>
@@ -135,7 +151,7 @@
* .
* </limitModules>
* </pre>
- *
+ *
* This configuration is the equivalent of the command line option:
* <code>--limit-modules <mod>[,<mod>...]</code>
*/
@@ -150,7 +166,7 @@
* By using the --add-modules you can define the root modules to be resolved. The configuration in
* <code>pom.xml</code> file can look like this:
* </p>
- *
+ *
* <pre>
* <addModules>
* <addModule>mod1</addModule>
@@ -159,7 +175,7 @@
* .
* </addModules>
* </pre>
- *
+ *
* The command line equivalent for jlink is: <code>--add-modules <mod>[,<mod>...]</code>.
*/
@Parameter
@@ -180,13 +196,13 @@
* otherwise {@code default} will be used as subdirectory.
* This ensures that multiple executions using classifiers will not overwrite the previous run’s image.</p>
*/
- @Parameter( defaultValue = "${project.build.directory}/maven-jlink", required = true, readonly = true )
+ @Parameter(defaultValue = "${project.build.directory}/maven-jlink", required = true, readonly = true)
private File outputDirectoryImage;
- @Parameter( defaultValue = "${project.build.directory}", required = true, readonly = true )
+ @Parameter(defaultValue = "${project.build.directory}", required = true, readonly = true)
private File buildDirectory;
- @Parameter( defaultValue = "${project.build.outputDirectory}", required = true, readonly = true )
+ @Parameter(defaultValue = "${project.build.outputDirectory}", required = true, readonly = true)
private File outputDirectory;
/**
@@ -207,7 +223,7 @@
/**
* Add the option <code>--bind-services</code> or not.
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean bindServices;
/**
@@ -219,26 +235,26 @@
/**
* <code>--ignore-signing-information</code>
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean ignoreSigningInformation;
/**
* This will suppress to have an <code>includes</code> directory in the resulting Java Run Time Image. The JLink
* command line equivalent is: <code>--no-header-files</code>
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean noHeaderFiles;
/**
* This will suppress to have the <code>man</code> directory in the resulting Java Run Time Image. The JLink command
* line equivalent is: <code>--no-man-pages</code>
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean noManPages;
/**
* Suggest providers that implement the given service types from the module path.
- *
+ *
* <pre>
* <suggestProviders>
* <suggestProvider>name-a</suggestProvider>
@@ -247,7 +263,7 @@
* .
* </suggestProviders>
* </pre>
- *
+ *
* The jlink command linke equivalent: <code>--suggest-providers [<name>,...]</code>
*/
@Parameter
@@ -277,13 +293,13 @@
/**
* This will turn on verbose mode. The jlink command line equivalent is: <code>--verbose</code>
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean verbose;
/**
* The JAR archiver needed for archiving the environments.
*/
- @Component( role = Archiver.class, hint = "zip" )
+ @Component(role = Archiver.class, hint = "zip")
private ZipArchiver zipArchiver;
/**
@@ -305,7 +321,7 @@
* Name of the generated ZIP file in the <code>target</code> directory. This will not change the name of the
* installed/deployed file.
*/
- @Parameter( defaultValue = "${project.build.finalName}", readonly = true )
+ @Parameter(defaultValue = "${project.build.finalName}", readonly = true)
private String finalName;
/**
@@ -315,8 +331,7 @@
private MavenProjectHelper projectHelper;
@Override
- public void execute() throws MojoExecutionException, MojoFailureException
- {
+ public void execute() throws MojoExecutionException, MojoFailureException {
failIfParametersAreNotInTheirValidValueRanges();
setOutputDirectoryImage();
@@ -325,168 +340,141 @@
JLinkExecutor jLinkExec = getExecutor();
Collection<String> modulesToAdd = new ArrayList<>();
- if ( addModules != null )
- {
- modulesToAdd.addAll( addModules );
+ if (addModules != null) {
+ modulesToAdd.addAll(addModules);
}
- jLinkExec.addAllModules( modulesToAdd );
+ jLinkExec.addAllModules(modulesToAdd);
Collection<String> pathsOfModules = new ArrayList<>();
- if ( modulePaths != null )
- {
- pathsOfModules.addAll( modulePaths );
+ if (modulePaths != null) {
+ pathsOfModules.addAll(modulePaths);
}
- for ( Entry<String, File> item : getModulePathElements().entrySet() )
- {
- getLog().info( " -> module: " + item.getKey() + " ( " + item.getValue().getPath() + " )" );
+ for (Entry<String, File> item : getModulePathElements().entrySet()) {
+ getLog().info(" -> module: " + item.getKey() + " ( "
+ + item.getValue().getPath() + " )");
// We use the real module name and not the artifact Id...
- modulesToAdd.add( item.getKey() );
- pathsOfModules.add( item.getValue().getPath() );
+ modulesToAdd.add(item.getKey());
+ pathsOfModules.add(item.getValue().getPath());
}
// The jmods directory of the JDK
- jLinkExec.getJmodsFolder( this.sourceJdkModules ).ifPresent(
- jmodsFolder -> pathsOfModules.add( jmodsFolder.getAbsolutePath() )
- );
- jLinkExec.addAllModulePaths( pathsOfModules );
+ jLinkExec
+ .getJmodsFolder(this.sourceJdkModules)
+ .ifPresent(jmodsFolder -> pathsOfModules.add(jmodsFolder.getAbsolutePath()));
+ jLinkExec.addAllModulePaths(pathsOfModules);
- List<String> jlinkArgs = createJlinkArgs( pathsOfModules, modulesToAdd );
+ List<String> jlinkArgs = createJlinkArgs(pathsOfModules, modulesToAdd);
- try
- {
- jLinkExec.executeJlink( jlinkArgs );
- }
- catch ( IllegalStateException e )
- {
- throw new MojoFailureException( "Unable to find jlink command: " + e.getMessage(), e );
+ try {
+ jLinkExec.executeJlink(jlinkArgs);
+ } catch (IllegalStateException e) {
+ throw new MojoFailureException("Unable to find jlink command: " + e.getMessage(), e);
}
- File createZipArchiveFromImage = createZipArchiveFromImage( buildDirectory, outputDirectoryImage );
+ File createZipArchiveFromImage = createZipArchiveFromImage(buildDirectory, outputDirectoryImage);
- if ( hasClassifier() )
- {
- projectHelper.attachArtifact( getProject(), "jlink", getClassifier(), createZipArchiveFromImage );
- }
- 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(), "jlink", getClassifier(), createZipArchiveFromImage);
+ } 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( createZipArchiveFromImage );
+ getProject().getArtifact().setFile(createZipArchiveFromImage);
}
}
- private List<File> getCompileClasspathElements( MavenProject project )
- {
- List<File> list = new ArrayList<>( project.getArtifacts().size() + 1 );
+ private List<File> getCompileClasspathElements(MavenProject project) {
+ List<File> list = new ArrayList<>(project.getArtifacts().size() + 1);
- for ( Artifact a : project.getArtifacts() )
- {
- getLog().debug( "Artifact: " + a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion() );
- list.add( a.getFile() );
+ for (Artifact a : project.getArtifacts()) {
+ getLog().debug("Artifact: " + a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion());
+ list.add(a.getFile());
}
return list;
}
- private Map<String, File> getModulePathElements()
- throws MojoFailureException
- {
+ private Map<String, File> getModulePathElements() throws MojoFailureException {
// For now only allow named modules. Once we can create a graph with ASM we can specify exactly the modules
// and we can detect if auto modules are used. In that case, MavenProject.setFile() should not be used, so
// you cannot depend on this project and so it won't be distributed.
Map<String, File> modulepathElements = new HashMap<>();
- try
- {
- Collection<File> dependencyArtifacts = getCompileClasspathElements( getProject() );
+ try {
+ Collection<File> dependencyArtifacts = getCompileClasspathElements(getProject());
- ResolvePathsRequest<File> request = ResolvePathsRequest.ofFiles( dependencyArtifacts );
+ ResolvePathsRequest<File> request = ResolvePathsRequest.ofFiles(dependencyArtifacts);
Optional<Toolchain> toolchain = getToolchain();
- if ( toolchain.isPresent()
- && toolchain.orElseThrow( NoSuchElementException::new ) instanceof DefaultJavaToolChain )
- {
- Toolchain toolcahin1 = toolchain.orElseThrow( NoSuchElementException::new );
- request.setJdkHome( new File( ( (DefaultJavaToolChain) toolcahin1 ).getJavaHome() ) );
+ if (toolchain.isPresent()
+ && toolchain.orElseThrow(NoSuchElementException::new) instanceof DefaultJavaToolChain) {
+ Toolchain toolcahin1 = toolchain.orElseThrow(NoSuchElementException::new);
+ request.setJdkHome(new File(((DefaultJavaToolChain) toolcahin1).getJavaHome()));
}
- ResolvePathsResult<File> resolvePathsResult = locationManager.resolvePaths( request );
+ ResolvePathsResult<File> resolvePathsResult = locationManager.resolvePaths(request);
- for ( Map.Entry<File, JavaModuleDescriptor> entry : resolvePathsResult.getPathElements().entrySet() )
- {
+ for (Map.Entry<File, JavaModuleDescriptor> entry :
+ resolvePathsResult.getPathElements().entrySet()) {
JavaModuleDescriptor descriptor = entry.getValue();
- if ( descriptor == null )
- {
+ if (descriptor == null) {
String message = "The given dependency " + entry.getKey()
- + " does not have a module-info.java file. So it can't be linked.";
- getLog().error( message );
- throw new MojoFailureException( message );
+ + " does not have a module-info.java file. So it can't be linked.";
+ getLog().error(message);
+ throw new MojoFailureException(message);
}
// Don't warn for automatic modules, let the jlink tool do that
- getLog().debug( " module: " + descriptor.name() + " automatic: " + descriptor.isAutomatic() );
- if ( modulepathElements.containsKey( descriptor.name() ) )
- {
- getLog().warn( "The module name " + descriptor.name() + " does already exists." );
+ getLog().debug(" module: " + descriptor.name() + " automatic: " + descriptor.isAutomatic());
+ if (modulepathElements.containsKey(descriptor.name())) {
+ getLog().warn("The module name " + descriptor.name() + " does already exists.");
}
- modulepathElements.put( descriptor.name(), entry.getKey() );
+ modulepathElements.put(descriptor.name(), entry.getKey());
}
// This part is for the module in target/classes ? (Hacky..)
// FIXME: Is there a better way to identify that code exists?
- if ( outputDirectory.exists() )
- {
- List<File> singletonList = Collections.singletonList( outputDirectory );
+ if (outputDirectory.exists()) {
+ List<File> singletonList = Collections.singletonList(outputDirectory);
- ResolvePathsRequest<File> singleModuls = ResolvePathsRequest.ofFiles( singletonList );
+ ResolvePathsRequest<File> singleModuls = ResolvePathsRequest.ofFiles(singletonList);
- ResolvePathsResult<File> resolvePaths = locationManager.resolvePaths( singleModuls );
- for ( Entry<File, JavaModuleDescriptor> entry : resolvePaths.getPathElements().entrySet() )
- {
+ ResolvePathsResult<File> resolvePaths = locationManager.resolvePaths(singleModuls);
+ for (Entry<File, JavaModuleDescriptor> entry :
+ resolvePaths.getPathElements().entrySet()) {
JavaModuleDescriptor descriptor = entry.getValue();
- if ( descriptor == null )
- {
+ if (descriptor == null) {
String message = "The given project " + entry.getKey()
- + " does not contain a module-info.java file. So it can't be linked.";
- getLog().error( message );
- throw new MojoFailureException( message );
+ + " does not contain a module-info.java file. So it can't be linked.";
+ getLog().error(message);
+ throw new MojoFailureException(message);
}
- if ( modulepathElements.containsKey( descriptor.name() ) )
- {
- getLog().warn( "The module name " + descriptor.name() + " does already exists." );
+ if (modulepathElements.containsKey(descriptor.name())) {
+ getLog().warn("The module name " + descriptor.name() + " does already exists.");
}
- modulepathElements.put( descriptor.name(), entry.getKey() );
+ modulepathElements.put(descriptor.name(), entry.getKey());
}
}
- }
- catch ( IOException e )
- {
- getLog().error( e.getMessage() );
- throw new MojoFailureException( e.getMessage() );
+ } catch (IOException e) {
+ getLog().error(e.getMessage());
+ throw new MojoFailureException(e.getMessage());
}
return modulepathElements;
}
- private JLinkExecutor getExecutor()
- {
+ private JLinkExecutor getExecutor() {
return getJlinkExecutor();
}
- private boolean projectHasAlreadySetAnArtifact( )
- {
- if ( getProject().getArtifact().getFile() != null )
- {
+ private boolean projectHasAlreadySetAnArtifact() {
+ if (getProject().getArtifact().getFile() != null) {
return getProject().getArtifact().getFile().isFile();
- }
- else
- {
+ } else {
return false;
}
}
@@ -494,86 +482,68 @@
/**
* @return true in case where the classifier is not {@code null} and contains something else than white spaces.
*/
- protected boolean hasClassifier()
- {
+ protected boolean hasClassifier() {
boolean result = false;
- if ( getClassifier() != null && !getClassifier().isEmpty() )
- {
+ if (getClassifier() != null && !getClassifier().isEmpty()) {
result = true;
}
return result;
}
- private File createZipArchiveFromImage( File outputDirectory, File outputDirectoryImage )
- throws MojoExecutionException
- {
- zipArchiver.addDirectory( outputDirectoryImage );
+ private File createZipArchiveFromImage(File outputDirectory, File outputDirectoryImage)
+ throws MojoExecutionException {
+ zipArchiver.addDirectory(outputDirectoryImage);
- File resultArchive = getArchiveFile( outputDirectory, finalName, getClassifier(), "zip" );
+ File resultArchive = getArchiveFile(outputDirectory, finalName, getClassifier(), "zip");
- zipArchiver.setDestFile( resultArchive );
- try
- {
+ zipArchiver.setDestFile(resultArchive);
+ try {
zipArchiver.createArchive();
- }
- catch ( ArchiverException | IOException e )
- {
- getLog().error( e.getMessage(), e );
- throw new MojoExecutionException( e.getMessage(), e );
+ } catch (ArchiverException | IOException e) {
+ getLog().error(e.getMessage(), e);
+ throw new MojoExecutionException(e.getMessage(), e);
}
return resultArchive;
-
}
- private void failIfParametersAreNotInTheirValidValueRanges()
- throws MojoFailureException
- {
- if ( compress != null && ( compress < 0 || compress > 2 ) )
- {
+ private void failIfParametersAreNotInTheirValidValueRanges() throws MojoFailureException {
+ if (compress != null && (compress < 0 || compress > 2)) {
String message = "The given compress parameters " + compress + " is not in the valid value range from 0..2";
- getLog().error( message );
- throw new MojoFailureException( message );
+ getLog().error(message);
+ throw new MojoFailureException(message);
}
- if ( endian != null && ( !"big".equals( endian ) && !"little".equals( endian ) ) )
- {
+ if (endian != null && (!"big".equals(endian) && !"little".equals(endian))) {
String message = "The given endian parameter " + endian
+ " does not contain one of the following values: 'little' or 'big'.";
- getLog().error( message );
- throw new MojoFailureException( message );
+ getLog().error(message);
+ throw new MojoFailureException(message);
}
- if ( addOptions != null && !addOptions.isEmpty() )
- {
+ if (addOptions != null && !addOptions.isEmpty()) {
requireJdk14();
}
}
- private void requireJdk14() throws MojoFailureException
- {
+ private void requireJdk14() throws MojoFailureException {
// needs JDK 14+
Optional<Toolchain> optToolchain = getToolchain();
String java14reqMsg = "parameter 'addOptions' needs at least a Java 14 runtime or a Java 14 toolchain.";
- if ( optToolchain.isPresent() )
- {
- Toolchain toolchain = optToolchain.orElseThrow( NoSuchElementException::new );
- if ( !( toolchain instanceof ToolchainPrivate ) )
- {
- getLog().warn( "Unable to check toolchain java version." );
+ if (optToolchain.isPresent()) {
+ Toolchain toolchain = optToolchain.orElseThrow(NoSuchElementException::new);
+ if (!(toolchain instanceof ToolchainPrivate)) {
+ getLog().warn("Unable to check toolchain java version.");
return;
}
ToolchainPrivate toolchainPrivate = (ToolchainPrivate) toolchain;
- if ( !toolchainPrivate.matchesRequirements( singletonMap( "jdk", "14" ) ) )
- {
- throw new MojoFailureException( java14reqMsg );
+ if (!toolchainPrivate.matchesRequirements(singletonMap("jdk", "14"))) {
+ throw new MojoFailureException(java14reqMsg);
}
- }
- else if ( !JavaVersion.JAVA_VERSION.isAtLeast( "14" ) )
- {
- throw new MojoFailureException( java14reqMsg );
+ } else if (!JavaVersion.JAVA_VERSION.isAtLeast("14")) {
+ throw new MojoFailureException(java14reqMsg);
}
}
@@ -583,178 +553,142 @@
* <p>Rationale: If a user creates multiple jlink artifacts using classifiers,
* the directories should not overwrite themselves for each execution.</p>
*/
- private void setOutputDirectoryImage()
- {
- if ( hasClassifier() )
- {
- final File classifiersDirectory = new File( outputDirectoryImage, "classifiers" );
- outputDirectoryImage = new File( classifiersDirectory, classifier );
- }
- else
- {
- outputDirectoryImage = new File( outputDirectoryImage, "default" );
+ private void setOutputDirectoryImage() {
+ if (hasClassifier()) {
+ final File classifiersDirectory = new File(outputDirectoryImage, "classifiers");
+ outputDirectoryImage = new File(classifiersDirectory, classifier);
+ } else {
+ outputDirectoryImage = new File(outputDirectoryImage, "default");
}
}
- private void ifOutputDirectoryExistsDelteIt()
- throws MojoExecutionException
- {
- if ( outputDirectoryImage.exists() )
- {
+ private void ifOutputDirectoryExistsDelteIt() throws MojoExecutionException {
+ if (outputDirectoryImage.exists()) {
// Delete the output folder of JLink before we start
// otherwise JLink will fail with a message "Error: directory already exists: ..."
- try
- {
- getLog().debug( "Deleting existing " + outputDirectoryImage.getAbsolutePath() );
- FileUtils.forceDelete( outputDirectoryImage );
- }
- catch ( IOException e )
- {
- getLog().error( "IOException", e );
- throw new MojoExecutionException( "Failure during deletion of " + outputDirectoryImage.getAbsolutePath()
- + " occured." );
+ try {
+ getLog().debug("Deleting existing " + outputDirectoryImage.getAbsolutePath());
+ FileUtils.forceDelete(outputDirectoryImage);
+ } catch (IOException e) {
+ getLog().error("IOException", e);
+ throw new MojoExecutionException(
+ "Failure during deletion of " + outputDirectoryImage.getAbsolutePath() + " occured.");
}
}
}
- private List<String> createJlinkArgs( Collection<String> pathsOfModules,
- Collection<String> modulesToAdd )
- {
+ private List<String> createJlinkArgs(Collection<String> pathsOfModules, Collection<String> modulesToAdd) {
List<String> jlinkArgs = new ArrayList<>();
- if ( stripDebug )
- {
- jlinkArgs.add( "--strip-debug" );
+ if (stripDebug) {
+ jlinkArgs.add("--strip-debug");
}
- if ( bindServices )
- {
- jlinkArgs.add( "--bind-services" );
+ if (bindServices) {
+ jlinkArgs.add("--bind-services");
}
- if ( endian != null )
- {
- jlinkArgs.add( "--endian" );
- jlinkArgs.add( endian );
+ if (endian != null) {
+ jlinkArgs.add("--endian");
+ jlinkArgs.add(endian);
}
- if ( ignoreSigningInformation )
- {
- jlinkArgs.add( "--ignore-signing-information" );
+ if (ignoreSigningInformation) {
+ jlinkArgs.add("--ignore-signing-information");
}
- if ( compress != null )
- {
- jlinkArgs.add( "--compress" );
- jlinkArgs.add( compress + "" );
+ if (compress != null) {
+ jlinkArgs.add("--compress");
+ jlinkArgs.add(compress + "");
}
- if ( launcher != null )
- {
- jlinkArgs.add( "--launcher" );
- jlinkArgs.add( launcher );
+ if (launcher != null) {
+ jlinkArgs.add("--launcher");
+ jlinkArgs.add(launcher);
}
- if ( addOptions != null && !addOptions.isEmpty() )
- {
- jlinkArgs.add( "--add-options" );
- jlinkArgs.add( String.format( "\"%s\"", String.join( " ", addOptions ) ) );
+ if (addOptions != null && !addOptions.isEmpty()) {
+ jlinkArgs.add("--add-options");
+ jlinkArgs.add(String.format("\"%s\"", String.join(" ", addOptions)));
}
- if ( disablePlugin != null )
- {
- jlinkArgs.add( "--disable-plugin" );
- jlinkArgs.add( disablePlugin );
-
+ if (disablePlugin != null) {
+ jlinkArgs.add("--disable-plugin");
+ jlinkArgs.add(disablePlugin);
}
- if ( pathsOfModules != null )
- {
+ if (pathsOfModules != null) {
// @formatter:off
- jlinkArgs.add( "--module-path" );
- jlinkArgs.add( getPlatformDependSeparateList( pathsOfModules ).replace( "\\", "\\\\" ) );
+ jlinkArgs.add("--module-path");
+ jlinkArgs.add(getPlatformDependSeparateList(pathsOfModules).replace("\\", "\\\\"));
// @formatter:off
}
- if ( noHeaderFiles )
- {
- jlinkArgs.add( "--no-header-files" );
+ if (noHeaderFiles) {
+ jlinkArgs.add("--no-header-files");
}
- if ( noManPages )
- {
- jlinkArgs.add( "--no-man-pages" );
+ if (noManPages) {
+ jlinkArgs.add("--no-man-pages");
}
- if ( hasSuggestProviders() )
- {
- jlinkArgs.add( "--suggest-providers" );
- String sb = getCommaSeparatedList( suggestProviders );
- jlinkArgs.add( sb );
+ if (hasSuggestProviders()) {
+ jlinkArgs.add("--suggest-providers");
+ String sb = getCommaSeparatedList(suggestProviders);
+ jlinkArgs.add(sb);
}
- if ( hasLimitModules() )
- {
- jlinkArgs.add( "--limit-modules" );
- String sb = getCommaSeparatedList( limitModules );
- jlinkArgs.add( sb );
+ if (hasLimitModules()) {
+ jlinkArgs.add("--limit-modules");
+ String sb = getCommaSeparatedList(limitModules);
+ jlinkArgs.add(sb);
}
- if ( !modulesToAdd.isEmpty() )
- {
- jlinkArgs.add( "--add-modules" );
+ if (!modulesToAdd.isEmpty()) {
+ jlinkArgs.add("--add-modules");
// This must be name of the module and *NOT* the name of the
// file! Can we somehow pre check this information to fail early?
- String sb = getCommaSeparatedList( modulesToAdd );
- jlinkArgs.add( sb.replace( "\\", "\\\\" ) );
+ String sb = getCommaSeparatedList(modulesToAdd);
+ jlinkArgs.add(sb.replace("\\", "\\\\"));
}
- if ( hasIncludeLocales() )
- {
- jlinkArgs.add( "--add-modules" );
- jlinkArgs.add( "jdk.localedata" );
- jlinkArgs.add( "--include-locales" );
- String sb = getCommaSeparatedList( includeLocales );
- jlinkArgs.add( sb );
+ if (hasIncludeLocales()) {
+ jlinkArgs.add("--add-modules");
+ jlinkArgs.add("jdk.localedata");
+ jlinkArgs.add("--include-locales");
+ String sb = getCommaSeparatedList(includeLocales);
+ jlinkArgs.add(sb);
}
- if ( pluginModulePath != null )
- {
- jlinkArgs.add( "--plugin-module-path" );
- StringBuilder sb = convertSeparatedModulePathToPlatformSeparatedModulePath( pluginModulePath );
- jlinkArgs.add( sb.toString().replace( "\\", "\\\\" ) );
+ if (pluginModulePath != null) {
+ jlinkArgs.add("--plugin-module-path");
+ StringBuilder sb = convertSeparatedModulePathToPlatformSeparatedModulePath(pluginModulePath);
+ jlinkArgs.add(sb.toString().replace("\\", "\\\\"));
}
- if ( buildDirectory != null )
- {
- jlinkArgs.add( "--output" );
- jlinkArgs.add( outputDirectoryImage.getAbsolutePath() );
+ if (buildDirectory != null) {
+ jlinkArgs.add("--output");
+ jlinkArgs.add(outputDirectoryImage.getAbsolutePath());
}
- if ( verbose )
- {
- jlinkArgs.add( "--verbose" );
+ if (verbose) {
+ jlinkArgs.add("--verbose");
}
- return Collections.unmodifiableList( jlinkArgs );
+ return Collections.unmodifiableList(jlinkArgs);
}
- private boolean hasIncludeLocales()
- {
+ private boolean hasIncludeLocales() {
return includeLocales != null && !includeLocales.isEmpty();
}
- private boolean hasSuggestProviders()
- {
+ private boolean hasSuggestProviders() {
return suggestProviders != null && !suggestProviders.isEmpty();
}
- private boolean hasLimitModules()
- {
+ private boolean hasLimitModules() {
return limitModules != null && !limitModules.isEmpty();
}
/**
* {@inheritDoc}
*/
- protected String getClassifier()
- {
+ protected String getClassifier() {
return classifier;
}
-
}
diff --git a/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java b/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java
index 1aef05a..fc82183 100644
--- a/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java
@@ -1,3 +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.
+ */
package org.apache.maven.plugins.jlink;
/*
@@ -19,10 +37,6 @@
* under the License.
*/
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
@@ -33,91 +47,83 @@
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
/**
* @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
*/
-public class AbstractJLinkMojoTest
-{
+public class AbstractJLinkMojoTest {
private AbstractJLinkMojo mojoMock;
@BeforeEach
- public void before()
- {
- this.mojoMock = mock( AbstractJLinkMojo.class, Mockito.CALLS_REAL_METHODS );
- when( mojoMock.getLog() ).thenReturn( mock( Log.class ) );
+ public void before() {
+ this.mojoMock = mock(AbstractJLinkMojo.class, Mockito.CALLS_REAL_METHODS);
+ when(mojoMock.getLog()).thenReturn(mock(Log.class));
}
@Test
- @DisplayName( "convert should return single characters" )
- public void convertShouldReturnSingleCharacter()
- {
- StringBuilder result = mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath( "x" );
- assertThat( result ).isNotEmpty().hasToString( "x" );
+ @DisplayName("convert should return single characters")
+ public void convertShouldReturnSingleCharacter() {
+ StringBuilder result = mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath("x");
+ assertThat(result).isNotEmpty().hasToString("x");
}
@Test
- @DisplayName( "convert should two characters separated by path separator" )
- public void convertShouldReturnTwoCharactersSeparatedByPathSeparator()
- {
- StringBuilder result = mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath( "x;a" );
- assertThat( result ).hasToString( "x" + File.pathSeparatorChar + "a" );
+ @DisplayName("convert should two characters separated by path separator")
+ public void convertShouldReturnTwoCharactersSeparatedByPathSeparator() {
+ StringBuilder result = mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath("x;a");
+ assertThat(result).hasToString("x" + File.pathSeparatorChar + "a");
}
@Test
- @DisplayName( "convert using differential delimiter should return two characters separated by path separator" )
- public void convertUsingDifferentDelimiterShouldReturnTwoCharactersSeparatedByPathSeparator()
- {
- StringBuilder result = mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath( "x:a" );
- assertThat( result ).hasToString( "x" + File.pathSeparatorChar + "a" );
+ @DisplayName("convert using differential delimiter should return two characters separated by path separator")
+ public void convertUsingDifferentDelimiterShouldReturnTwoCharactersSeparatedByPathSeparator() {
+ StringBuilder result = mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath("x:a");
+ assertThat(result).hasToString("x" + File.pathSeparatorChar + "a");
}
@Test
- @DisplayName( "convertSeparatedModulePathToPlatformSeparatedModulePath() "
- + "should return two characters separated by path separator" )
- public void convertUsingMultipleDelimitersShouldReturnTwoCharactersSeparatedByPathSeparator()
- {
- StringBuilder result = mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath( "x:a::" );
- assertThat( result ).hasToString( "x" + File.pathSeparatorChar + "a" );
+ @DisplayName("convertSeparatedModulePathToPlatformSeparatedModulePath() "
+ + "should return two characters separated by path separator")
+ public void convertUsingMultipleDelimitersShouldReturnTwoCharactersSeparatedByPathSeparator() {
+ StringBuilder result = mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath("x:a::");
+ assertThat(result).hasToString("x" + File.pathSeparatorChar + "a");
}
@Test
- @DisplayName( "getPlatformDependSeparateList() should return a single character" )
- public void getPlatformDependSeparateListShouldReturnASingleCharacter()
- {
- String result = mojoMock.getPlatformDependSeparateList( Collections.singletonList( "A" ) );
- assertThat( result ).isEqualTo( "A" );
+ @DisplayName("getPlatformDependSeparateList() should return a single character")
+ public void getPlatformDependSeparateListShouldReturnASingleCharacter() {
+ String result = mojoMock.getPlatformDependSeparateList(Collections.singletonList("A"));
+ assertThat(result).isEqualTo("A");
}
@Test
- @DisplayName( "getPlatformDependSeparateList() should return two characters separated" )
- public void getPlatformDependSeparateListShouldReturnTwoCharactersSeparated()
- {
- String result = mojoMock.getPlatformDependSeparateList( Arrays.asList( "A", "B" ) );
- assertThat( result ).isEqualTo( "A" + File.pathSeparatorChar + "B" );
+ @DisplayName("getPlatformDependSeparateList() should return two characters separated")
+ public void getPlatformDependSeparateListShouldReturnTwoCharactersSeparated() {
+ String result = mojoMock.getPlatformDependSeparateList(Arrays.asList("A", "B"));
+ assertThat(result).isEqualTo("A" + File.pathSeparatorChar + "B");
}
@Test
- @DisplayName( "getPlatformDependSeparateList() should return three characters separated" )
- public void getPlatformDependSeparateListShouldReturnThreeCharactersSeparated()
- {
- String result = mojoMock.getPlatformDependSeparateList( Arrays.asList( "A", "B", "C" ) );
- assertThat( result ).isEqualTo( "A" + File.pathSeparatorChar + "B" + File.pathSeparatorChar + "C" );
+ @DisplayName("getPlatformDependSeparateList() should return three characters separated")
+ public void getPlatformDependSeparateListShouldReturnThreeCharactersSeparated() {
+ String result = mojoMock.getPlatformDependSeparateList(Arrays.asList("A", "B", "C"));
+ assertThat(result).isEqualTo("A" + File.pathSeparatorChar + "B" + File.pathSeparatorChar + "C");
}
@Test
- @DisplayName( "getCommaSeparatedList() should return a single character" )
- public void getCommaSeparatedListShouldReturnASingleCharacter()
- {
- String result = mojoMock.getCommaSeparatedList( Collections.singletonList( "A" ) );
- assertThat( result ).isEqualTo( "A" );
+ @DisplayName("getCommaSeparatedList() should return a single character")
+ public void getCommaSeparatedListShouldReturnASingleCharacter() {
+ String result = mojoMock.getCommaSeparatedList(Collections.singletonList("A"));
+ assertThat(result).isEqualTo("A");
}
@Test
- @DisplayName( "getCommaSeparatedList() should return two characters separated by comma" )
- public void getCommaSeparatedListShouldReturnTwoCharactersSeparatedByComma()
- {
- String result = mojoMock.getCommaSeparatedList( Arrays.asList( "A", "B" ) );
- assertThat( result ).isEqualTo( "A,B" );
+ @DisplayName("getCommaSeparatedList() should return two characters separated by comma")
+ public void getCommaSeparatedListShouldReturnTwoCharactersSeparatedByComma() {
+ String result = mojoMock.getCommaSeparatedList(Arrays.asList("A", "B"));
+ assertThat(result).isEqualTo("A,B");
}
-
}