java - Maven dependency stripVersion creates wrong classpath -
i trying compile project maven (through eclipse), while stripping versions dependency jars. have following in pom.xml:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-dependency-plugin</artifactid> <version>2.8</version> <executions> <execution> <id>copy-dependencies</id> <phase>prepare-package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputdirectory>${project.build.directory}/lib</outputdirectory> <overwritereleases>false</overwritereleases> <overwritesnapshots>false</overwritesnapshots> <overwriteifnewer>true</overwriteifnewer> <stripversion>true</stripversion> </configuration> </execution> </executions> </plugin>
and indeed, jars copied lib/ without version numbers. alas, classnotfound, because manifest.mf in generated executable jar contains classpath referring files including version numbers, naturally not there.
what doing wrong, , how fix it?
edit: jar created maven-jar-plugin:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-jar-plugin</artifactid> <version>2.6</version> <configuration> <archive> <manifest> <addclasspath>true</addclasspath> <classpathprefix>lib/</classpathprefix> <mainclass>my.main.class</mainclass> <adddefaultimplementationentries>true</adddefaultimplementationentries> <adddefaultspecificationentries>true</adddefaultspecificationentries> </manifest> </archive> </configuration> </plugin>
i using run -> maven install
(eclipse m2e plugin)
change maven-jar-plugin create custom classpath layout without version
example:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-jar-plugin</artifactid> <version>3.0.2</version> <configuration> <archive> <manifest> <classpathlayouttype>custom</classpathlayouttype> <customclasspathlayout>lib/$${artifact.artifactid}.$${artifact.extension}</customclasspathlayout> <addclasspath>true</addclasspath> </manifest> </archive> </configuration> </plugin>
Comments
Post a Comment