Maven2による自動デプロイの実験をした

@ITを参考にMaven2による自動デプロイの実験をした。
http://www.atmarkit.co.jp/fjava/special/maven2_02/maven2_02_2.html


1.プロジェクト作成



@ITでは"q4e"というeclipseプラグインを用いているが、wtpプロジェクトにならないなどの問題が発生し、記事どおりに動作しない。
そのため、mvnコマンドで作成するようにした。

  mvn archetype:create -DgroupId=com.example
                       -DartifactId=maven2-webapp
                       -DarchetypeArtifactId=maven-archetype-webapp


2.pom.xmlの変更


以下のように内容を変更した

    
	4.0.0
	com.example
	maven2-webapp
	war
	0.0.1
	maven2-webapp Maven Webapp
	
		
			junit
			junit
			3.8.1
			test
		
	
	
		
			
				true
				org.apache.maven.plugins
				maven-compiler-plugin
				
					1.6
					1.6
					true
					true
				
			
			
				org.apache.maven.plugins
				maven-eclipse-plugin
				
					2.0
					true
				
			
		
		maven2-webapp
	
    

3.eclipseプロジェクトへの変更

    mvn eclipse:eclipse

を実行し、eclipseプロジェクトへの変更を行なう。


4.Cargo Maven2 Pluginでデプロイできるように設定する。


ここでも、例によってpom.xmlを編集する。

    
	4.0.0
	com.example
	maven2-webapp
	war
	0.0.1
	maven2-webapp Maven Webapp
	
		
			junit
			junit
			3.8.1
			test
		
	
	
		
			
				true
				org.apache.maven.plugins
				maven-compiler-plugin
				
					1.6
					1.6
					true
					true
				
			
			
				org.apache.maven.plugins
				maven-eclipse-plugin
				
					2.0
					true
				
			

org.codehaus.cargo cargo-maven2-plugin tomcat6x remote runtime

${cargo.tomcat.manager.url} ${cargo.remote.username} ${cargo.remote.password}
remote com.example maven2-webapp war
maven2-webapp

IntegrationTest http://localhost:8080/manager admin password

PerformanceTest http://hogehoge:8080/manager admin password


5.デプロイ実行


事前に、Tomcatは起動させておくこと。(Managerを用いてデプロイするため)

まずは、build

    mvn package

そしてデプロイ

    mvn -P IntegrationTest cargo:deploy
   (2回目以降のデプロイは)
    mvn -P IntegrationTest cargo:deployer-redeploy