One: Manually add the package into the local warehouse
The Maven command to install the JAR package is:
For example, I have an IK tokenizer that I want to use in the project and can be installed into the local library by myself. If you don't know the groupId, you can click on the jar package to see it. As for the artifactId and version, you can fill in it yourself. As long as it is consistent in the pom,
mvn install:install-file -Dfile=/home/hanson/IKAnalyzer.jar -DgroupId=org.wltea.analyzer -DartifactId=IKAnalyzer -Dversion=2012FF_u1 -Dpackaging=jar
You can directly mvn install your own maven project or something
The following are also download repositories for some commonly used packages.
http://mvnrepository.com/
http://search.maven.org/
http://repository.sonatype.org/content/groups/public/
http://people.apache.org/repo/m2-snapshot-repository/
http://people.apache.org/repo/m2-incubating-repository/
Two: Use the assembly plugin to assemble a set of files, directories, and dependent elements into an archive.
Plugin URL http://maven.apache.org/plugins/maven-assembly-plugin/
The version number can be viewed at http://maven.apache.org/plugins/index.html
For example, if your Maven 2 project contains the "src/main/bin" directory, you can instruct the Assembly plugin to copy all the files in the "src/main/bin" directory to the bin directory (the directory in the archive ), and can modify their permission attributes (UNIX mode)
You need to add the maven-assembly-plugin plugin to the pom.xml file
< plugin > < artifactId > maven-assembly-plugin </ artifactId > < executions > <!-- executor mvn assembly:assembly --> < execution > < id > make-zip </ id > <!-- any name --> < phase > package </ phase > <!-- Bind to the package life cycle phase --> < goals > < goal > single </goal><!-- 只运行一次 --> </goals> <configuration> <descriptors> <!--描述文件路径--> <descriptor>src/main/resources/zip.xml</descriptor> </descriptors> </configuration> </execution> </executions> </plugin>
The description file settings are as follows
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> <id>release</id> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <directory>${project.basedir}\src\main\config</directory> <!-- 过滤 --> <excludes> <exclude>*.xml</exclude> </excludes> <outputDirectory>\</outputDirectory> </fileSet> </fileSets> <dependencySets> <dependencySet> <useProjectArtifact>true</useProjectArtifact> <outputDirectory>lib</outputDirectory><!-- 将scope为runtime的依赖包打包到lib目录下。 --> <scope>runtime</scope> </dependencySet> </dependencySets> </assembly>
The following format is used in this description file
packaged file format Can have: tar.zip war zip <formats> <format>zip</format> </formats> 需要打包的路径 <directory>${project.basedir}</directory> 打包后输出的路径 <outputDirectory>/</outputDirectory> 打包需要包含的文件 <excludes> <exclude>junit:junit</exclude> <exclude>commons-lang:commons-lang</exclude> <exclude>commons-logging:commons-logging</exclude> </excludes> 当前项目构件是否包含在这个依赖集合里。 <useProjectArtifact>true</useProjectArtifact> 依赖包打包到目录下 < dependencySets > < dependencySet > < outputDirectory > lib </ outputDirectory > <!-- Package the dependency package whose scope is runtime into the lib directory. --> < useProjectArtifact > true </ useProjectArtifact > < scope > runtime </ scope > </ dependencySet > </ dependencySets >
3. Skip tests when compiling
-DskipTests compile test cases
-Dmaven.test.skip=true do not compile test cases