<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>App-Data-lib</artifactId> <parent> <groupId>net.biancheng.www</groupId> <artifactId>Root</artifactId> <version>1.0</version> </parent> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> </dependencies> <!--添加插件管理--> <build> <pluginManagement> <plugins> <!--声明插件--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.2.1</version> <executions> <!--将 jar-no-fork 目标绑定到 verify 阶段--> <execution> <id>www.lmcjl.com</id> <phase>verify</phase> <goals> <goal> jar-no-fork </goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> </project>
mvn clean install
[INFO] Scanning for projects... [INFO] [INFO] -------------------< net.biancheng.www:App-Data-lib >------------------- [INFO] Building App-Data-lib 1.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ App-Data-lib --- [INFO] Deleting D:\eclipse workSpace4\App-Data-lib\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ App-Data-lib --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory D:\eclipse workSpace4\App-Data-lib\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ App-Data-lib --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to D:\eclipse workSpace4\App-Data-lib\target\classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ App-Data-lib --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory D:\eclipse workSpace4\App-Data-lib\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ App-Data-lib --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to D:\eclipse workSpace4\App-Data-lib\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ App-Data-lib --- [INFO] Surefire report directory: D:\eclipse workSpace4\App-Data-lib\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running net.biancheng.www.App_Data_lib.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ App-Data-lib --- [INFO] Building jar: D:\eclipse workSpace4\App-Data-lib\target\App-Data-lib-1.0.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ App-Data-lib --- [INFO] Installing D:\eclipse workSpace4\App-Data-lib\target\App-Data-lib-1.0.jar to D:\myRepository\repository\net\bianc heng\www\App-Data-lib\1.0\App-Data-lib-1.0.jar [INFO] Installing D:\eclipse workSpace4\App-Data-lib\pom.xml to D:\myRepository\repository\net\biancheng\www\App-Data-li b\1.0\App-Data-lib-1.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.469 s [INFO] Finished at: 2021-04-16T09:23:26+08:00 [INFO] ------------------------------------------------------------------------
<project> ... <!--添加插件管理--> <build> <pluginManagement> ... </pluginManagement> <!-- 声明使用 maven-source-plugin 插件 --> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> </plugin> </plugins> </build> </project>
图1:Maven 插件管理执行结果
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>net.biancheng.www</groupId> <artifactId>Root</artifactId> <version>1.0</version> <!--定义的父类pom.xml 打包类型使pom --> <packaging>pom</packaging> <properties> <!-- 定义一些属性 --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <log4j.version>1.2.17</log4j.version> <junit.version>4.9</junit.version> <system.version>1.0</system.version> <mysql.connector.version>5.1.18</mysql.connector.version> <c3p0.version>0.9.1</c3p0.version> </properties> <!--dependencyManagement 标签用于控制子模块的依赖版本等信息 --> <!-- 该标签只用来控制版本,不能将依赖引入 --> <dependencyManagement> <dependencies> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <!--引用的properties标签中定义的属性 --> <version>${log4j.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <!--引用的properties标签中定义的属性 --> <version>${junit.version}</version> <!-- <scope>test</scope> --> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <!--引用的properties标签中定义的属性 --> <version>${mysql.connector.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <!--引用的properties标签中定义的属性 --> <version>${c3p0.version}</version> </dependency> </dependencies> </dependencyManagement> <!--插件依赖--> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.2.1</version> <executions> <execution> <id>www.lmcjl.com parent</id> <phase>verify</phase> <goals> <goal> jar-no-fork </goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> </project>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>App-Data-lib</artifactId> <parent> <groupId>net.biancheng.www</groupId> <artifactId>Root</artifactId> <version>1.0</version> </parent> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> </dependencies> <build> <plugins> <!-- 声明使用 maven-source-plugin 插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> </plugin> </plugins> </build> </project>
mvn clean install
图2:Maven 继承插件管理
本文链接:http://task.lmcjl.com/news/18667.html