0

I built a maven project, that it copy dependencies jar files in classpath folder (/lib folder near jar file) and look for required dependencies in lib/ folder and use them (set <classpathPrefix>lib/</classpathPrefix> in manifest.mf). it works correctly.

Now I want to change project that it doesn't dependent on dependencies version. I want to have a project that when a dependency required, pick it from lib folder. Because in future, when I need to change the dependency version, I don't have to rebuild the jar file with new pom.xml, and just change old jar file with new one in /lib.

Is there any way to do this ?

Edit:

My pom.xml:

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>first.PathGetter</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <descriptors>
                        <descriptor>src/assembly/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

assembly.xml:

<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>distribution</id>
<formats>
    <format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
    <fileSet>
        <directory>${project.build.directory}</directory>
        <outputDirectory>/</outputDirectory>
        <includes>
            <include>*.jar</include>
        </includes>
    </fileSet>
</fileSets>
<dependencySets>
    <dependencySet>
        <scope>runtime</scope>
        <outputDirectory>/lib</outputDirectory>
        <useProjectArtifact>false</useProjectArtifact>
        <unpack>false</unpack>
    </dependencySet>
</dependencySets>
</assembly>
Ehsan Solimo
  • 23
  • 1
  • 9
  • Can you show how you are doing at the moment ? – khmarbaise Aug 10 '15 at 09:40
  • See update, plugin of pom.xml added – Ehsan Solimo Aug 10 '15 at 09:49
  • Now I put all dependencies in lib folder and set lib folder as class path in `manifest.mf` (Class-Path: lib/*-version.jar). At run time, project pick all required dependencies from class path. In fact I don't want to set class path in `manifest.mf` but I don't know how can I tell path of dependencies without manifest and project use them in run time. – Ehsan Solimo Aug 10 '15 at 11:21

0 Answers0