Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve Maven classpath from configuration

Tags:

maven-2

maven

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

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

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

like image 972
Pass Avatar asked Aug 03 '26 15:08

Pass


1 Answers

The easiest thing to do is to use something like groovy and set it up programatically.

Here is the config that needs to be included.

        <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>
like image 82
Pass Avatar answered Aug 06 '26 08:08

Pass



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!