Maven - YooYoungmo/AEP GitHub Wiki

๊ฐœ์š”

https://en.wikipedia.org/wiki/Apache_Maven
์ฃผ๋กœ ์ž๋ฐ”์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๋นŒ๋“œ ์ž๋™ํ™” ํˆด์ด๋‹ค.

์„ธํŒ…

httpsํ”„๋กœํ† ์ฝœ ์ด์šฉ์— ์ œ์•ฝ์ด ์žˆ๋Š” ๊ฒฝ์šฐ ๊ธฐ๋ณธ ๋ ˆํŒŒ์ง€ํ† ๋ฆฌ์˜ ํ”„๋กœํ† ์ฝœ์„ http๋กœ ์ˆ˜์ •ํ•˜์—ฌ ์‚ฌ์šฉ ํ• ์ˆ˜ ์žˆ๋‹ค.
pom.xml ํŒŒ์ผ ๋ณด์กฐ ํด๋ฆญ ํ›„-> maven -> show Effective POM ๋กœ ํ™•์ธ ๊ฐ€๋Šฅ

<!-- pom.xml -->
<project>
<?xml version="1.0" encoding="UTF-8"?>
    ...
    <repositories>
        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>Central Repository</name>
            <url>http://repo.maven.apache.org/maven2</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>Central Repository</name>
            <url>http://repo.maven.apache.org/maven2</url>
        </pluginRepository>
    </pluginRepositories>
</project>

์˜์กด์„ฑ ์ถฉ๋Œ ๊ด€๋ฆฌ

์ฐธ์กฐ๋œ library์˜ ๋‚ด๋ถ€ library์˜ ๋ฒ„์ „ ์ถœ๋™์‹œ ๋‘๊ฐ€์ง€ ๋ฐฉ์‹์œผ๋กœ ๊ด€๋ฆฌ ๊ฐ€๋Šฅ

  • ํŠน์ • library์˜ ์˜์กด์„ฑ ์ œ๊ฑฐ
  • library์˜ ๋ฒ„์ „์„ fix ํ•˜๋Š” ๋ฐฉ์‹
<!-- pom.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<project>
    <dependencies>
        <dependency>
            <groupId>net.sourceforge.htmlunit</groupId>
            <artifactId>htmlunit</artifactId>
            <version>2.24</version>
            <!-- ํŠน์ • library์˜ ์˜์กด์„ฑ ์ œ๊ฑฐ -->
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <!-- library์˜ ๋ฒ„์ „์„ fix ํ•˜๋Š” ๋ฐฉ์‹ -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.10</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

ํ”Œ๋Ÿฌ๊ทธ์ธ

###Maven Surefire Plugin
build lifeCycle์˜ test๋‹จ๊ณ„์— ์‚ฌ์šฉ๋˜๋ฉฐ - unit test ์ˆ˜ํ–‰ configuration์— IntegrationTest์˜ ํŒจํ„ด์„ excludes ์ง€์ •ํ•˜์—ฌ ํ…Œ์ŠคํŠธ ์ˆ˜ํ–‰์‹œ ์ œ์™ธํ•˜๊ณ  ์žˆ๋‹ค.

<!-- pom.xml -->
<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <excludes>
                        <exclude>**/*IntegrationTest*</exclude>
                    </excludes>
                </configuration>
            </plugin>
     ...

integration test๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. integration test๋ฅผ ์œ„ํ•œ 4๋‹จ๊ณ„์˜ Maven lifecycle๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค.

  • pre-integration-test
  • integration-test
  • post-integration-test
  • verify
<project>
     <build>
         <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <includes>
                        <include>**/*IntegrationTest*</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...

์†Œ์Šค ์ปดํŒŒ์ผ์„ ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. (๋ณธ ํ”„๋กœ์ ํŠธ์—์„œ maven์œผ๋กœ ์‹คํ–‰์‹œ jdk์™€ ๋…๋ฆฝ์ ์œผ๋กœ ์ปดํŒŒ์ผ๋Ÿฌ์˜ ๋ฒ„์ „์„ ์ง€์ •ํ•ด์ฃผ๋Š”๋ฐ ์‚ฌ์šฉ.)

<project>
     <build>
         <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            ...
โš ๏ธ **GitHub.com Fallback** โš ๏ธ