RE: How to add class file to build & classpath?
ces (default-testResources) @ consumer --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory C:\test\maven-test\multi-module-test\ consumer\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ consume r --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ consumer --- [INFO] No tests to run. [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ consumer --- [INFO] Building jar: C:\test\maven-test\multi-module-test\consumer\target\consum er-1.0.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ consumer --- [INFO] Installing C:\test\maven-test\multi-module-test\consumer\target\consumer- 1.0.jar to C:\Users\RPATRICK\.m2\repository\test\consumer\1.0\consumer-1.0.jar [INFO] Installing C:\test\maven-test\multi-module-test\consumer\pom.xml to C:\Us ers\RPATRICK\.m2\repository\test\consumer\1.0\consumer-1.0.pom [INFO] [INFO] Reactor Summary: [INFO] [INFO] multi-module-test .. SUCCESS [ 0.524 s] [INFO] generator .. SUCCESS [ 3.373 s] [INFO] consumer ... SUCCESS [ 0.245 s] [INFO] [INFO] BUILD SUCCESS [INFO] [INFO] Total time: 4.864 s [INFO] Finished at: 2017-04-06T16:07:09-05:00 [INFO] Final Memory: 19M/373M [INFO] C:\test\maven-test\multi-module-test> -Original Message- From: David Hoffer [mailto:dhoff...@gmail.com] Sent: Thursday, April 06, 2017 3:26 PM To: Maven Users List Subject: Re: How to add class file to build & classpath? I'll try to reply to the last 3 posts... Unfortunately the code uses compiled classes from other modules. So I can't change the phase to prior to compile, if I do that then it doesn't generate the sources. I did find a way to generate sources instead of class files as I agree that is a lot nicer...its not quite as easy as javassist but close enough. However I could not find any combination of moving phases around/etc to make this work...as I mentioned above if I changed the exec plugin phase to be prior to compile then it didn't do anything so there was no generated sources to compile. It seems Maven just just does not like subprocesses that generate more sources using the compiled code. I will look at the above sample projects to see what I missed. For now I have changed things so that I put my generated code right in the src/main/java folder then wrap the exec plugin in a profile so I can manually run that when needed. Not ideal but its working. Will investigate the other projects. -Dave On Thu, Apr 6, 2017 at 1:27 PM, Robert Patrick wrote: > I also built a little sample project where I simulated a generated > class using the maven-resources-plugin to copy a class into the > target/classes directory during the process-resources phase. My unit > test in that module works fine and the other module that consumes that > class (via a normal > dependency) works fine in a multi-module build. Maybe the issue you > are having can be solved by simply moving the exec-maven-plugin > execution to the process-resources phase? > > > > -Original Message----- > From: David Hoffer [mailto:dhoff...@gmail.com] > Sent: Thursday, April 06, 2017 12:45 PM > To: Maven Users List > Subject: Re: How to add class file to build & classpath? > > 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 > > > 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
Re: How to add class file to build & classpath?
I'll try to reply to the last 3 posts... Unfortunately the code uses compiled classes from other modules. So I can't change the phase to prior to compile, if I do that then it doesn't generate the sources. I did find a way to generate sources instead of class files as I agree that is a lot nicer...its not quite as easy as javassist but close enough. However I could not find any combination of moving phases around/etc to make this work...as I mentioned above if I changed the exec plugin phase to be prior to compile then it didn't do anything so there was no generated sources to compile. It seems Maven just just does not like subprocesses that generate more sources using the compiled code. I will look at the above sample projects to see what I missed. For now I have changed things so that I put my generated code right in the src/main/java folder then wrap the exec plugin in a profile so I can manually run that when needed. Not ideal but its working. Will investigate the other projects. -Dave On Thu, Apr 6, 2017 at 1:27 PM, Robert Patrick wrote: > I also built a little sample project where I simulated a generated class > using the maven-resources-plugin to copy a class into the target/classes > directory during the process-resources phase. My unit test in that module > works fine and the other module that consumes that class (via a normal > dependency) works fine in a multi-module build. Maybe the issue you are > having can be solved by simply moving the exec-maven-plugin execution to > the process-resources phase? > > > > -Original Message- > From: David Hoffer [mailto:dhoff...@gmail.com] > Sent: Thursday, April 06, 2017 12:45 PM > To: Maven Users List > Subject: Re: How to add class file to build & classpath? > > 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 > > 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: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__urldefense.proofpoint&d=DwIBaQ&c= > RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK10&r= > Ql5uwmbofQMW0iErugdCnFgO-CBGr_pt_OzwdxJosG0&m=hpzCbX-p3CruRsEhA_ > MZO805q6XsrzWSSqkZCm7IfAs&s=K-Fe2PmitKUNWXWy2vB1JvN-Ih5TBC0VwxThPwDenU8&e= > . > > 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__urldefense.proofpoint&d=DwIBaQ&c= &
RE: How to add class file to build & classpath?
I also built a little sample project where I simulated a generated class using the maven-resources-plugin to copy a class into the target/classes directory during the process-resources phase. My unit test in that module works fine and the other module that consumes that class (via a normal dependency) works fine in a multi-module build. Maybe the issue you are having can be solved by simply moving the exec-maven-plugin execution to the process-resources phase? -Original Message- From: David Hoffer [mailto:dhoff...@gmail.com] Sent: Thursday, April 06, 2017 12:45 PM To: Maven Users List Subject: Re: How to add class file to build & classpath? 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 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: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__urldefense.proofpoint&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK10&r=Ql5uwmbofQMW0iErugdCnFgO-CBGr_pt_OzwdxJosG0&m=hpzCbX-p3CruRsEhA_MZO805q6XsrzWSSqkZCm7IfAs&s=K-Fe2PmitKUNWXWy2vB1JvN-Ih5TBC0VwxThPwDenU8&e= > . > 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__urldefense.proofpoint&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK10&r=Ql5uwmbofQMW0iErugdCnFgO-CBGr_pt_OzwdxJosG0&m=hpzCbX-p3CruRsEhA_MZO805q6XsrzWSSqkZCm7IfAs&s=K-Fe2PmitKUNWXWy2vB1JvN-Ih5TBC0VwxThPwDenU8&e= > . > 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 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 > > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to add class file to build & classpath?
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 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 > > 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: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 > 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 > > > > >
Re: How to add class file to build & classpath?
Hi David, Is this class generated from data files rather than compiled classes? If so, can you bind the plugin run with the generate-resources phase? That would make it available at compile time. > On Apr 6, 2017, at 11:48 AM, David Hoffer 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
Re: How to add class file to build & classpath?
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 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: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 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 > >
RE: How to add class file to build & classpath?
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 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
Re: How to add class file to build & classpath?
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. org.codehaus.mojo exec-maven-plugin 1.6.0 code-generator compile java com.issinc.odin.display.metadata.generator.UiDisplayMetadataGenerator true true ${project.build.directory}/classes -Dave On Thu, Apr 6, 2017 at 10:34 AM, Curtis Rueden 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 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 > > >
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://loci.wisc.edu/software ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden On Thu, Apr 6, 2017 at 10:48 AM, David Hoffer 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 >