Skip to content

Commit

Permalink
Fix the module name is not extracted when the path to the module cont…
Browse files Browse the repository at this point in the history
…ains spaces (#6)

When `MainClassModuleNameExtractor` is run in external JVM a file with
arguments for the JVM is created. This file contains the paths to the
modules but if those paths contain spaces they are not properly escaped
and as a result `MainClassModuleNameExtractor` receives corrupted paths
as arguments.

Quote all paths in the file so spaces are handled properly.
  • Loading branch information
plamentotev authored and rfscholte committed Feb 5, 2018
1 parent 3305b3c commit 6f38b8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public <T> Map<T, String> extract( Map<T, Path> files )

for ( Path p : files.values() )
{
argsWriter.append( p.toAbsolutePath().toString() );
// make sure the path is surrounded with quotes in case there is space
argsWriter.append( '"' );
// make sure to escape Windows paths
argsWriter.append( p.toAbsolutePath().toString().replace( "\\", "\\\\" ) );
argsWriter.append( '"' );
argsWriter.newLine();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@ public void testJarUnsupported() throws Exception
assertEquals( null, name );
}

@Test
public void testJarWithSpacesInPath() throws Exception
{
String name = getExtractor().extract( Paths.get( "src/test/resources/jar with spaces in path/plexus-java-1.0.0-SNAPSHOT.jar" ) );
assertEquals( "org.codehaus.plexus.languages.java", name );
}

}
Binary file not shown.

0 comments on commit 6f38b8e

Please sign in to comment.