You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2019/03/23 20:04:57 UTC
[maven-jlink-plugin] 01/01: Cleaned up code.
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch CODE_IMPROVEMENTS
in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git
commit a4df80a4b5911e40ac32d4cb4c2570b53714bad3
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Feb 10 19:08:46 2019 +0100
Cleaned up code.
---
.../org/apache/maven/plugins/jlink/JLinkMojo.java | 21 +++++++++++----------
.../maven/plugins/jlink/AbstractJLinkMojoTest.java | 21 ---------------------
2 files changed, 11 insertions(+), 31 deletions(-)
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 137c6b8..83459ee 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
@@ -368,7 +368,8 @@ public class JLinkMojo
for ( Map.Entry<File, JavaModuleDescriptor> entry : resolvePathsResult.getPathElements().entrySet() )
{
- if ( entry.getValue() == null )
+ JavaModuleDescriptor value = entry.getValue();
+ if ( value == null )
{
String message = "The given dependency " + entry.getKey()
+ " does not have a module-info.java file. So it can't be linked.";
@@ -377,13 +378,12 @@ public class JLinkMojo
}
// Don't warn for automatic modules, let the jlink tool do that
- getLog().debug( " module: " + entry.getValue().name() + " automatic: "
- + entry.getValue().isAutomatic() );
- if ( modulepathElements.containsKey( entry.getValue().name() ) )
+ getLog().debug(" module: " + value.name() + " automatic: " + value.isAutomatic());
+ if ( modulepathElements.containsKey( value.name() ) )
{
- getLog().warn( "The module name " + entry.getValue().name() + " does already exists." );
+ getLog().warn( "The module name " + value.name() + " does already exists." );
}
- modulepathElements.put( entry.getValue().name(), entry.getKey() );
+ modulepathElements.put( value.name(), entry.getKey() );
}
// This part is for the module in target/classes ? (Hacky..)
@@ -397,18 +397,19 @@ public class JLinkMojo
ResolvePathsResult<File> resolvePaths = locationManager.resolvePaths( singleModuls );
for ( Entry<File, JavaModuleDescriptor> entry : resolvePaths.getPathElements().entrySet() )
{
- if ( entry.getValue() == null )
+ JavaModuleDescriptor value = entry.getValue();
+ if ( value == 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 );
}
- if ( modulepathElements.containsKey( entry.getValue().name() ) )
+ if ( modulepathElements.containsKey( value.name() ) )
{
- getLog().warn( "The module name " + entry.getValue().name() + " does already exists." );
+ getLog().warn( "The module name " + value.name() + " does already exists." );
}
- modulepathElements.put( entry.getValue().name(), entry.getKey() );
+ modulepathElements.put( value.name(), entry.getKey() );
}
}
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 85dd34c..bcabd52 100644
--- a/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java
@@ -109,25 +109,4 @@ public class AbstractJLinkMojoTest
assertThat( result ).isEqualTo( "A,B" );
}
-// @Test
-// public void xxx()
-// throws MojoExecutionException, IOException, CommandLineException
-// {
-// Process p = mock( Process.class );
-//
-// String b = "Error occured";
-// byte[] bytes = b.getBytes();
-// ByteArrayOutputStream baos = new ByteArrayOutputStream();
-// baos.write( bytes );
-//
-// when (p.getOutputStream()).thenReturn( baos );
-//
-// Commandline cmd = mock( Commandline.class );
-// when (cmd.execute()).thenReturn( p );
-//
-// File outputDirectory = mock( File.class );
-//
-// mojoMock.executeCommand( cmd, outputDirectory );
-//
-// }
}