Skip to content

Commit

Permalink
Merge pull request #17 from rhowe/tidyups
Browse files Browse the repository at this point in the history
Miscellaneous code cleanups
  • Loading branch information
olamy committed May 20, 2019
2 parents 62438bb + 3aab7d7 commit de5e97a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ private List<String> resolveProcessorPathEntries()

resolutionErrorHandler.throwErrors( request, resolutionResult );

List<String> elements = new ArrayList<String>( resolutionResult.getArtifacts().size() );
List<String> elements = new ArrayList<>( resolutionResult.getArtifacts().size() );

for ( Object resolved : resolutionResult.getArtifacts() )
{
Expand Down
25 changes: 8 additions & 17 deletions src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected void preparePaths( Set<File> sourceFiles )
.setMainModuleDescriptor( moduleDescriptorPath );

Toolchain toolchain = getToolchain();
if ( toolchain != null && toolchain instanceof DefaultJavaToolChain )
if ( toolchain instanceof DefaultJavaToolChain )
{
request.setJdkHome( new File( ( (DefaultJavaToolChain) toolchain ).getJavaHome() ) );
}
Expand All @@ -256,27 +256,22 @@ protected void preparePaths( Set<File> sourceFiles )
{
pathElements.put( entry.getKey().getPath(), entry.getValue() );
}


if ( compilerArgs == null )
{
compilerArgs = new ArrayList<>();
}

for ( File file : resolvePathsResult.getClasspathElements() )
{
classpathElements.add( file.getPath() );

if ( multiReleaseOutput )
{
if ( compilerArgs == null )
{
compilerArgs = new ArrayList<>();
}

if ( getOutputDirectory().toPath().startsWith( file.getPath() ) )
{
compilerArgs.add( "--patch-module" );

StringBuilder patchModuleValue = new StringBuilder( moduleDescriptor.name() )
.append( '=' )
.append( file.getPath() );

compilerArgs.add( patchModuleValue.toString() );
compilerArgs.add( String.format( "%s=%s", moduleDescriptor.name(), file.getPath() ) );
}
}
}
Expand All @@ -286,10 +281,6 @@ protected void preparePaths( Set<File> sourceFiles )
modulepathElements.add( file.getPath() );
}

if ( compilerArgs == null )
{
compilerArgs = new ArrayList<>();
}
compilerArgs.add( "--module-version" );
compilerArgs.add( getProject().getVersion() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ protected void preparePaths( Set<File> sourceFiles )
.setMainModuleDescriptor( mainModuleDescriptorClassFile.getAbsolutePath() );

Toolchain toolchain = getToolchain();
if ( toolchain != null && toolchain instanceof DefaultJavaToolChain )
if ( toolchain instanceof DefaultJavaToolChain )
{
request.setJdkHome( ( (DefaultJavaToolChain) toolchain ).getJavaHome() );
}
Expand Down Expand Up @@ -285,7 +285,7 @@ protected void preparePaths( Set<File> sourceFiles )
.setMainModuleDescriptor( testModuleDescriptorJavaFile.getAbsolutePath() );

Toolchain toolchain = getToolchain();
if ( toolchain != null && toolchain instanceof DefaultJavaToolChain )
if ( toolchain instanceof DefaultJavaToolChain )
{
request.setJdkHome( ( (DefaultJavaToolChain) toolchain ).getJavaHome() );
}
Expand Down Expand Up @@ -336,7 +336,7 @@ else if ( Double.valueOf( getTarget() ) < Double.valueOf( MODULE_INFO_TARGET ) )
{
if ( compilerArgs == null )
{
compilerArgs = new ArrayList<String>();
compilerArgs = new ArrayList<>();
}
compilerArgs.add( "--patch-module" );

Expand Down Expand Up @@ -380,7 +380,7 @@ else if ( Double.valueOf( getTarget() ) < Double.valueOf( MODULE_INFO_TARGET ) )
{
if ( compilerArgs == null )
{
compilerArgs = new ArrayList<String>();
compilerArgs = new ArrayList<>();
}
compilerArgs.add( "--patch-module" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ public void testCompilerIncludesExcludes()
CompilerMojo compileMojo =
getCompilerMojo( "target/test-classes/unit/compiler-includes-excludes-test/plugin-config.xml" );

Set<String> includes = new HashSet<String>();
Set<String> includes = new HashSet<>();
includes.add( "**/TestCompile4*.java" );
setVariableValueToObject( compileMojo, "includes", includes );

Set<String> excludes = new HashSet<String>();
Set<String> excludes = new HashSet<>();
excludes.add( "**/TestCompile2*.java" );
excludes.add( "**/TestCompile3*.java" );
setVariableValueToObject( compileMojo, "excludes", excludes );
Expand Down Expand Up @@ -275,11 +275,11 @@ public void testOneOutputFileForAllInput2()

setVariableValueToObject( compileMojo, "compilerManager", new CompilerManagerStub() );

Set<String> includes = new HashSet<String>();
Set<String> includes = new HashSet<>();
includes.add( "**/TestCompile4*.java" );
setVariableValueToObject( compileMojo, "includes", includes );

Set<String> excludes = new HashSet<String>();
Set<String> excludes = new HashSet<>();
excludes.add( "**/TestCompile2*.java" );
excludes.add( "**/TestCompile3*.java" );
setVariableValueToObject( compileMojo, "excludes", excludes );
Expand Down Expand Up @@ -414,7 +414,7 @@ private TestCompilerMojo getTestCompilerMojo( CompilerMojo compilerMojo, String
File testClassesDir = new File( buildDir, "test-classes" );
setVariableValueToObject( mojo, "outputDirectory", testClassesDir );

List<String> testClasspathList = new ArrayList<String>();
List<String> testClasspathList = new ArrayList<>();

Artifact junitArtifact = mock( Artifact.class );
ArtifactHandler handler = mock( ArtifactHandler.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/

import org.codehaus.plexus.compiler.manager.CompilerManager;
import org.codehaus.plexus.compiler.manager.NoSuchCompilerException;

/**
* @author Edwin Punzalan
Expand All @@ -41,7 +40,6 @@ public CompilerManagerStub( boolean shouldFail )
}

public org.codehaus.plexus.compiler.Compiler getCompiler( String compilerId )
throws NoSuchCompilerException
{
return new CompilerStub( shouldFail );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,21 @@ public CompilerOutputStyle getCompilerOutputStyle()
}

public String getInputFileEnding( CompilerConfiguration compilerConfiguration )
throws CompilerException
{
return "java";
}

public String getOutputFileEnding( CompilerConfiguration compilerConfiguration )
throws CompilerException
{
return "class";
}

public String getOutputFile( CompilerConfiguration compilerConfiguration )
throws CompilerException
{
return "output-file";
}

public boolean canUpdateTarget( CompilerConfiguration compilerConfiguration )
throws CompilerException
{
return false;
}
Expand Down Expand Up @@ -126,7 +122,6 @@ public CompilerResult performCompile( CompilerConfiguration compilerConfiguratio
}

public String[] createCommandLine( CompilerConfiguration compilerConfiguration )
throws CompilerException
{
return new String[0];
}
Expand Down

0 comments on commit de5e97a

Please sign in to comment.