maven經常使用插件及目標java
mvn help:system 查看系統變量apache
mvn help:effective-pom 最終生效的pom文件內容bootstrap
mvn help:describe -Dplugin=clean 查看Plugin的功能服務器
mvn help:describe -Dcmd=deploy 查看deploy階段的設定詳細app
mvn dependency:tree 查看項目的依賴關係maven
mvn dependency:analyze 分析項目的依賴關係ui
mvn dependency:build-classpath 查看classpath的內容url
mvn scm:updatespa
<build>.net
<resources>
<resource>
<directory>src/main/java/com/atm/haservice/sys/mapping</directory>
<includes>
<include>*</include>
</includes>
<targetPath>com/atm/haservice/sys/mapping</targetPath>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>generatorConfig.xml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>cn.com.demo.Main</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
發佈到企業內部的nexus服務器
在~/.m2/setting.xml中設定服務器的認證情報
<server> <id>nexus-releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin123</password> </server> |
2,在項目的pom.xml中陪在發佈元素
<distributionManagement> <repository> <id>nexus-releases</id> <name>Nexus Release Repository</name> <url>http://localhost:8081/nexus/content/repositories/releases/</url> <!-- <url>scp://localhost:8081/nexus/content/repositories/releases/</url> --> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> |
3)執行mvn deploy
配置maven首先從公司內部的nexus下載組件
1)在~/.m2/setting.xml中配置mirrior內容,由於maven默認從遠程的central獲取組件,
經過在setting中陪在mirror到nexus-public,因此首先會從nexus的倉庫獲取組件,無需在pom.xml文件中配置內容。
但若是要下載snapshot的內容,就得陪在profiles來進行查詢,應爲maven默認不會查詢snapshot的。
<mirrors> <mirror> <id>nexus-public</id> <mirrorOf>central</mirrorOf> <name>nexus-public-for-central</name> <url>http://localhost:8081/nexus/content/groups/public/</url> </mirror> </mirrors> |
maven代碼管理(SVN)操做
scm:branch - branch the project(建立項目的分支) scm:validate - validate the scm information in the pom(校驗SCM的配置信息) scm:add - command to add file(增長一個文件) scm:unedit - command to stop editing the working copy(中止編輯當前COPY) scm:export - command to get a fresh exported copy(拉一個全新的分支) scm:bootstrap - command to checkout and build a project(checkout並編譯工程) scm:changelog - command to show the source code revisions(顯示源碼版本) scm:list - command for get the list of project files(列出工程的文件) scm:checkin - command for commiting changes(提交變動) scm:checkout - command for getting the source code(獲取源碼) scm:status - command for showing the scm status of the working copy(獲取本地項目的狀態) scm:update - command for updating the working copy with the latest changes(從服務器獲取最新的版本) scm:diff - command for showing the difference of the working copy with the remote one(比較本地與遠程服務器的差別) scm:update-subprojects - command for updating all projects in a multi project build(更新子項目) scm:edit - command for starting edit on the working copy(編輯) scm:tag - command for tagging a certain revision(打標籤) |