Hi,

You should be able to get only the project compiled classes with project.getBuild().getOutputDirectory(). Internally, this is what getCompileClasspathElements does. For the test classpath, you have the similar project.getBuild().getTestOutputDirectory().

With those two folders, you can create the URLClassLoader that load the classes.

Guillaume,


Le 05/09/2016 à 06:05, Francois-Xavier Bonnet a écrit :
When I wrote builder-maven-plugin <https://javabuild.java.net/> I had to do
things with some project classes. What I did was scan the source code and
then load the corresponding .class for each .java file found. Maybe you
could do the same.
The code is here:
https://github.com/javabuild/builder-parent/blob/master/builder-maven-plugin/src/main/java/net/java/javabuild/ExecuteMojo.java

On 5 September 2016 at 13:56, Barrie Treloar <[email protected]> wrote:

On 5 September 2016 at 12:11, Christopher <[email protected]> wrote:

Hi,

I'm trying to write a Maven plugin which gets, and processes, a list of
classes from the project. I want to be able to get the project classes
compiled from either src/main/java (compile scope), and src/test/java
(test
scope, minus compile scope), depending on user configuration.

So far, the closest things I've found to help me are (project is an
instance of MavenProject):
project.getCompileClasspathElements()
and
project.getTestClasspathElements()

I then use that to build a URLClassLoader, which I then use Guava's
ClassPath utility to find all the classes.

The problem is, that brings in the whole classpath, and all I want is
just
the project's own classes, not those from dependencies (including Java
itself). And, the test classpath elements includes the compile-time
scoped
items, as well, which I don't necessarily want. I could probably do set
subtraction to remove the compile-time scope from the test scope, but I
can't figure out how to get rid of what's being added as dependencies,
which I don't wish to process. Perhaps I can do set subtraction from the
dependencies? Is there a way to enumerate the classpath of just the
dependencies?

Has anybody done anything like this? Is there a better way to get only
the
project's own classes?

Why are you wanting to do this?

Are the output files in target/classes and target/test-classes not
sufficient?



---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
https://www.avast.com/antivirus


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to