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 the main class. It works in project with less dependencies only; for large project with many dependencies, it will cause Java class names or resource files to conflict
Cannot work well with Service Provider Interface(SPI), because multiply service config files across multiply dependencies may overwrite each other, and only one of them will left
maven-shade-plugin: It packages all dependencies into one uber-JAR. It can also be used to build an executable JAR by specifying the main class. This plugin is particularly useful as it merges content of specific files instead of overwriting them by relocating classes. This is needed when there are resource files that have the same name across the JARs and the plugin tries to package all the resource files together
Work well with Service Provider Interface(SPI), because multiply service config files across multiply dependencies will be concated to a final one.
spring-boot-maven-plugin: Best for packaging Spring Boot applications, simplifies creating executable JARs/WARs with Spring Boot runtime.
Cannot work well with JNI, because JNI don’t know how to parse the jar file by default
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.1.0</version> <configuration> <!-- set main class --> <archive> <manifest> <mainClass>xxx.yyy.zzz</mainClass> </manifest> </archive>
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
org.apache.hadoop.fs.LocalFileSystem org.apache.hadoop.fs.viewfs.ViewFileSystem org.apache.hadoop.fs.HarFileSystem org.apache.hadoop.fs.http.HttpFileSystem org.apache.hadoop.fs.http.HttpsFileSystem # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
The actual main class is JarLauncher or WarLauncher, which will prepare the classloader that can understand these nested fat-jar’s structure. And these information is stored in the META-INF/MANIFEST.MF
By default, the maven-surefire-plugin’s test goal automatically executes all test classes in the test source directory that match a set of naming patterns
**/Test*.java
**/*Test.java
**/*TestCase.java
4.1.1 Skip Test
mvn package -DskipTests: Compile test project but don’t run tests.
mvn package -Dmaven.test.skip=true: Skip both compilation and execution.
4.1.2 Run Specific Tests
mvn test -Dtest=SampleTest
mvn test -Dtest=SampleTest#case1
mvn test -Dtest=*Test
mvn test -Dtest=SampleTest1,SampleTest2
mvn test -Dtest=*Test,SampleTest1,SampleTest2
4.1.3 Exclude Tests
When using the <includes> element, the default matching rules will be disabled.
When using the <excludes> element, the default matching rules will not be disabled.