Permalink
Browse files

[GSCOLLECT-783] Simplify build configuration for code generation.

git-svn-id: svn+ssh://gscollections.svn.services.gs.com/svnroot/gscollections-svn/trunk@126 d5c9223b-1aff-41ac-aadd-f810b4a99ac4
  • Loading branch information...
1 parent 1dff4c5 commit 942b9fae50d575066707874602b21174ffa83371 Bhavana Hindupur committed Nov 26, 2012
Showing with 188 additions and 282 deletions.
  1. +1 −114 collections-api/pom.xml
  2. +1 −1 collections-parent.iml
  3. +1 −28 collections/pom.xml
  4. +6 −10 ...erator-ant/src/main/java/com/gs/collections/codegenerator/ant/GsCollectionsCodeGeneratorTask.java
  5. +5 −33 ...ode-generator-maven-plugin/src/main/java/com/gs/collections/codegenerator/maven/GenerateMojo.java
  6. +37 −64 ...ons-code-generator/src/main/java/com/gs/collections/codegenerator/GsCollectionsCodeGenerator.java
  7. +104 −0 gs-collections-code-generator/src/main/java/com/gs/collections/codegenerator/tools/FileUtils.java
  8. +2 −0 gs-collections-code-generator/src/main/resources/api/block/function/primitiveFunction.stg
  9. +2 −0 ...tions-code-generator/src/main/resources/api/block/function/primitiveObjectToPrimitiveFunction.stg
  10. +2 −0 gs-collections-code-generator/src/main/resources/api/block/function/primitiveToObjectFunction.stg
  11. +2 −0 gs-collections-code-generator/src/main/resources/api/block/predicate/primitivePredicate.stg
  12. +2 −0 gs-collections-code-generator/src/main/resources/api/block/procedure/primitiveProcedure.stg
  13. +2 −0 gs-collections-code-generator/src/main/resources/api/collection/mutablePrimitiveCollection.stg
  14. +2 −0 gs-collections-code-generator/src/main/resources/api/iterator/primitiveIterator.stg
  15. +2 −0 gs-collections-code-generator/src/main/resources/api/list/mutablePrimitiveList.stg
  16. +2 −0 gs-collections-code-generator/src/main/resources/api/list/primitiveList.stg
  17. +2 −0 gs-collections-code-generator/src/main/resources/api/primitiveIterable.stg
  18. 0 ...ections-code-generator/src/main/resources/{api → impl}/block/factory/primitiveEqualsWithDelta.stg
  19. +2 −0 gs-collections-code-generator/src/main/resources/{api → impl}/block/factory/primitivePredicates.stg
  20. +2 −0 gs-collections-code-generator/src/main/resources/{ → impl}/lazy/primitiveSelectIterable.stg
  21. +2 −0 gs-collections-code-generator/src/main/resources/{ → impl}/list/mutable/primitiveArrayList.stg
  22. +2 −0 ...lections-code-generator/src/main/resources/{api → test}/block/factory/primitivePredicatesTest.stg
  23. +2 −0 gs-collections-code-generator/src/main/resources/{ → test}/lazy/primitiveSelectIterableTest.stg
  24. +2 −0 gs-collections-code-generator/src/main/resources/{ → test}/list/mutable/primitiveArrayListTest.stg
  25. +1 −32 unit-tests/pom.xml
@@ -104,125 +104,12 @@
<version>2.1.0-SNAPSHOT</version>
<executions>
<execution>
- <id>iterable</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api</targetPath>
- <templateFileName>api/primitiveIterable.stg</templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>iterator</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api/iterator</targetPath>
- <templateFileName>api/iterator/primitiveIterator.stg</templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>procedure</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api/block/procedure/primitive
- </targetPath>
- <templateFileName>api/block/procedure/primitiveProcedure.stg</templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>predicate</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api/block/predicate/primitive
- </targetPath>
- <templateFileName>api/block/predicate/primitivePredicate.stg</templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>function</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api/block/function/primitive
- </targetPath>
- <templateFileName>api/block/function/primitiveFunction.stg</templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>toObjectFunction</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api/block/function/primitive
- </targetPath>
- <templateFileName>api/block/function/primitiveToObjectFunction.stg</templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>objectToPrimitiveFunction</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api/block/function/primitive
- </targetPath>
- <templateFileName>api/block/function/primitiveObjectToPrimitiveFunction.stg
- </templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>primitiveList</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api/list/primitive
- </targetPath>
- <templateFileName>api/list/primitiveList.stg
- </templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>mutablePrimitiveList</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api/list/primitive
- </targetPath>
- <templateFileName>api/list/mutablePrimitiveList.stg
- </templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>mutablePrimitiveCollection</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/api/collection/primitive
- </targetPath>
- <templateFileName>api/collection/mutablePrimitiveCollection.stg
- </templateFileName>
+ <templateDirectory>..\gs-collections-code-generator\src\main\resources\api</templateDirectory>
</configuration>
</execution>
</executions>
@@ -4,7 +4,7 @@
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/com" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
View
@@ -110,39 +110,12 @@
<version>2.1.0-SNAPSHOT</version>
<executions>
<execution>
- <id>list</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/impl/list/mutable/primitive
- </targetPath>
- <templateFileName>list/mutable/primitiveArrayList.stg</templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>function</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/impl/block/factory/primitive
- </targetPath>
- <templateFileName>api/block/factory/primitivePredicates.stg</templateFileName>
- </configuration>
- </execution>
- <execution>
- <id>select</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <targetPath>target/generated-sources/java/com/gs/collections/impl/lazy/primitive
- </targetPath>
- <templateFileName>lazy/primitiveSelectIterable.stg</templateFileName>
+ <templateDirectory>..\gs-collections-code-generator\src\main\resources\impl</templateDirectory>
</configuration>
</execution>
</executions>
@@ -23,24 +23,20 @@
public class GsCollectionsCodeGeneratorTask extends Task
{
- private String targetPath;
- private String templateFileName;
+ private File templateDirectory;
@Override
public void execute()
{
+ this.log("Scanning all template files from " + this.templateDirectory.getPath());
+
GsCollectionsCodeGenerator gsCollectionsCodeGenerator =
- new GsCollectionsCodeGenerator(new File(this.targetPath), this.templateFileName);
+ new GsCollectionsCodeGenerator(this.templateDirectory);
gsCollectionsCodeGenerator.generate();
}
- public void setTargetPath(String targetPath)
- {
- this.targetPath = targetPath;
- }
-
- public void setTemplateFileName(String templateFileName)
+ public void setTemplateDirectory(File templateDirectory)
{
- this.templateFileName = templateFileName;
+ this.templateDirectory = templateDirectory;
}
}
@@ -35,13 +35,7 @@
* @parameter expression="${project.build.directory}/generated-sources"
* @required
*/
- private File targetPath;
-
- /**
- * @parameter
- * @required
- */
- private String templateFileName;
+ private File templateDirectory;
/**
* The Maven project to act upon.
@@ -51,37 +45,15 @@
*/
private MavenProject project;
- /**
- * Whether the generated source should get added to the compile or test classpath.
- *
- * @parameter default-value="false"
- * @required
- */
- private boolean test;
-
public void execute() throws MojoExecutionException, MojoFailureException
{
- if (!this.targetPath.exists())
- {
- boolean mkdirs = this.targetPath.mkdirs();
- if (!mkdirs)
- {
- throw new MojoFailureException("Could not create directory " + this.targetPath);
- }
- }
- this.getLog().info("Writing generated code to " + this.targetPath);
+ this.getLog().info("Scanning all template files from " + this.templateDirectory.getPath());
GsCollectionsCodeGenerator gsCollectionsCodeGenerator =
- new GsCollectionsCodeGenerator(this.targetPath, this.templateFileName);
+ new GsCollectionsCodeGenerator(this.templateDirectory);
gsCollectionsCodeGenerator.generate();
- if (this.test)
- {
- this.project.addTestCompileSourceRoot(this.targetPath.getAbsolutePath());
- }
- else
- {
- this.project.addCompileSourceRoot(this.targetPath.getAbsolutePath());
- }
+ this.project.addCompileSourceRoot("target/generated-sources/java");
+ this.project.addTestCompileSourceRoot("target/generated-test-sources/java");
}
}
Oops, something went wrong.

0 comments on commit 942b9fa

Please sign in to comment.