
























mvn install:install-file -Dfile=cs-1.1.3-SNAPSHOT.jar -DgroupId=com.bireturn -DartifactId=cs -Dversion=1.1.3-SNAPSHOT -Dpackaging=jar
mvn install:install-file -Dfile=cs-1.1.3-SNAPSHOT.pom -DgroupId=com.bireturn -DartifactId=cs -Dversion=1.1.3-SNAPSHOT -Dpackaging=pom
<!--小游戏 地心侠士 公众号:小满小慢 QQ:464884492-->
<dependency>
<version>1</version>
<groupId>com.herbert</groupId>
<artifactId>projectLocal.jar</artifactId>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/projectLocal.jar</systemPath>
</dependency>
<plugin>
<!--小游戏 地心侠士 公众号:小满小慢 QQ:464884492-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerArguments>
<extdirs>${basedir}/src/main/resources/lib/bo;${basedir}/src/main/resources/lib/cognos</extdirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<!--小游戏 地心侠士 公众号:小满小慢 QQ:464884492-->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy api to others project</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/c echo done copy version .</argument>
<argument>&& copy /Y ${project.build.directory}\${project.artifactId}.jar D:\\lib\${project.artifactId}.jar </argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--小游戏 地心侠士 公众号:小满小慢 QQ:464884492-->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>convert version code</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<mainClass>com.herbert.common.HkDoConvertVersionCode</mainClass>
<arguments>
<argument>微信小游戏地心侠士</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--小游戏 地心侠士 公众号:小满小慢 QQ:464884492-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>rootZip-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${name}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>./rootZip-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
rootZip-assembly.xml 文件内容
<assembly>
<id>bin-1</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/webapp/WEB-INF</directory>
<outputDirectory>/herbert/WEB-INF</outputDirectory>
<excludes>
<exclude>cfgHome/hkInitPath/initCmd/**</exclude>
<exclude>cfgHome/hkInitPath/command/*.command</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>/herbert/WEB-INF/classes</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/webapp/apps_res</directory>
<outputDirectory>/herbert/apps_res</outputDirectory>
</fileSet>
<fileSet>
<directory>src/scripts</directory>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
<scope>runtime</scope>
<excludes>
<exclude>${project.groupId}:${project.artifactId}</exclude>
</excludes>
</dependencySet>
<dependencySet>
<outputDirectory>/</outputDirectory>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
复制文件时可以对某些文件内容做替换,比如src/scripts 文件中的一个文件内容,打包后,对应参数会替换成具体的值
java -jar -Dloader.path=resources,lib ${project.artifactId}-${project.version}.jar shutdown
<plugin>
<!--小游戏 地心侠士 公众号:小满小慢 QQ:464884492-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>api</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>herbert-dxxs-api</classifier>
<archive>
<manifest>
<addClasspath>false</addClasspath>
</manifest>
</archive>
<includes>
<include>**/com/dxxs/DataImport*.class</include>
<include>**/com/dxxs/DeleteFile*.class</include>
<include>**/com/dxxs/DownFile*.class</include>
<include>**/com/dxxs/ExcelConvert*.class</include>
<include>**/com/dxxs/FileListener*.class</include>
<include>**/com/dxxs/FileUpaload*.class</include>
<include>**/com/dxxs/UploadFileInfo*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
内置属性(Maven预定义属性,用户可以直接使用)
pom属性(使用pom属性可以引用到pom.xml文件中对应元素的值)
自定义属性(在pom.xml文件的标签下定义的Maven属性)
定义属性:
<project>
<properties>
<mysql.version>5.6.32</mysql.version>
</properties>
</project>
使用属性:
<!--小游戏 地心侠士 公众号:小满小慢 QQ:464884492-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
setting.xml文件属性(与pom属性同理,用户可以用settings.开头的属性引用setting.xml文件的xml元素值)
Java系统属性(所有的Java属性都可以使用Maven属性引用)
环境变量属性(所有的环境变量都可以以env.开头的Maven属性引用)
只构建父工程
mvn package -N
只构建子工程,多个子工程逗号分隔
mvn package -pl 子模块名称
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。