One Spring Boot project, deploy to both JAR or WAR

I managed to do it by adding <packaging>${packaging.type}</packaging> to the POM file and then setting different profiles for JAR and WAR: <profiles> <profile> <id>jar</id> <properties> <packaging.type>jar</packaging.type> </properties> </profile> <profile> <id>war</id> <properties> <packaging.type>war</packaging.type> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> </dependencies> </profile> </profiles> Now mvn package -P war produces a WAR and mvn package -P jar … Read more

What is a shaded JAR file? And what is the difference/similarities between an uber JAR and shaded JAR? [duplicate]

I’ll explain what an uber JAR is first because this underpins the shading explanation. Uber JAR An uber JAR is a JAR which contains the contents of multiple JARs (or, less commonly, multiple other JARs themselves) Your application will almost certainly use other packages and these packages might be provided as JARs. When using Maven … Read more

Karaf / Maven – Unable to resolve: missing requirement osgi.wiring.package

I believe you have two options here. If you have Import-Package: com.google.gson;version=”[2.3,3)” in your MANIFEST.MF, this means that you want some package to be imported from a deployed bundle, not from an embedded jar. In this case, you should first deploy gson-2.3.1.jar bundle (copy this file to the deploy folder), and then deploy your bundle. … Read more

Change source directory in profile maven

According to the documentation, you can change only few <build> parameters in the profile and <sourceDirectory> is not one of them. I’d configure the main <build> to take sources from path defined by some property (eg. src.dir), set this property to src/main/java and override it in the custom profile: <project> … <properties> <src.dir>src/main/java</src.dir> </properties> <build> … Read more

Proper fix for Java 10 complaining about illegal reflection access by jaxb-impl 2.3.0?

jaxb-ri runtime uses ClassLoader#defineClass / Unsafe#defineClass to do some bytecode modification in runtime to optimize performance. ClassLoader#defineClass is tried first which causes the warning. This legacy optimization is removed completely in jaxb-ri master (after 2.3.0, not released yet). To disable this optimization for 2.3.0, set system property com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize. After next jaxb-ri release updating to newest … Read more

Difference between the maven-assembly-plugin, maven-jar-plugin and maven-shade-plugin?

maven-jar-plugin: This plugin provides the capability to build and sign JARs. But it just compiles the java files under src/main/java and src/main/resources/. It doesn’t include the dependencies JAR files. maven-assembly-plugin: This plugin extracts all dependency JARs into raw classes and groups them together. It can also be used to build an executable JAR by specifying … Read more

Multiple install:install-file in a single pom.xml

I would imagine something like this would work (this will install it on every build): <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <executions> <execution> <id>inst_1</id> <phase>initialize</phase> <goals> <goal>install-file</goal> </goals> <configuration> <!– config for file 1 –> </configuration> </execution> <execution> <id>inst_2</id> <phase>initialize</phase> <goals> <goal>install-file</goal> </goals> <configuration> <!– config for file 2 –> </configuration> </execution> <!– execution file 3… … Read more

Unzip dependency in maven

You can do it with dependencies:unpack-dependencies: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.2</version> <executions> <execution> <id>unpack-sigar</id> <phase>package<!– or any other valid maven phase –></phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <includeGroupIds>org.hyperic</includeGroupIds> <includeArtifactIds>sigar-dist</includeArtifactIds> <outputDirectory> ${project.build.directory}/wherever/you/want/it <!– or: ${project.basedir}/wherever/you/want/it –> </outputDirectory> </configuration> </execution> </executions> </plugin> Reference: Unpacking project dependencies dependency:unpack-dependencies