Hi Dave, I cooked up an example of the multi-module approach which I hope helps:
https://github.com/ctrueden/adhoc-classes The adhoc-dependency modules just generates a class file by some arbitrary means via the exec-maven-plugin. In my case, this is a shell script which calls javac, but in your case it will be your javassist-based approach of course. The main-project module depends on the adhoc-dependency module just fine, and is able to see the generated class without issue. Does it work for you? 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 12:45 PM, David Hoffer <[email protected]> wrote: > Yes that is the location the class file(s) are being created in. And yes I > am binding the exec-maven-plugin to the compile phase in my pom (see prior > email). Also the class(s) file is being included in the resulting jar. > However all this is not sufficient for Maven to notice the class(s) file > was generated and add to the build and classpath. > > I think part of the reason is that in multi-module maven builds it does not > use the jars for the classpath but rather the pre-jar content (not 100% > certain of that). However I don't know why Maven doesn't add/use all files > in the ./target/classes folder but only uses files that it put there > itself. > > What am I missing here? It seems this should just work because the files > are in the ./target/classes folder. > > -Dave > > On Thu, Apr 6, 2017 at 10:55 AM, Robert Patrick <[email protected] > > > wrote: > > > 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:[email protected]] > > 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 <[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 > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > >
