-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Compiling Generated .java Into .class Files #92
Comments
Hi @pbtura let me investigate |
I spent some time experimenting with a test project to see if I could isolate the issue. I made two discoveries that might be helpful. First, the
to
I re-ran the build and the .class files for the generated source were created in the ${project.build.directory}/classes directory. ${project.build.directory}/generated-sources/annotations is the default output location when doing annotation processing via the maven-compiler-plugin. I wonder if there is some sort of conflict, even though the proc argument is set to none? |
Hi @pbtura thanks for help, I’ll focus on your findings |
Hi @pbtura in this branch I've performed a test to replicate your issue I haven't been able to replicate the error and in my test all seems work well. Take a look to the branch. Below a summary of plugin's configuration <plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<addOutputDirectoryToCompilationSources>true</addOutputDirectoryToCompilationSources>
<failOnError>false</failOnError>
<processors>
<processor>org.bsc.maven.plugin.processor.test.TestGenerateSourceProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
Let me know |
Ok, I will check that out when I get some time. In the mean time, I posted my sample project to github if you want to try running some tests against it. The project is located here: https://github.com/pbtura/jpa-test |
Hi @pbtura I've cloned your project jpa-test. I've applied the following update to the
And all worked as expected. Take note that the default plugin output path is Below the updated <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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tura</groupId>
<artifactId>jpa-test</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<properties>
<classes.generated.path>${project.build.directory}/generated-sources/annotations</classes.generated.path>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.3.13.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.13.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<version>2.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>3.0.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-sql</artifactId>
<version>3.0.7</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<!-- Tell Maven we are using EJB -->
<ejbVersion>3.2</ejbVersion>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>4.5-jdk8</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<includes>
<include>com/tura/jpa/domain/*.java</include>
</includes>
<addOutputDirectoryToCompilationSources>true</addOutputDirectoryToCompilationSources>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.3.13.Final</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<proc>none</proc>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
</project>
`` |
I'm seeing some strange behavior when trying to use this plugin and I'm not sure if it is a bug or if I am just doing something wrong. When I run a maven build, the generated .java files are being created as expected but there are no corresponding .class files. The project is getting packaged into a library jar, so if the class files are missing, other projects that use the jar will not be able to use the generated files. What do I need to do to make sure the class files get created?
Here is what my pom looks like currently:
When I run 'mvn clean package' everything passes and I see the generated sources in generated-sources/annotations. When I look at generated-sources/classes however the directory is empty. The resulting jar also lacks any of the generated class files.
The text was updated successfully, but these errors were encountered: