java - How do you use the maven shade plugin to include only specific classes from a dependency with scope "provided"? -
i using maven shade plugin package application jar file. 1 of dependencies tomcat:
<dependency> <groupid>org.apache.tomcat</groupid> <artifactid>tomcat-catalina</artifactid> <version>7.0.59</version> <scope>provided</scope> </dependency>
the scope of dependency provided container supply jar files. however, need add few single classes dependency jar file. tried adding filter , specifying name of class added, seems provided dependencies ignored shade plugin.
<build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-shade-plugin</artifactid> <version>2.3</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <filters> <filter> <artifact>org.apache.tomcat:tomcat-catalina</artifact> <includes> <include>org/apache/catalina/deploy/loginconfig.class</include> </includes> </filter> </filters> </configuration> </execution> </executions> </plugin> </plugins> </build>
any ideas how need can achieved?
i had same issue , if can suggest solution use maven-assembly-plugin address problem :
<plugin> <artifactid>maven-assembly-plugin</artifactid> <version>2.5.5</version> <executions> <execution> <id>jar-with-dependencies</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptors> <descriptor>src/main/assembly/assembly.xml</descriptor> </descriptors> <archive> <manifest> <mainclass>com.mypackage.mainclass</mainclass> </manifest> </archive> </configuration> </execution> </executions> </plugin>
and here sample of assembly.xml allow include "provided" scope artifacts:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> <id>jar-with-dependencies</id> <formats> <format>jar</format> </formats> <includebasedirectory>false</includebasedirectory> <dependencysets> <dependencyset> <outputdirectory>/</outputdirectory> <useprojectartifact>true</useprojectartifact> <unpack>true</unpack> </dependencyset> <dependencyset> <outputdirectory>/lib</outputdirectory> <useprojectartifact>false</useprojectartifact> <unpack>false</unpack> <scope>provided</scope> </dependencyset> </dependencysets>
i'am having classpath issues in generated artifact in manifest file!
Comments
Post a Comment