Maven: Retrieve Code, Compile, Deploy

1, Compile, Deploy
1) pom.xml
<project>
...
</build>
...
<plugins>
...
<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>tomcat-maven-plugin</artifactId>
				<configuration>
					<url>http://127.0.0.1:8080/manager</url>
					<server>mytomcat</server>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>


2) settings.xml in \Users\[account]\.m2\ of Operation System
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0   
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<localRepository/>
	<interactiveMode/>
	<usePluginRegistry/>
	<offline/>
	<pluginGroups/>
	<servers>
		<server>
			<id>mytomcat</id>
			<username>test</username>
			<password>pass</password>
		</server>
	</servers>
	<mirrors/>
	<proxies/>
	<profiles/>
	<activeProfiles/>
</settings>



3) tomcat-users.xml
 <role rolename="manager"/>
	<role rolename="admin"/>
	<user username="test" password="pass" roles="manager"/>


2, Get latest code from SVN
1) pom.xml
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-scm-plugin</artifactId>
				<version>1.3</version>
				<configuration>
					<goals>install</goals>
					<username>***</username>
					<password>***</password>
				</configuration>
			</plugin>


...
<scm>
		<connection>scm:svn:file://192.168.1.***//repository/***/</connection>
		<developerConnection>scm:svn:file://192.168.1.***//repository/***//</developerConnection>
		<url>scm:svn:file://192.168.1.180/repository/***//</url>
	</scm>
</project>


3, install software with svn command. i.e. Slik-Subversion-1.6.12-win32.msi
svn --username *** --password *** --non-interactive update F:\***

svn help update

http://www.sliksvn.com/en/download



4, batch DOS command
Echo ------Start To Deploy Project------
Echo ------
Echo ------Start To Retrieve Latest Content From SVN------
call mvn scm:update
Echo ------
Echo ------Start To Install Application------
call mvn install 
Echo ------
Echo ------Start To Deploy Application On Tomcat------
call mvn tomcat:redeploy
Echo ------
Echo ------Deploy Done------



Note:
1, SCM URL
scm:svn:svn://[username[:password]@]server_name[:port]/path_to_repository
scm:svn:svn+ssh://[username@]server_name[:port]/path_to_repository
scm:svn:file://[hostname]/path_to_repository
scm:svn:http://[username[:password]@]server_name[:port]/path_to_repository
scm:svn:https://[username[:password]@]server_name[:port]/path_to_repository


2, SCM example
scm:svn:file:///svn/root/module
scm:svn:file://localhost/path_to_repository
scm:svn:file://my_server/path_to_repository
scm:svn:http://svn.apache.org/svn/root/module
scm:svn:https://[email protected]/svn/root/module
scm:svn:https://username:[email protected]/svn/root/module


3, SCM Command

mvn scm:changelog
mvn -DstartDate=YYYY-MM-DD -DendDate=YYYY-MM-DD scm:changelog

mvn scm:diff
mvn -DstartRevision=<revision> -DendRevision=<revision> scm:diff

mvn scm:validate



你可能感兴趣的:(java,apache,tomcat,maven,SVN)