倧éšåã®habrazhitelã«ãšã£ãŠã倧èŠæš¡ãªãœãããŠã§ã¢éçºã®äžã§ãæè¡ãèšèªãé«åºŠãªãã®ãããã¯ããã«é
ããŠããããšãããããã®ã¯ãå瀺ã§ã¯ãªããšæããŸãã æ®å¿µãªãããããã¯é¿ããããŸãããäœçŸäžè¡ãã®ã³ãŒããååŸããŠå¥ã®èšèªã«æžãæããããããæ°ãããã¬ãŒã ã¯ãŒã¯ã䜿çšãããããããšã¯ãããæç¹ã§ã¯äžå¯èœã ããã§ãã
ããããããæç¹ã§é
延ãéåžžã«å€§ãããªãã補åã競äºåã倱ããåŸã
ã«åžå Žããæ¶ããŠãããŸãã ç§ãããŸããŸèŠ³å¯ããã®ã¯ããã®ãããªç·©ãããªæžè¡°ã®ç¶æ³ã§ããã
ããã§ã¯ãç¹å®ã®ã±ãŒã¹ã§ãã©ãããŠãé¿ããããªããã®ãé
ãããMavenãããžã§ã¯ãã³ã¬ã¯ã¿ãŒã䜿çšããŠéçºã掻æ§åããããšããæ¹æ³ã«ã€ããŠã話ããããšæããŸãã
ãããããç§ãéçºããã·ã¹ãã ã®äž»ãªå©ç¹ã¯ãããããªåŽåã§Mavenã䜿çšããŠä»»æã®èšèªã§å®è£
ããããããžã§ã¯ããæããããšãã§ããããŒãžã§ã³ãå°éãããããžã§ã¯ãã®ãã«ãæã«èªåçã«æŽæ°ãããå¥ã®ããã±ãŒãžããã¢ã»ã³ãã«ã§ããããšã§ãã å¿
èŠãªã®ã¯ããœãŒã¹ãã³ã³ãã€ã«ã§ããã³ãã³ãã©ã€ã³ãŠãŒãã£ãªãã£ã ãã§ããã¹ã¯ãªããèšèªã®å Žåãæ€èšŒãŠãŒãã£ãªãã£ã圹ç«ã¡ãŸãã
äžããããïŒ
-ãã³ã¢ããäžé£ã®dllã§æ§æããããœãŒã¹ã®ãªãã¢ããªã±ãŒã·ã§ã³éçºè
ã«æäŸãããã·ã¹ãã ã
-Pascalã«äŒŒãŠããããPascalã®æšæºæ©èœïŒãã¹ãŠã§ã¯ãªãïŒã«å ããŠãé©çšãããããã°ã©ãã³ã°èšèªã䜿çšãããšãdllã®ãã³ã¢ãã«å®è£
ããããªããžã§ã¯ãã䜿çšã§ããŸãã ãã®ã¢ããªã±ãŒã·ã§ã³èšèªã¯ãäžçš®ã®ã³ãŒããã€ãã«ã³ã³ãã€ã«ãããå¥ã®ãã³ã¢ãdllã«ãã£ãŠå®è¡ãããŸãã
ãããã£ãŠãäž»ãªéçºã¯äžèšã®
éæ³ã®å¿çšèšèªã§è¡ããããã®é
åã¯ããããå°æ¬ãããã³ãã¥ããã£ãææã«é¥ããå¯èœæ§ãããããã³ã¢ãã¯å®æçã«ïŒæ°ãæã«1åã®æ°ããããŒãžã§ã³ïŒæ¬ç€Ÿããé
ä¿¡ãããå€æŽã§ããŸããã
Pascalã«äŒŒããDelphiã«åºã¥ããŠäœæãããç¬èªã®ããã°ã©ãã³ã°èšèªãéçºããã³ä¿å®ããããšã¯ãããããæªãèãã§ããå¯èœæ§ãéåžžã«é«ãã§ããã15ã17幎åã«ãã®ããšãèãå§ãã人ã¯ããŸããã§ããã ä»ã®ç®æšãè¿œæ±ããŸããããäžè¬çã«ã¯æåããŸããã
ã·ã¹ãã èªäœã¯ããµãŒããŒãã¯ã©ã€ã¢ã³ããããã³ã·ã³ã¯ã©ã€ã¢ã³ããåãã顧客ã«è²©å£²ããã補åã§ãã åœç¶ãã»ãšãã©ã®é¡§å®¢ã¯ã·ã¹ãã ã®æšæºæ©èœã«æºè¶³ããŠããªããããã·ã¹ãã ãããŒãºã«åãããŠãä»äžãããå¿çšéçºéšéãããã€ããããŸãã åãããžã§ã¯ãã¯ãããã°ã©ããŒã®åå¥ã®ã°ã«ãŒãã«åŸäºããŠããŸãã ã°ã«ãŒãéã®çžäºäœçšãšçµéšã®äº€æã¯ãå£æ»
çã«å°ããã§ãã ãããã£ãŠãåã°ã«ãŒãã¯è»èŒªãåçºæããåãã¬ãŒãã10åç®ã«ããæ©äŒãåŸãŸãã
åæåŸããã®éšééã®çžäºäœçšã®æ¬ åŠã¯ãäž»ã«å
±éã³ãŒãã䜿çšããã¡ã«ããºã ã®æ¬ åŠã«ããããšãæããã«ãªããŸããã ã€ãŸããã°ã«ãŒãéã§çµéšãšãœãŒã¹ã³ãŒãã®äº€æããã£ãå Žåãã©ã€ãã©ãªïŒãœãŒã¹ïŒã¯å¥ã®ãããžã§ã¯ãïŒå¥ã®ã¯ã©ã€ã¢ã³ãã®è£œåïŒã«ã³ããŒããããã®æç¹ã§ååšããŠãããã¹ãŠã®äžå
·åãšæ¬ ç¹ãä¿æããŠç¬ç«ããç掻ãéãå§ããŸããã³ããŒã
ãã®ç¶æ³ãæ¹åããããã«ãäžé£ã®å
±æã³ãŒãã©ã€ãã©ãªïŒ
ããã±ãŒãž ïŒã䜿çšããŠããªããžããªïŒãªããžããªïŒãšãããžã§ã¯ãã³ã¬ã¯ã·ã§ã³ã·ã¹ãã ãç·šæããããšã決å®ãããŸããã
ããã©ã«ãã§åæ§ã®æ©èœãå®è¡ããæè»ãªã©ã€ããµã€ã¯ã«ãšãã©ã°ã€ã³ã·ã¹ãã ã®å€§ããªæè»æ§ãåããŠãããããMavenããã®ããŒã«ãšããŠéžæãããŸããã
ãããããŸãæåã«
äž»ãªåé¡ã¯ã調æ»ã®å§ãã«ç§ãçããªãã£ãããããã±ãŒãžã«ã¯ãã€ãã³ãŒãã«ã³ã³ãã€ã«ãããŠããªããã¡ã€ã«ãã€ãŸããœãŒã¹ãå«ããå¿
èŠããããšããããšã§ããã ã³ã³ãã€ã«ã¯ã䜿çšããããã«ãŒãã«ãã®ããŒãžã§ã³ã®äžã§æ£ç¢ºã«è¡ãããå¿
èŠããããŸãã ç°¡åã«ããããã«ãã¢ããªã±ãŒã·ã§ã³ã®ãœãŒã¹ãbpaãšåŒã³ãŸãã ããã¯ãMavenã®æšæºLCãšã¯è¥å¹²ç°ãªããŸãã
ãã®ãããªå瀺ã®åŸããœãŒã¹ããããã±ãŒãžãäœæããããšã決å®ãããŸããããäœæäžã«ã¢ãããã¯ãªã³ã³ãã€ã«ããã§ãã¯ããå¿
èŠããããŸãã èšãæãããšã.classãæåã«ã³ã³ãã€ã«ããããšãã«ã»ãŒæšæºã®Mavenã©ã€ããµã€ã¯ã«ã䜿çšãã次ã«ãªãœãŒã¹ãšãšãã«jarã«ããã±ãŒãžåãããŸãã ç§ã®å Žåã«éããã³ã³ãã€ã«ããããã¡ã€ã«ã®ä»£ããã«ãããã±ãŒãžã¯å§çž®ããããœãŒã¹bpaãã圢æãããŸããã
Mavenã®ä»çµã¿ã«ã€ããŠå°ã
Mavenã®ã©ã€ããµã€ã¯ã«ã¯å®å
šã«å®äºããŠãããäžé£ã®ãã§ãŒãºã§ã¯ãå¿
èŠãª
ãããžã§ã¯ãã¢ã»ã³ããªã®ã»ãŒ
ãã¹ãŠã®æ®µéãèæ
®ãããŸãã
ãããŠãLCã®ãããã§ãŒãºãããšãã°ãmvn compileããéå§ããããšããŠããéã«ãå®éã«ã¯æ€èšŒïŒãããžã§ã¯ãæ€èšŒïŒããã³ã³ãã€ã«ãŸã§ã®ãã§ãŒãºãã§ãŒã³å
šäœãå®è¡ããŸãã äžéšã®ãã§ãŒãºã§ã¯ãpom.xmlïŒMavenãããžã§ã¯ãã®ã¡ã€ã³ãã¡ã€ã«ïŒã«ã¯ããããŒã®ã¿ãããããã©ã°ã€ã³ã®èµ·åã瀺ãåäžã®è¡šç€ºã§ã¯ãªãã«ãããããããåŒã³åºãããããããããã©ã«ããã©ã°ã€ã³ããããŸãã
Mavenã¯å®å
šãªãã©ã°ã€ã³ã·ã¹ãã ã§ããããšãå¥ã«èšåãã䟡å€ããããŸãã èšãæããã°ã圌ã¯ãã©ã°ã€ã³ãèµ·åãã以å€ã«ã»ãšãã©äœãã§ããŸãããã圌ãã¯ãã§ã«é©ãã»ã©å€ãã®æ¹æ³ãç¥ã£ãŠããŸãã Mavenã«ãããžã§ã¯ãã¢ã»ã³ããªã®ç¹æ§ãæãããå Žåã¯ãpom.xmlã«é©åãªãã©ã°ã€ã³ãé©åãªãã§ãŒãºã§é©åãªãã©ã¡ãŒã¿ãŒã§èµ·åããããã®æ瀺ãè¿œå ããå¿
èŠããããŸãã
ãã®ãããªå®å
šã«æå¹ãªç©ºã®pom.xmlã¯ã空ã§ããã«ãããããããmvn deployã³ãã³ããåä¿¡ãããšãsrc / mainãã©ã«ããŒããJava Plug-inã®åæåãã³ã³ãã€ã«ãããã±ãŒãžåãããã³ãããã€ãèµ·åããŸãã
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.projectgroup</groupId> <artifactId>projectname</artifactId> <version>01.03.03-00</version> <build> </build> </project>
Mavenã®äž»ãªäœ¿çšããªã·ãŒã¯ããã¹ãŠã®ã¢ã¯ã·ã§ã³ã«ããã©ã«ãã®ãã©ã¡ãŒã¿ãŒãããããããã®ããã©ã«ããååã§ãªãããèããéåããŠããå Žåã«ã®ã¿è¿œå ã®èšå®ãå¿
èŠã§ããããšã§ãã ç§ã®å Žåãéåžžã«å€ãã®ããã©ã«ããæŸæ£ããªããã°ãªããªãã£ããããpom.xmlã¯ããã»ã©æ§ããã«èŠããªããªããŸããã
pom.xmlã§æ°ããã©ã€ããµã€ã¯ã«ãæ§ç¯ãã
ããã±ãŒãžãå®è£
ããããã«ã次ã®ã©ã€ããµã€ã¯ã«ãéžæãããŸããã
åæå ïŒåæåïŒ-èšå®ïŒããããã£ãŸãã¯ããŒ=å€ïŒãã¡ã€ã«ããèšå®ãèªã¿åããããããã£ã¿ã°ã«è¿œå ããŸãã ããããã£ã¿ã°ã«ã€ããŠã¯åŸã»ã©èª¬æããŸãã
generate-sources ïŒãœãŒã¹ã³ãŒãçæïŒ-zipãããã®ããã±ãŒãž/ãããžã§ã¯ãã®äŸåé¢ä¿ã§ãããã¹ãŠã®ããã±ãŒãžãããŠã³ããŒãããçŸåšã®ããã±ãŒãž/ãããžã§ã¯ãã®ãœãŒã¹ãšãšãã«ããã«ã³ã³ãã€ã«ããããã«å¥ã®ãã£ã¬ã¯ããªã«è§£åããŸãã
compile -bpasã®ã³ã³ãã€ã«ãã©ã°ã€ã³ãå®è¡ããŸããããã«ãããæ£ããã³ã³ãã€ã«é åºã決å®ãããèšèªã®ã³ãã³ãã©ã€ã³ã³ã³ãã€ã©ãèµ·åããŸãã 以äžã«èªåã®ãã©ã°ã€ã³ã«ã€ããŠç°¡åã«èª¬æããŸããããããæžãããã®ã¬ã€ãããã®èšäºã®ç¯å²å€ã«ç§»åããããšããå§ãããŸãã
ã¢ã»ã³ã㪠-ãœãŒã¹ãã¡ã€ã«ã®ãµããã£ã¬ã¯ããªã®æ§é ãä¿æããªãããbpasãœãŒã¹ã§æ§æãããããã±ãŒãžãzipã§ããã¯ããŸãã
ããã〠ïŒãã®å Žåããªããžããªãžã®ã¢ã³ããŒãïŒ-ã¢ã»ã³ããªãã§ãŒãºã§åéãããã¢ã»ã³ããªzipã¯ãpom.xmlããã³ãã®ä»ã®ããã±ãŒãžæ
å ±ãè¿œå ãããããŒã«ã«Mavenãªããžããªã«éä¿¡ãããŸãã ãã®æé ã¯ãéåžžã®ãããã€jarãã¡ã€ã«ãšã»ãŒåãã§ãããç¹å¥ãªãã©ã¡ãŒã¿ãŒããããŸãã
clean-ãã®ãã§ãŒãºã¯ãã¢ã»ã³ããªãã§ãŒãºã®äžè¬çãªLCã«ã¯å«ãŸããŠããŸããããå€å°ç°ãªããŸãããã¢ããã°ã¬ãŒããããŠãããããèšåãã䟡å€ããããŸãã ã³ã³ãã€ã«ããããã¡ã€ã«ããããã£ã¬ã¯ããªã®æšæºçãªåé€ã«å ããŠã ïŒtargetDirectoryïŒãäŸåããã±ãŒãžã®ããŠã³ããŒãããã³ã¢ã³ããã¯äžã«çæãããã¬ããŒãžãåé€ããå¿
èŠããããŸããã
pom.xmlã®äžè¬çãªæ§é
pom.xmlãæ¡ä»¶ä»ãã§ãããããŒãšã¢ã»ã³ããªã®2ã€ã®éšåã«åå²ããŸãã
ããããŒã¯ãããã±ãŒãžIDïŒgroupIdãartifactIdãããŒãžã§ã³ïŒãããããã£ïŒå
éšå®æ°ãšããŠæ©èœããããããã£ïŒãããŒã«ã«ãªããžããªïŒdistributionManagementïŒãããŒã«ã«ãã©ã°ã€ã³ãªããžããªïŒpluginRepositoriesïŒãããŒã«ã«ããã±ãŒãžãªããžããªïŒãªããžããªïŒãããã³äŸåé¢ä¿ã§ãããã®ããã±ãŒãžïŒäŸåé¢ä¿ïŒã åæã«ã3ã€ã®ãªããžããªã¯ãã¹ãŠåããªããžããªãæãããšãã§ããŸãããåºæ¬çã«ãããã¯3ã€ã®ç°ãªããšã³ãã£ãã£ã§ãããããããåå¥ã«æå®ããå¿
èŠããããŸãã ããšãã°ããã©ã°ã€ã³ãä»ã®ã³ãŒããšã¯å¥ã«ä¿åããhttpã¢ã¯ã»ã¹ã䜿çšããŠãªããžããªå
ã®ããã±ãŒãžã«ã¢ã¯ã»ã¹ãããã¡ã€ã«ãªããžããªã®ããã«ããã«ããããã€ãããããšã決å®ã§ããŸãã
ã¢ã»ã³ããªïŒãã«ãã¿ã°ïŒã¯pom.xmlã®2çªç®ã®éšåã§ãããããã©ã«ãèšå®ä»¥å€ã®ããŸããŸãªãã©ã°ã€ã³ã«ããã©ã€ããµã€ã¯ã«ã®ãã®ãã§ãŒãºãŸãã¯ãã®ãã§ãŒãºã®åŠçæ©èœãæ§æãããŸãã ããã«ããããžã§ã¯ãã®ã¢ã»ã³ããªã«åå ãããã£ã¬ã¯ããªãšãã©ã¡ãŒã¿ãŒãããã«æ§æãããŸãã
sourceDirectory-ã³ã³ãã€ã«ã®ãœãŒã¹ã眮ãããŠãããã£ã¬ã¯ããªã
finalName-ã¢ãŒã«ã€ãã«å§çž®ããåŸã®æçµãã¡ã€ã«åã
directory-ã³ã³ãã€ã«ããããã¡ã€ã«ãé
眮ãããäœæ¥ãã£ã¬ã¯ããªã
ããã«ãããããã¹ãŠã®ãã©ã¡ãŒã¿ãŒã«ã¯ããã©ã«ãå€ãããããããã®ããã©ã«ããšã¯ç°ãªãå¿
èŠããããããããã§ã®åå¥ã®æ瀺ãå¿
èŠã§ããããšãããäžåºŠæãåºããããšæããŸãã
ãã«ãã¿ã°ã§ã®ã©ã€ããµã€ã¯ã«å®è£
ããã§ãå®çŸ©ããLCã«æ»ããå¿
èŠãªæ§æã§ç®çã®ãã©ã°ã€ã³ãåŒã³åºããŠãã©ã€ããµã€ã¯ã«ã®åãã§ãŒãºãã©ã®ããã«å®è£
ãããããèŠãŠã¿ãŸãããã
åæåãã
ç¹°ãè¿ããŸãããããããã£ã¿ã°ã«ã€ããŠå°ã説æããŸãã ããããªãå¿
èŠã§ãã©ã®ããã«äœ¿çšããããã説æããŸãããã
éåžžã«ç¡ç€Œãªèšãæ¹ãããã°ããã®ã¿ã°ã¯ããã°ã©ã ïŒpom.xmlïŒã§äœ¿çšãããå®æ°ã®å®£èšã«äŒŒãŠããŸãã ãããã3ã€ã®ç°ãªãæ¹æ³ã§å€ãååŸã§ããŸãã ãŸããåã¡ãœããã«ã¯ãæ¬åœã«å¿
èŠãªãšãã«çµæãã©ããªããã決å®ããåªå
é äœããããŸãã
æãäœãåªå
é äœã¯ã次ã®ããã«ãããããã£ãçŽæ¥ããããã£ã¿ã°ã«æžã蟌ãããšã§ãã
<properties> <helloText>Hello my friend</ helloText > </properties>
ãmvn âDhelloText = Hi initializeãã®ããã«ãMavenã®èµ·åæã«çŽæ¥åªå
é äœãé«ããªããŸã
Mavenããã®ãã©ã¡ãŒã¿ãŒã§èµ·åãããšãhelloTextã¿ã°ã®åæå€ã¯ãçŸåšã®ã»ãã·ã§ã³ã®èµ·åã©ã€ã³ã§æž¡ãããå€ãã€ãŸã xmlã§ã¯ä¿åãããŸããã ãã®ãããªå®æ°ããŸã£ããååšããªãã£ãå Žåããã®ã»ãã·ã§ã³ã§ã¯ååšãã䜿çšã§ããŸãã ååšããªããã¹ãŠã®å®æ°ã®å€ã¯ç©ºã®æååã§ãã
çŸåšã®ã»ãã·ã§ã³ã®ãã©ã°ã€ã³ã«ãã£ãŠãproprtiesã¿ã°ã«å€ãè¿œå ããããšãæãåªå
ãããŸãã ãŸããpom.xmlã«ã¯ä¿åãããŸããã ãname = valueããå«ãããããã£ãã¡ã€ã«ã«åã
ã®ã¢ã»ã³ããªèšå®ãè¡ãããã«äœ¿çšããã®ã¯ããã®ã¡ã«ããºã ã§ã
ãããè¡ãã«ã¯ãproperties-maven-pluginãã©ã°ã€ã³ã䜿çšããŸã
<build> ⊠<plugins> ⊠<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-1</version> <executions> <execution> <id>1</id> <phase>initialize</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> <file>..\build.conf</file> </files> </configuration> </execution> <execution> <id>2</id> <phase>pre-clean</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> <file>..\build.conf</file> </files> </configuration> </execution> </executions> </plugin> ⊠</plugins>
ç¶æ³äŸåã®èšå®ãå¥ã®ãã¡ã€ã«ã«å
¥ããããã®èå³æ·±ããœãªã¥ãŒã·ã§ã³ã«å ããŠãã©ã€ããµã€ã¯ã«ã®ãŸã£ããç°ãªããã§ãŒãºã§åããã©ã°ã€ã³ãã©ã®ããã«å®è¡ããããã«ã€ããŠã®è¯ããã¢ã³ã¹ãã¬ãŒã·ã§ã³ããããŸãã ããã¯<executions />ã¿ã°ã«ãã£ãŠä¿èšŒãããŸãããã®ã¿ã°ã§ã¯ãå¿
èŠãªãã§ãŒãºããšã«åå¥ã®<execution />ã¿ã°ãäœæãããŸãã <execution />ã¿ã°ã«ã¯äžæã®IDãå«ããå¿
èŠãããïŒå®è¡ãè€æ°ã®å ŽåïŒãä»ã®ãã¹ãŠãããåªå
床ãé«ãåå¥ã®æ§æã¿ã°ãå«ããããšãã§ããŸãã
çæãœãŒã¹
ãœãŒã¹çæã®æ®µéã§ããªããžããªããååž°çã«ããŠã³ããŒãããå¿
èŠãªãã¹ãŠã®ããã±ãŒãžã解åããŸããããã¯äŸåé¢ä¿ã«ç€ºãããŠããŸãã ç¹°ãè¿ããŸãããå®éã«ã¯èªåã§äœãããå¿
èŠã¯ãããŸããã ãã©ã°ã€ã³ã¯ãé©åãªèšå®ã瀺ããåŸããã¹ãŠãè¡ããŸãã
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.2.1</version> <executions> <execution> <id>unpackSources</id> <phase>generate-sources</phase> <goals> <goal>unpack</goal> </goals> </execution> </executions> <configuration> <workDirectory>${packagesPath}</workDirectory> </configuration> </plugin>
$ {packagesPath}ã®æ§ç¯ã¯ãã¿ã°ã/ project / properties / packagesPathãããå€ãååŸããå¿
èŠãããããšãæå³ããŸãã
ãããšã¯å¥ã«ãã¢ã³ããã¯ã«
maven-assembly-pluginãã©ã°ã€ã³ã䜿çšããããšã¯éæšå¥šãšèŠãªãããMaven 3ã§ã®äœ¿çšã¯æšå¥šãããªãããšã«æ³šæããŠãã ããã代ããã«ãäžèšãšåæ§ã®èšå®ã§
maven-dependency-pluginã
䜿çšããŸãã å€ãããŒãžã§ã³ã®ãã©ã°ã€ã³ã䜿çšããŠãç¯å²å
ã®ããã€ãã®ã¿ã¹ã¯ãå®è¡ããããã«åããã©ã°ã€ã³ãã©ã®ããã«æ§æãããŠããããããäžåºŠç€ºããŸãã
ã³ã³ãã€ã«ãã
ã³ã³ãã€ã«ã®æ®µéãäœåºŠã調æŽããå¿
èŠããããŸããããç¬èªã®ã³ã³ãã€ã«ãã©ã°ã€ã³ãäœæããããšã§äž»ãªå°é£ãçããŸããã ç¬èªã®Mavenãã©ã°ã€ã³ãäœæããããã®æ®µéçãªæé ã¯å¥ã®èšäºã®ãããã¯ã§ãããããããã§ã¯ããã«çŠç¹ãåœãŠãŸããã æçµçã«ãããã§çŽ¹ä»ããè³æã¯ã¹ã¯ãªããèšèªã«äœ¿çšã§ããŸããã¹ã¯ãªããèšèªã®ã³ã³ãã€ã«ã¯ãŸã£ããå¿
èŠãããŸããã
1ã€ç¢ºããªããšã¯ãã©ããªã«é 匵ã£ãŠãããã€ãã£ã
maven-compile-pluginã®èµ·åãç¡å¹ã«ã§ããªãããšã§ãããã®åŒã³åºãã¯ãJavaãœãŒã¹ãã³ã³ãã€ã«ããããšã§ãïŒsuperPom.xmlã®ç·šéã®å¯èœæ§ãèæ
®ããã«ïŒã ãããã£ãŠãç§ã®ã³ã³ãã€ã«ãã©ã°ã€ã³ã®èšå®ã¯æ¬¡ã®ãšããã§ãã
<plugin> <groupId>com.companyname.utils</groupId> <artifactId>BPASCompilerPlugin</artifactId> <version>0.1.0.2</version> <executions> <execution> <phase>compile</phase> <goals> <goal>bpascompile</goal> </goals> </execution> </executions> <configuration> <protectionServer>${protectionServerName}</protectionServer> <protectionAlias>${protectionServerAlias}</protectionAlias> <bpasccPath>${pathToBPASCC}</bpasccPath> <binaryVersion>${env.BINARY_VERSION}</binaryVersion> </configuration> </plugin>
䜿çšããããã©ã¡ãŒã¿ãŒïŒ
protectionServer-ä¿è·ãµãŒããŒãããããªããšãã³ãã³ãã©ã€ã³ã³ã³ãã€ã©ãèµ·åã§ããŸããã
protectionAlias-ä¿è·ãµãŒããŒã®äœ¿çšæžã¿ã©ã€ã»ã³ã¹ã®ã»ã¯ã·ã§ã³ã
bpasccPath-ã³ãã³ãã©ã€ã³ã³ã³ãã€ã©ãžã®ãã«ãã¹ãŸãã¯çžå¯Ÿãã¹ã
binaryVersion-ã³ã³ãã€ã«ãããã©ã€ãã©ãªã«ãããŠã³ãããããããŒãžã§ã³ã
ããã¯ãã©ã°ã€ã³ã®ãã¹ãŠã®èšå®ã§ã¯ãããŸããããç§ãèšã£ãããã«ãããã¯å¥ã®å€§ããªèšäºã®ãããã¯ã§ãã ååãšããŠãæ§æã»ã¯ã·ã§ã³ã¯ãŸã£ããçç¥ã§ãããã©ã°ã€ã³ã«å¿
èŠãªãã¹ãŠã®ãã©ã¡ãŒã¿ãŒã¯ãMavenã®åºæ¬æŠå¿µã«å¯Ÿå¿ããããã©ã«ãå€ã§ãã©ã°ã€ã³ã«ãã£ãŠåæåãããŸãã
éäŒ
ã¢ã»ã³ããªãã§ãŒãºãæž¡ããšãMavenã¯ããã©ã«ãã§maven-assembly-pluginãå®è¡ããããã«æ§æããããã«ãã¿ã°ã§ã¢ã»ã³ããªãã§ãŒãºã§ã®èµ·åãæ瀺çã«ç€ºãããã®èšå®ããªãŒããŒã©ã€ãããŠåäœãããããšãã§ããŸãã ã³ã³ãã€ã«ããåã«ããã±ãŒãžã解åããããã«åããã©ã°ã€ã³ã䜿çšããã®ã§ãä»åºŠã¯ããã®ãã©ã°ã€ã³ã®èšå®ã®å®å
šçãæäŸããŸããããã«ã¯ãããã¯ãšè§£åã®äž¡æ¹ãå«ãŸããŸãã
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.2.1</version> <executions> <execution> <id>unpackSources</id> <phase>generate-sources</phase> <goals> <goal>unpack</goal> </goals> </execution> <execution> <id>packSources</id> <phase>assembly</phase> <goals> <goal>assembly</goal> </goals> </execution> </executions> <configuration> <descriptors> <descriptor>..\src.xml</descriptor> </descriptors> <workDirectory>${packagesPath}</workDirectory> </configuration> </plugin>
id = packSourcesã®2çªç®ã®å®è¡ã»ã¯ã·ã§ã³ãšããã®ãã§ãŒãºã«å¿
èŠãªèšå®.. \ src.xmlã衚瀺ãããŸãã Src.xmlã«ã¯ããœãŒã¹ãããã±ãŒãžåããæ¹æ³ã®èšå®ãå«ãŸããŠããŸãã å®éããããã®èšå®ã¯ãã¹ãŠèšè¿°åã¿ã°ã«çŽæ¥é
眮ã§ããŸãããããã¯pom.xmlã§éåžžã«ä¹±éã«ãªãå¯èœæ§ããããŸãã
ããã¯ãå³ãå®æãããããã®src.xmlã®äŸã§ãã
<?xml version="1.0" encoding="UTF-8"?> <assembly> <id>src</id> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <includes> <include>pom.xml</include> </includes> </fileSet> <fileSet> <directory>SOURCE</directory> <excludes> <exclude>.svn</exclude> <exclude>**/*${packagesDirName}*/**</exclude> </excludes> </fileSet> </fileSets> </assembly>
packagesDirNameã¯ã/ project / properties pom.xmlãã¡ã€ã«ã®å®æ°ã§ã
ãããšã¯å¥ã«ãããã±ãŒãžèšå®ãå¥ã®ãã¡ã€ã«ã«è»¢éããããšã§ããã¹ãŠã®ããã±ãŒãžã«å¯ŸããŠ1ã€ã®ããã±ãŒãžæ§æãäœæã§ããããšã¯éåžžã«äŸ¿å©ã§ãã
é
åãã
ãã®ãã©ã°ã€ã³ã®èšå®ãæå®ãããã©ããã«é¢ä¿ãªãããããã€ãã§ãŒãºãMavenã«ãã£ãŠèµ·åãããŸãã ããããåå®çŸ©ããããšã§ããã®ãã©ã°ã€ã³ãç§ãã¡èªèº«ã®ããã«æ©èœãããŸããã
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.5</version> <configuration> <file>${project.build.directory}\${project.artifactId}-src.zip</file> <url>${project.distributionManagement.repository.url}</url> <repositoryId>${project.distributionManagement.repository.id}</repositoryId> <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> <packaging>zip</packaging> <pomFile>pom.xml</pomFile> </configuration> </plugin>
ãã®ãããªæåèšå®ã§ã¯ã
maven-deploy-pluginã«ãããä»»æã®ãã¡ã€ã«ïŒãŸãã¯ãã¡ã€ã«ã®ã°ã«ãŒãïŒãæå¹ãªã©ã€ãã©ãªïŒããã±ãŒãžïŒãšããŠMavenãªããžããªã«ã¢ããããŒãã§ããŸãã 次ã«ãèšå®ãé çªã«åæããŠã¿ãŸãããã
file-ããã±ãŒãžãšããŠMavenãªããžããªã«éä¿¡ããããã¡ã€ã«ã
url -Mavenãªããžããªãžã®ãã¹
repositoryId-ãããã€ãå®è¡ããããªããžããªã®èå¥åã
groupId ã
artifactId ã
version -Mavenãªããžããªã®æšæºããã±ãŒãžIDã ã©ã€ãã©ãªãäžæã«èå¥ã§ããã®ã¯ãããã3ã€ã®ãã©ã¡ãŒã¿ãŒã§ãã ããã±ãŒãžã³ã°-ãããã€ã¡ã³ãæ©èœã«ã¯ããªããžããªã«éä¿¡ããããã¡ã€ã«ã®ããã¯ãå«ãŸããŸãããããã£ãŠãããã±ãŒãžã§äœãããªãããã«ãzipãå床æå®ããå¿
èŠããããŸããããããªããšãjarã®ããã«ã¢ã³ããã¯ããã³ããã¯ãããŸãã
pomFile-ãã®ãã©ã¡ãŒã¿ãŒãæå®ãããšãpom.xmlãšããŠæå®ãããã¡ã€ã«ãããã±ãŒãžã«è¿œå ãããŸã;å
ã®ååã¯ç°ãªãå ŽåããããŸãã ãªãªãžãã«ã®pom.xmlãç¶æããããšã¯å€ãã®çç±ã§æçã§ããããããã®æ©èœã軜èŠããŸããã
ãããã«
å
ã«è¿°ã¹ãããã«ãã¯ãªãŒã³ãã§ãŒãºã¯æšæºLCã®äžéšã§ã¯ãããŸããã æåã®ã¿ã¹ã¯ã¯ãmvn cleanã³ãã³ãã®å®è¡åŸããããžã§ã¯ãã«éèŠãªã¢ã¯ãã£ããã£ã®çè·¡ãæ®ããªãããšã§ãã ãã®å Žåãæšæºã®targetSourceãã©ã«ããŒïŒãã«ãã¿ã°ã§ç€ºãããïŒã«å ããŠãããã±ãŒãž/ãããžã§ã¯ãã®ã³ã³ãã€ã«ãæ£åžžã«è¡ãããã«ãäŸåé¢ä¿ãšããŠãããŒãžãããããã¹ãŠã®ããã±ãŒãžãåé€ããå¿
èŠããããŸãã
ãããã£ãŠãèšå®ïŒ
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>2.4.1</version> <configuration> <filesets> <fileset> <directory>${packagesPath}</directory> </fileset> </filesets> </configuration> </plugin>
ãã£ã¬ã¯ã㪠-åé€ãããå®éã®ãã£ã¬ã¯ããªã ããã§ããã©ã°ã€ã³ã®äœæè
ã¯äžè¬ã«åãå
¥ããããŠããæŠå¿µããé¢ããŠããããã©ã°ã€ã³èšå®ãæ瀺çã«æå®ããŠããããã©ã«ãã®ã¢ã¯ã·ã§ã³ã¯ãã£ã³ã»ã«ãããªãããšã«æ³šæããŠãã ããã ãããããã®å Žåãããã¯äžå¿
èŠãªèšå®ããç§ãã¡ãæãã®ã§ãéåžžã«è¯ãã§ãã
æåã«åã
ã®èšå®ãã©ã³ããåŠçããããšãã©ãã»ã©é£ãããã念é ã«çœ®ããŠã以äžã®ããã±ãŒãžã®ããããã®ãã«ããã¹ãpom.xmlãæäŸããŸãã
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.companyname.packages</groupId> <artifactId>String</artifactId> <version>0.1.0.1</version> <name>String</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>windows-1251</project.build.sourceEncoding> <packagesPath>${basedir}/SOURCE/${packagesDirName}</packagesPath> </properties> <distributionManagement> <repository> <id>spb-maven-repo</id> <name>spb-maven-repo</name> <url>file://\\SPB-FS\maven-repo</url> </repository> </distributionManagement> <pluginRepositories> <pluginRepository> <id>spb-maven-repo</id> <name>spb-maven-repo</name> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> <checksumPolicy>fail</checksumPolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> <checksumPolicy>fail</checksumPolicy> </snapshots> <url>http://spb-maven-repo</url> <layout>default</layout> </pluginRepository> </pluginRepositories> <repositories> <repository> <id>spb-maven-repo</id> <url>http://spb-maven-repo</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.companyname.packages</groupId> <artifactId>Arithm</artifactId> <version>0.1.0.1</version> <type>zip</type> </dependency> <dependency> <groupId>com.companyname.packages</groupId> <artifactId>bUnit</artifactId> <version>0.9.0.0</version> <type>zip</type> </dependency> </dependencies> <build> <directory>USER</directory> <sourceDirectory>${basedir}/SOURCE</sourceDirectory> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-1</version> <executions> <execution> <id>1</id> <phase>initialize</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> <file>..\build.conf</file> </files> </configuration> </execution> <execution> <id>2</id> <phase>pre-clean</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> <file>..\build.conf</file> </files> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.2.1</version> <executions> <execution> <id>unpackSources</id> <phase>generate-sources</phase> <goals> <goal>unpack</goal> </goals> </execution> <execution> <id>packSources</id> <phase>assembly</phase> <goals> <goal>assembly</goal> </goals> </execution> </executions> <configuration> <descriptors> <descriptor>..\src.xml</descriptor> </descriptors> <workDirectory>${packagesPath}</workDirectory> </configuration> </plugin> <plugin> <groupId>com.companyname.utils</groupId> <artifactId>CompilerPlugin</artifactId> <version>0.1.0.2</version> <executions> <execution> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> <configuration> <protectionServer>${protectionServerName}</protectionServer> <protectionAlias>${protectionServerAlias}</protectionAlias> <bpasccPath>${pathToBPASCC}</bpasccPath> <binaryVersion>${env.BINARY_VERSION</binaryVersion> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.5</version> <configuration> <file>${project.build.directory}\${project.artifactId}-src.zip</file> <url>${project.distributionManagement.repository.url}</url> <repositoryId>${project.distributionManagement.repository.id}</repositoryId> <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> <packaging>zip</packaging> <pomFile>pom.xml</pomFile> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>2.4.1</version> <configuration> <filesets> <fileset> <directory>${packagesPath}</directory> </fileset> </filesets> </configuration> </plugin> </plugins> </build> </project>
ãŸãšã
ç§ã¯ãã¹ãŠãã§ããã ã詳现ã«èª¬æããããšããŸãããããã¹ãŠåãããã«ãèå°è£ã§ã¯ãŸã åŸç¶ã®èšäºã§åãäžããäºå®ã®èšå€§ãªæ°ã®è³ªåããããŸããã
- ãã§ãŒãºãšç®æšã¯ãèªèº«ãšãã©ã°ã€ã³ãšã®é¢ä¿ã§ãã
- ã¢ãŒãã¿ã€ãã®äœæ-pom.xmlæ§æãšäžé£ã®ããã©ã«ããã¡ã€ã«ããã°ãããããã€ããããã®ãããžã§ã¯ããã³ãã¬ãŒãã
- Mavenãªããžããªãšãã®ç®¡çã
- Mavenãã©ã°ã€ã³ãäœæããã³ãããã°ããæ¹æ³ã
- ããããã¿ãããšã«ç¬èªã®ãã©ã°ã€ã³ãäœæããªãæ¹æ³ã
ç§èªèº«ãèªåã®ä»äºã«æºè¶³ããŠãããšããäºå®ã«ããããããããã®åœ¢åŒã§ã¯ãããžã§ã¯ãããããã§çµã¿ç«ãŠãã·ã¹ãã ã¯ãŸã å®å
šã§ã¯ãããŸããããäžèšã®èª¬æã¯ããã/ãããžã§ã¯ãã®å®å
šãªã©ã€ããµã€ã¯ã«ã®å®è£
ãååã«ç€ºããŠããŸãã å®éãããã¯å®è¡å¯èœãªãã¬ãŒã ã¯ãŒã¯ã§ããããã®äžã§å¯èœæ§ãã»ãšãã©åºããããšãã§ããŸãã
ãã®ãããªãããã¢ã»ã³ããªã®äž»ãªå©ç¹ã¯æ¬¡ã®ãšããã§ãã
- æ±çšã³ãŒãã®è¿œå ãç°¡å
- äŸåé¢ä¿ã®è¿œå ãšãããžã§ã¯ãã®æ§ç¯ãç°¡å
- ãããžã§ã¯ãã®éææ§ïŒäœ¿çšãããŠãããã®ãšéæšæºã®æ¹åã®å®éã®éã¯æããã§ãïŒ
- Mavenã¡ã«ããºã ã®ãããã§ãããã±ãŒãžéã®åŸªç°äŸåé¢ä¿ã®èå¥ã
- äžè¬çãªã³ãŒãã®ä¿®æ£ã®èªåé
åžã
- éåžžã®éçºè
/ãã¹ã¿ãŒã«ââãã䜿ããããïŒ3ã4ããŒã ãååã«ç¥ã£ãŠããïŒã
䟿å©ãªãªã³ã¯
䜿çšãããããŒãžã§ã³ç®¡çã®äŸåé¢ä¿Mavençšã®æãåºæ¬çãªãã©ã°ã€ã³ã®ã»ãããšãããã«é¢ããããã¥ã¡ã³ãã¡ã€ã³ã®Mavenãªããžããªã«å«ãŸãããã©ã°ã€ã³ã®è¿œå ã»ãã