Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run the generator using gradle #261

Open
jw opened this issue Sep 15, 2016 · 3 comments
Open

How to run the generator using gradle #261

jw opened this issue Sep 15, 2016 · 3 comments
Labels

Comments

@jw
Copy link

jw commented Sep 15, 2016

Can we force the code generator to place the generated classes in a specific location?

@doanduyhai
Copy link
Owner

No, the Java Annotation Processing API restrict the location of generated classes to the $PROJECT_HOME/target folder.

But you can always define an extra step in the build process with Maven (or Gradle) to copy the generated source codes back to $PROJECT_HOME/src/main/java. Example:

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-source-files-to-classpath</id>
                        <!-- here the phase you need, read https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference -->
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/src/main/java</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/target/generated-classes/annotation</directory>
                                    <includes>
                                        <include>**/TestEntity*.java</include>
                                        <include>**/TestView*.java</include>
                                        <include>**/TestUDT*.java</include>
                                        <include>**/TestCodecRegistry*.java</include>
                                        <include>**/TestFunctionRegistry*.java</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

@jw
Copy link
Author

jw commented Oct 10, 2016

Found out it is easier to add this plugin. That way the autogenerated classes are placed in <project>/build/generated/source/apt/main/info/archinnov/achilles/generated. It is even possible to place the generated files somewhere else.

@doanduyhai
Copy link
Owner

Oh nice! I should upgrade my docs to have a section dedicated to Gradle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants