Can't you generated class files in the expected location (in 
${project.build.directory}/classes directory) during the compile phase?  I 
would expect these classes to be included in classpath for later pahses and in 
the JAR created during the packaging phase of the module build (assuming 
packaging type is "jar").  Have you tried that?



-----Original Message-----
From: Curtis Rueden [mailto:ctrue...@wisc.edu] 
Sent: Thursday, April 06, 2017 11:34 AM
To: Maven Users List
Subject: Re: How to add class file to build & classpath?

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://urldefense.proofpoint.com/v2/url?u=https-3A__loci.wisc.edu_software&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK10&r=Ql5uwmbofQMW0iErugdCnFgO-CBGr_pt_OzwdxJosG0&m=sAgPJflD39NrfRATxD1qVSvbRHcZlzbPxQqHpteGc0M&s=yDl8PjVnueV1WAKs6W36AGN5yriHr-5eTXTPZi_k0kk&e=
ImageJ2 lead, Fiji maintainer - 
https://urldefense.proofpoint.com/v2/url?u=https-3A__imagej.net_User-3ARueden&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK10&r=Ql5uwmbofQMW0iErugdCnFgO-CBGr_pt_OzwdxJosG0&m=sAgPJflD39NrfRATxD1qVSvbRHcZlzbPxQqHpteGc0M&s=biFYk60WuoVvD5FQonUNvMwQmBxfAOcXn6XyvvRRVDw&e=
 


On Thu, Apr 6, 2017 at 10:48 AM, David Hoffer <dhoff...@gmail.com> 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
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to