-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94f1fe0
commit 30bbb05
Showing
9 changed files
with
805 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
<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.1.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>1.0-SNAPSHOT</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> |
15 changes: 15 additions & 0 deletions
15
test/src/main/java/org/bsc/maven/plugin/processor/test/ParameterDocumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ""; | ||
|
||
|
||
} |
18 changes: 18 additions & 0 deletions
18
test/src/main/java/org/bsc/maven/plugin/processor/test/ServiceDocumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ""; | ||
} |
149 changes: 149 additions & 0 deletions
149
test/src/main/java/org/bsc/maven/plugin/processor/test/TESTWikiProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package org.bsc.maven.plugin.processor.test; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
|
||
import javax.annotation.processing.*; | ||
import javax.lang.model.SourceVersion; | ||
import javax.lang.model.element.Element; | ||
import javax.lang.model.element.ElementKind; | ||
import javax.lang.model.element.TypeElement; | ||
import javax.tools.Diagnostic.Kind; | ||
import javax.tools.FileObject; | ||
import javax.tools.StandardLocation; | ||
|
||
/** | ||
* | ||
* @author softphone | ||
* | ||
* | ||
*/ | ||
@SupportedSourceVersion(SourceVersion.RELEASE_7) | ||
@SupportedAnnotationTypes( "*" ) | ||
//@SupportedOptions( {"subfolder", "filepath", "templateUri"}) | ||
//@SupportedAnnotationTypes( {"javax.ws.rs.GET", "javax.ws.rs.PUT", "javax.ws.rs.POST", "javax.ws.rs.DELETE"}) | ||
public class TESTWikiProcessor extends AbstractProcessor { | ||
|
||
protected void info( String msg ) { | ||
processingEnv.getMessager().printMessage(Kind.NOTE, msg ); | ||
} | ||
|
||
protected void warn( String msg ) { | ||
//logger.warning(msg); | ||
processingEnv.getMessager().printMessage(Kind.WARNING, msg ); | ||
} | ||
|
||
protected void warn( String msg, Throwable t ) { | ||
//logger.log(Level.WARNING, msg, t ); | ||
processingEnv.getMessager().printMessage(Kind.WARNING, msg ); | ||
t.printStackTrace(System.err); | ||
} | ||
|
||
protected void error( String msg ) { | ||
//logger.severe(msg); | ||
processingEnv.getMessager().printMessage(Kind.ERROR, msg ); | ||
} | ||
|
||
protected void error( String msg, Throwable t ) { | ||
//logger.log(Level.SEVERE, msg, t ); | ||
processingEnv.getMessager().printMessage(Kind.ERROR, msg ); | ||
t.printStackTrace(System.err); | ||
} | ||
|
||
/** | ||
* | ||
* @param filer | ||
* @return | ||
* @throws IOException | ||
*/ | ||
protected FileObject getResourceFormClassPath(Filer filer, final String resource, final String packageName) throws IOException { | ||
FileObject f = filer.getResource(StandardLocation.CLASS_PATH, packageName, resource); | ||
|
||
//java.io.Reader r = f.openReader(true); // ignoreEncodingErrors | ||
java.io.InputStream is = f.openInputStream(); | ||
|
||
if( is==null ) { | ||
warn( String.format("resource [%s] not found!", resource) ); | ||
return null; | ||
} | ||
|
||
return f; | ||
} | ||
|
||
|
||
/** | ||
* | ||
* @param subfolder subfolder (e.g. confluence) | ||
* @param filePath relative path (e.g. children/file.wiki) | ||
* @return | ||
* @throws IOException | ||
*/ | ||
protected FileObject getOutputFile( Filer filer, String subfolder, String filePath ) throws IOException { | ||
|
||
Element e = null; | ||
FileObject res = | ||
filer.createResource(StandardLocation.SOURCE_OUTPUT, | ||
subfolder, | ||
filePath, | ||
e); | ||
|
||
return res; | ||
} | ||
|
||
/** | ||
* | ||
* @param e | ||
* @return | ||
* @throws ClassNotFoundException | ||
*/ | ||
protected Class<?> getClassFromElement( Element e ) throws ClassNotFoundException { | ||
if( null==e ) throw new IllegalArgumentException("e is null!"); | ||
if( ElementKind.CLASS!=e.getKind() ) throw new IllegalArgumentException( String.format("element [%s] is not a class!", e)); | ||
|
||
TypeElement te = (TypeElement) e; | ||
|
||
info( String.format("loading class [%s]", te.getQualifiedName().toString())); | ||
|
||
return Class.forName(te.getQualifiedName().toString()); | ||
|
||
} | ||
|
||
@Override | ||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { | ||
if (roundEnv.processingOver()) return false; | ||
|
||
System.out.println( "====> PROCESSOR RUN"); | ||
|
||
java.util.Map<String,String> optionMap = processingEnv.getOptions(); | ||
|
||
|
||
for( TypeElement e : annotations ) { | ||
|
||
for (Element re : roundEnv.getElementsAnnotatedWith(e)) { | ||
|
||
if( re.getKind()==ElementKind.METHOD) { | ||
|
||
info( String.format("[%s], Element [%s] is [%s] ", re.getEnclosingElement(), re.getKind(), re.getSimpleName())); | ||
|
||
} | ||
} | ||
} | ||
|
||
//final Filer filer = processingEnv.getFiler(); | ||
|
||
//FileObject res = getOutputFile(filer, subfolder, filePath); | ||
|
||
//java.io.Writer w = res.openWriter(); | ||
|
||
//w.close(); | ||
|
||
return true; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
{toc} | ||
|
||
h1. SERVICES | ||
\\ | ||
<!-- $BeginBlock services -->h2. ${service.name} | ||
|*Description:* | ${service.description} | | ||
| *Since:* | ${service.since} | | ||
| *Notes:* | ${service.notes} | | ||
| *Security:* | ${service.security} | | ||
| *Usage:* | ${service.verb} ${service.path} | | ||
| *Consumes* | ${service.consumes} | | ||
| *Produces:* | ${service.produces} | | ||
| *Parameters* | {quote} | ||
|| name || default || description || | ||
<!-- $BeginBlock parameters -->| ${param.name} | ${param.default} | ${param.description} | | ||
<!-- $EndBlock parameters --> | ||
{quote}| | ||
\\ | ||
---- | ||
<!-- $EndBlock services --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<actions> | ||
<action> | ||
<actionName>CUSTOM-deploy</actionName> | ||
<displayName>deploy</displayName> | ||
<goals> | ||
<goal>deploy</goal> | ||
</goals> | ||
<activatedProfiles> | ||
<activatedProfile>sonatype</activatedProfile> | ||
</activatedProfiles> | ||
</action> | ||
</actions> |
Oops, something went wrong.