Skip to content

Commit

Permalink
Merge branch 'feature/issue#63' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Oct 7, 2016
2 parents f8c6e3d + 29deb57 commit 28a915b
Show file tree
Hide file tree
Showing 11 changed files with 849 additions and 4 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 @@ -441,14 +457,23 @@ private void executeWithExceptionsHandled() throws Exception
}


String compileClassPath = buildCompileClasspath();
final String compileClassPath = buildCompileClasspath();

String processor = buildProcessor();
final String processor = buildProcessor();

List<String> options = new ArrayList<String>(10);
final List<String> options = new ArrayList<String>(10);

options.add("-cp");
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
160 changes: 160 additions & 0 deletions test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<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>

<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin-test</artifactId>
<version>3.2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MAVEN PROCESSOR PLUGIN TEST- ${project.version}</name>
<description></description>

<properties>
<!--
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-->
</properties>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>

</dependencies>

<inceptionYear>2012</inceptionYear>


<build>


<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

<!--
===================================================================
PROCESSOR PLUGIN
===================================================================
-->

<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>${project.version}</version>
<dependencies>
<dependency>
<groupId>org.bsc</groupId>
<artifactId>jaxrs-wiki-processor</artifactId>
<version>2.2</version>
</dependency>

</dependencies>
<executions>

<execution>

<id>process-test</id>
<goals>
<goal>process-test</goal>
</goals>
<phase>process-test-classes</phase>
<configuration>
<outputDirectory>${basedir}/src/site</outputDirectory>

<additionalSourceDirectories>
<item>${user.home}/src</item>
<item>./src/main/java</item>
</additionalSourceDirectories>

<failOnError>false</failOnError>
<processors>
<!-- list of processors to use -->
<processor>org.bsc.maven.plugin.processor.test.TESTWikiProcessor</processor>
<processor>org.bsc.jaxrs.JAXRSWikiProcessor</processor>
</processors>

<options>
</options>
</configuration>


</execution>
<execution>

<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<outputDirectory>${basedir}/src/site</outputDirectory>

<additionalSourceDirectories>
<item>${basedir}/src/main/java</item>
<item>${user.home}/src</item>
</additionalSourceDirectories>

<failOnError>false</failOnError>
<processors>
<!-- list of processors to use -->
<processor>org.bsc.jaxrs.JAXRSWikiProcessor</processor>
</processors>

<options>
</options>
</configuration>


</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/src-generated/src</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/src-generated/test</source>
</sources>
</configuration>
</execution>

</executions>
</plugin>
</plugins>

</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.bsc.maven.plugin.processor.test;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.SOURCE)
@Target({ ElementType.PARAMETER})
public @interface ParameterDocumentation {

String value() default "";


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.bsc.maven.plugin.processor.test;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


@Retention(RetentionPolicy.SOURCE)
@Target({ ElementType.METHOD})
public @interface ServiceDocumentation {

public String since() default "";

public String value() default "";

public String note() default "";
}

0 comments on commit 28a915b

Please sign in to comment.