How to use maven shade to build jar and war -
i'm on project working openrdf, , require shade plugin transform service entries. build war , jar simultaneously, both usages possible. however, cannot shade plugin produce shaded jar , shaded war @ same time - shade invokes on package type defined in properties, , binding e.g. jar plugin package phase in order create jar next war results in unshaded jar. how can create both shaded jar , shaded war @ same time?
if "shaded war" mean regular war dependencies packed web-inf/lib
, might use maven-war-plugin
separately , use jar
packaging type. way shade plugin work correctly. , .war
built plugin.
below pom.xml. , here working example.
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>so.test</groupid> <artifactid>stackoverflow-test2</artifactid> <version>1.0-snapshot</version> <packaging>jar</packaging> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-shade-plugin</artifactid> <version>2.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <finalname>${project.build.finalname}-fatjar</finalname> </configuration> </execution> </executions> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-war-plugin</artifactid> <version>2.6</version> <executions> <execution> <phase>package</phase> <goals> <goal>war</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupid>org.testng</groupid> <artifactid>testng</artifactid> <version>5.14.9</version> </dependency> </dependencies> </project>
Comments
Post a Comment