Skip to content

Commit

Permalink
get sourcepath from project.getCompileSourceRoot()
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Sep 28, 2016
1 parent 0b6bc2c commit 29deb57
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/main/java/org/bsc/function/Consumer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.bsc.function;

/**
*
* @author bsorrentino
* @param <T>
*/
public interface Consumer<T> {

void accept(T t);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.bsc.function.Consumer;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;

Expand Down Expand Up @@ -310,6 +311,21 @@ private String buildProcessor()

protected abstract java.util.Set<String> getClasspathElements( java.util.Set<String> result );

private String buildCompileSourcepath( Consumer<String> onSuccess) {

final java.util.List<String> roots = project.getCompileSourceRoots();

if( roots == null || roots.isEmpty() ) {
return null;
}

final String result = StringUtils.join(roots.iterator(), File.pathSeparator);

onSuccess.accept( result );

return result;
}

private String buildCompileClasspath()
{

Expand All @@ -331,7 +347,7 @@ private String buildCompileClasspath()

getClasspathElements(pathElements);

StringBuilder result = new StringBuilder();
final StringBuilder result = new StringBuilder();

for( String elem : pathElements ) {
result.append(elem).append(File.pathSeparator);
Expand Down Expand Up @@ -449,8 +465,15 @@ private void executeWithExceptionsHandled() throws Exception

options.add("-cp");
options.add(compileClassPath);
options.add("-sourcepath");
options.add(compileClassPath);

buildCompileSourcepath( new Consumer<String>() {
public void accept(String sourcepath) {

options.add("-sourcepath");
options.add(sourcepath);
}
});

options.add("-proc:only");

addCompilerArguments(options);
Expand Down

0 comments on commit 29deb57

Please sign in to comment.