diff --git a/pom.xml b/pom.xml
index 6c543bb..c43f275 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,10 +40,14 @@
false
false
false
+ 5.1.0
+ 3.15.0
+ 0.8.15
rwx
+ rwx-processor
rwx-test
@@ -62,9 +66,14 @@
2.6-SNAPSHOT
- org.codehaus.groovy
+ org.commonjava.rwx
+ rwx-processor
+ 2.6-SNAPSHOT
+
+
+ org.apache.groovy
groovy-templates
- 3.0.17
+ ${version.groovy-templates}
@@ -105,19 +114,19 @@
hamcrest-core
-
+
+ org.apache.maven.plugins
maven-javadoc-plugin
- ${version.plugin.javadoc}
false
-Xdoclint:none
-Xdoclint:none
none
- 8
+ ${javaVersion}
diff --git a/rwx-processor/pom.xml b/rwx-processor/pom.xml
new file mode 100644
index 0000000..ea99e15
--- /dev/null
+++ b/rwx-processor/pom.xml
@@ -0,0 +1,43 @@
+
+
+
+ 4.0.0
+
+
+ org.commonjava.rwx
+ rwx-parent
+ 2.6-SNAPSHOT
+
+
+ rwx-processor
+
+ RWX::Processor
+
+
+
+ org.commonjava.rwx
+ rwx
+
+
+ org.apache.groovy
+ groovy-templates
+
+
+
+
diff --git a/rwx/src/main/java/org/commonjava/rwx/core/AnnoProcessor.java b/rwx-processor/src/main/java/org/commonjava/rwx/processor/AnnoProcessor.java
similarity index 94%
rename from rwx/src/main/java/org/commonjava/rwx/core/AnnoProcessor.java
rename to rwx-processor/src/main/java/org/commonjava/rwx/processor/AnnoProcessor.java
index c6920f1..6a0c9a4 100644
--- a/rwx/src/main/java/org/commonjava/rwx/core/AnnoProcessor.java
+++ b/rwx-processor/src/main/java/org/commonjava/rwx/processor/AnnoProcessor.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (C) 2010 Red Hat, Inc. (http://github.com/Commonjava/commonjava)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.commonjava.rwx.core;
+package org.commonjava.rwx.processor;
import groovy.lang.Writable;
import groovy.text.GStringTemplateEngine;
@@ -26,7 +26,6 @@
import org.commonjava.rwx.anno.Request;
import org.commonjava.rwx.anno.Response;
import org.commonjava.rwx.anno.StructPart;
-import org.commonjava.rwx.util.ProcessorUtils;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
@@ -41,24 +40,26 @@
import javax.lang.model.util.Elements;
import javax.tools.Diagnostic;
import javax.tools.FileObject;
-import javax.tools.StandardLocation;
import java.io.IOException;
+import java.net.URL;
import java.io.Writer;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
-import static org.commonjava.rwx.util.ProcessorUtils.GENERATED;
-import static org.commonjava.rwx.util.ProcessorUtils.getElementClassByType;
-import static org.commonjava.rwx.util.ProcessorUtils.getList;
-import static org.commonjava.rwx.util.ProcessorUtils.getMethodName;
-import static org.commonjava.rwx.util.ProcessorUtils.getPackageAndClassName;
-import static org.commonjava.rwx.util.ProcessorUtils.getRegistryClassName;
-import static org.commonjava.rwx.util.ProcessorUtils.union;
+import static org.commonjava.rwx.processor.ProcessorUtils.GENERATED;
+import static org.commonjava.rwx.processor.ProcessorUtils.getElementClassByType;
+import static org.commonjava.rwx.processor.ProcessorUtils.getList;
+import static org.commonjava.rwx.processor.ProcessorUtils.getMethodName;
+import static org.commonjava.rwx.processor.ProcessorUtils.getPackageAndClassName;
+import static org.commonjava.rwx.processor.ProcessorUtils.getRegistryClassName;
+import static org.commonjava.rwx.processor.ProcessorUtils.union;
/**
* Created by ruhan on 7/24/17.
@@ -128,8 +129,11 @@ private void writeRegistryFile( Set extends Element> classes, RoundEnvironment
List imports = new ArrayList<>();
List simpleClassNames = new ArrayList<>();
+ List sortedClasses = new ArrayList<>( classes );
+ sortedClasses.sort( Comparator.comparing( e -> ( (TypeElement) e ).getQualifiedName().toString() ) );
+
Set packageNames = new HashSet<>();
- for ( Element elem : classes )
+ for ( Element elem : sortedClasses )
{
String qName = ( (TypeElement) elem ).getQualifiedName().toString();
imports.add( qName );
@@ -437,19 +441,15 @@ else if ( sPart != null || aPart != null )
private Template getTemplate( String templateName )
{
- Template template;
try
{
- final FileObject resource = processingEnv.getFiler()
- .getResource( StandardLocation.CLASS_PATH, TEMPLATE_PKG,
- templateName );
- template = engine.createTemplate( resource.toUri().toURL() );
+ final URL resource = AnnoProcessor.class.getResource( "/" + TEMPLATE_PKG + "/" + templateName );
+ return engine.createTemplate( Objects.requireNonNull( resource ) );
}
catch ( Exception e )
{
throw new IllegalStateException( "Cannot load template: " + TEMPLATE_PKG + "/" + templateName, e );
}
- return template;
}
private void generateOutput( Template template, Map templateParams, String className )
diff --git a/rwx/src/main/java/org/commonjava/rwx/util/ProcessorUtils.java b/rwx-processor/src/main/java/org/commonjava/rwx/processor/ProcessorUtils.java
similarity index 97%
rename from rwx/src/main/java/org/commonjava/rwx/util/ProcessorUtils.java
rename to rwx-processor/src/main/java/org/commonjava/rwx/processor/ProcessorUtils.java
index 621d4fb..2f8c561 100644
--- a/rwx/src/main/java/org/commonjava/rwx/util/ProcessorUtils.java
+++ b/rwx-processor/src/main/java/org/commonjava/rwx/processor/ProcessorUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (C) 2010 Red Hat, Inc. (http://github.com/Commonjava/commonjava)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.commonjava.rwx.util;
-
-import org.apache.commons.lang3.StringUtils;
+package org.commonjava.rwx.processor;
import javax.lang.model.element.Element;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -43,9 +42,10 @@ private static void debug( String message )
public static final String GENERATED = "generated";
+ @SafeVarargs
public static Set extends E> union( Set extends E>... sets )
{
- Set es = new HashSet<>();
+ Set es = new LinkedHashSet<>();
for ( Set extends E> s : sets )
{
es.addAll( s );
@@ -142,7 +142,7 @@ public static String getRegistryClassName( Set packageNames )
}
commonPkgName = sb.toString();
- if ( StringUtils.isBlank( commonPkgName ) )
+ if ( commonPkgName.trim().isEmpty() )
{
return "generated._Registry"; // default
}
diff --git a/rwx/src/main/resources/groovy/Parser.groovy b/rwx-processor/src/main/resources/groovy/Parser.groovy
similarity index 100%
rename from rwx/src/main/resources/groovy/Parser.groovy
rename to rwx-processor/src/main/resources/groovy/Parser.groovy
diff --git a/rwx/src/main/resources/groovy/Registry.groovy b/rwx-processor/src/main/resources/groovy/Registry.groovy
similarity index 100%
rename from rwx/src/main/resources/groovy/Registry.groovy
rename to rwx-processor/src/main/resources/groovy/Registry.groovy
diff --git a/rwx/src/main/resources/groovy/Renderer.groovy b/rwx-processor/src/main/resources/groovy/Renderer.groovy
similarity index 100%
rename from rwx/src/main/resources/groovy/Renderer.groovy
rename to rwx-processor/src/main/resources/groovy/Renderer.groovy
diff --git a/rwx/src/test/java/org/commonjava/rwx/core/util/ProcessorUtilsTest.java b/rwx-processor/src/test/java/org/commonjava/rwx/processor/ProcessorUtilsTest.java
similarity index 90%
rename from rwx/src/test/java/org/commonjava/rwx/core/util/ProcessorUtilsTest.java
rename to rwx-processor/src/test/java/org/commonjava/rwx/processor/ProcessorUtilsTest.java
index 19640c1..2cbf359 100644
--- a/rwx/src/test/java/org/commonjava/rwx/core/util/ProcessorUtilsTest.java
+++ b/rwx-processor/src/test/java/org/commonjava/rwx/processor/ProcessorUtilsTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (C) 2010 Red Hat, Inc. (http://github.com/Commonjava/commonjava)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.commonjava.rwx.core.util;
+package org.commonjava.rwx.processor;
-import static org.commonjava.rwx.util.ProcessorUtils.getElementClassByType;
-import static org.commonjava.rwx.util.ProcessorUtils.getRegistryClassName;
+import static org.commonjava.rwx.processor.ProcessorUtils.getElementClassByType;
+import static org.commonjava.rwx.processor.ProcessorUtils.getRegistryClassName;
import org.junit.Test;
import java.util.Collections;
diff --git a/rwx-test/pom.xml b/rwx-test/pom.xml
index d685bb1..ea722ef 100644
--- a/rwx-test/pom.xml
+++ b/rwx-test/pom.xml
@@ -45,9 +45,15 @@
${project.build.directory}/generated-sources
- org.commonjava.rwx.core.AnnoProcessor
+ org.commonjava.rwx.processor.AnnoProcessor
+
+
+ org.commonjava.rwx
+ rwx-processor
+
+
diff --git a/rwx/pom.xml b/rwx/pom.xml
index e75cf06..0ca3fac 100644
--- a/rwx/pom.xml
+++ b/rwx/pom.xml
@@ -34,10 +34,6 @@
org.apache.commons
commons-lang3
-
- org.codehaus.groovy
- groovy-templates
-
commons-io
commons-io