CIã§ã®Javaéçºããããã®mavenã®éå¼ãçãªãã®
ã³ãã³ãã©ã¤ã³ã§Javaã®éçºããããvimã§éçºãããçã®è¦æãå¤ã ããã©ã°ã°ãã¦ãã°ã°ãã¦ãEclipseã®åµã§ãããããã¨ãããããã³ãã³ãã©ã¤ã³ã§ããã¸ã§ã¯ããä½ã£ã¦ãããªãã«éçºããããã«ã¯maven使ãã®ã楽ã§ãããªã®ã§ãåºæ¬çãªä½¿ãæ¹ãã¡ã¢ã£ã¨ãã¾ãã
Debianã®ç³»çµ±ãªãããã§installã§ãã¾ãã
sudo aptitude install maven2
æ¬å½ã¯manã¨ãå ¬å¼ããã¥ã¡ã³ãè¦ãã®ãæ£ããã¨ã¯æããã§ããã©ãããªãããã«ãã©ãçãã®ã¯ç¡çãããªããã¨æãããã¨ã£ãããã¨é²åé²çã«ããã¦ããã¾ãã
ããã¸ã§ã¯ãã®çæ
空ãã£ã¬ã¯ããªãã¤ãã£ã¦æ¬¡ã®ã³ãã³ããå©ãã¨ããã¸ã§ã¯ããçæããã¾ãã
mvn archetype:create -DgroupId=org.hoge -DartifactId=AppHoge -Dversion=0.0.1
ã³ã³ãã¤ã«
mvn compile
ãã¹ãå®è¡
compileãè¡ããã¾ãã
mvn test
packageã®çæ
compile, testãè¡ããã¾ãã
ãã®ã¾ã¾packageã ãã§ãçæããã¾ãããä¸åº¦cleanããã»ããããã®ã§cleanã¯ããã§ãã¾ãã
mvn clean package
argsã®æ¸¡ãæ¹
mvn exec:java -Dexec.mainClass=org.hoge.App -Dexec.args="args0"
ä¾åããã±ã¼ã¸ã®ä½æ
mvn clean assembly:assembly
pom.xml
<build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>org.hoge.Main</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build>
CLããã®å®è¡
mvn exec:java -Dexec.mainClass=org.hoge.App
Webç¨ã®ãµã¼ãã¼èµ·å
mvn jetty:run
pom.xmlã«ããããè¨è¿°ãããã¾ãã
<build> <sourceDirectory>src/main/java</sourceDirectory> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <configuration> <contextPath>/</contextPath> <scanIntervalSeconds>10</scanIntervalSeconds> <connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>8020</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> </plugin> </plugins> </build>
éçº/æ¬çªã§ãªã½ã¼ã¹ã®åç §å ãå¤æ´ãã
pom.xmlã¸idãæå®ãã¦resourceã®åç §å ãã£ã¬ã¯ããªãå¤ããã
<profiles> <profile> <id>dev</id> <build> <resources> <resource> <directory>src/dev/resources</directory> </resource> </resources> </build> </profile> </profiles>
ãã¨ã¯IDãæå®ãã¦ããã±ã¼ã¸ãä½æããã¨æå®ãããªã½ã¼ã¹ãåç
§ãã
ããã±ã¼ã¸ãåºæ¥ä¸ããã¾ãã
mvn clean package -Pdev
Eclipseã®ããã¸ã§ã¯ãã¸å¤æ´
mvn eclipse:eclipse