Yes I know its more common to start with java source files but in this case
that is not possible unless someone knows how to generate sources from a
javassist generated CtClass. If I could do that then yes I could just add
the sources instead of the class.
Here is the best I have so far and sort of works. Since my class generator
writes to the target/classes folder I told the exec-maven-plugin that and
now it is part of the build as other modules can use the generated class
but its not a great solution as my IDE does not know about the class so it
shows errors. So apparently IntelliJ's Maven support does not extend this
sort of exec-maven-plugin configuration. I need to find a better way to do
this so IDE is happy as well.
Here is the relevant part of my pom.
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>code-generator</id>
<phase>compile</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.issinc.odin.display.metadata.generator.UiDisplayMetadataGenerator</mainClass>
<includeProjectDependencies>true</includeProjectDependencies>
<addOutputToClasspath>true</addOutputToClasspath>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
-Dave
On Thu, Apr 6, 2017 at 10:34 AM, Curtis Rueden <[email protected]> wrote:
> Hi Dave,
>
> > I'm using exec-maven-plugin to call a main in my code that uses
> > javassist to generate a class file at build time.
>
> The more common pattern is to generate .java source files, and then include
> them in the build.
>
> Since you are generating .class file(s), could you do it in a separate
> module of a multi-module build, then add that module as a dependency to
> your main project module?
>
> Could you post an MCVE, particularly your POM, which shows your current
> approach?
>
> Regards,
> Curtis
>
> --
> Curtis Rueden
> LOCI software architect - https://loci.wisc.edu/software
> ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
>
>
> On Thu, Apr 6, 2017 at 10:48 AM, David Hoffer <[email protected]> wrote:
>
> > I'm using exec-maven-plugin to call a main in my code that uses javassist
> > to generate a class file at build time. My code places the class file in
> > the ./target/classes folder so it gets included in the modules normal
> > binary jar.
> >
> > However the rest of the build and other code needs to know that the class
> > exists. I've added that module/artifact as a dependency but the build
> and
> > the runtime classpath has no idea that class exists.
> >
> > How do I add it to the build and runtime classpath?
> >
> > -Dave
> >
>