Alternative method of adding dependencies by using variable

Alternative method of adding third-party libraries to the project  at compile time is the use of variable which will be recorded formed classpath, followed by specifying the maven-compiler-plugin line compilation  overriding argument classpath.

This option may be necessary when you need to keep the original dependencies of the maven project (from pom.xml).

Recording formed classpath variable (in this example: your.classpath.property) as follows:

<plugin>
    <groupId>org.hedgecode.maven.plugins</groupId>
    <artifactId>classpath-maven-plugin</artifactId>
    <version>1.0</version>
    <configuration>
        <path>lib/*.jar</path>
        <isMask>true</isMask>
        <outputProperty>your.classpath.property</outputProperty>
        <assignProjectClasspath>false</assignProjectClasspath>
    </configuration>
</plugin>

Plugin maven-compiler-plugin configuration to compile of your project in this case it should look something like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <compilerArgs>
            <arg>-classpath</arg>
            <arg>${maven.compile.classpath}${path.separator}${your.classpath.property}</arg>
        </compilerArgs>
    </configuration>
</plugin>