Extracting Maven classpath from configuration

I need to find the classpath for maven somehow, i.e. all dependencies, etc., and use it as part of the config for the plugin. Here's an example

    ...<systemProperties>
        <systemProperty>
          <name>some.system.property.here</name>
          <value>${maven.runtime.classpath}</value>
        </systemProperty>
     </systemProperties>
    </configuration>...

      

Unfortunately, the $ {maven.runtime.classpath} property is empty. Is there anything that is equivalent to this?

+3


source to share


2 answers


The easiest way is to use something like groovy and configure it programmatically.

Here is the configuration to be enabled.



        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>

            <configuration>
                <source>
                    import org.codehaus.plexus.util.StringUtils;
                    import java.io.File;

                    System.setProperty("your.classpath.property", StringUtils.join(project.getRuntimeClasspathElements().iterator(), File.pathSeparator));
                </source>
            </configuration>

            <executions>
                <execution>
                    <phase>generate-sources</phase>

                    <goals>
                        <goal>execute</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

      

+2


source


I'm not sure why the classpath is empty, maybe this will help: http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html



0


source







All Articles