maven프로젝트를 자주 사용하고 있습니다.

빌드설정 및 기본 properties를 지정하여 사용하면 조금 편합니다.

<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>

 <repositories>
        <repository>
            <id>default</id>
            <layout>default</layout>
            <name>my_default</name>
            <url>${desired-url}</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>default</id>
            <layout>default</layout>
            <name>my_default</name>
            <url>${desired-url}</url>
        </pluginRepository>
    </pluginRepositories>

….
<build>
        <!– file name –>
        <finalName>${project.name}</finalName>

        <!– Resources Path –>
        <resources>
            <resource>
                <directory>src/main/resources/defaultImages</directory>
                <targetPath>${basedir}/target/classes/defaultImages</targetPath>
            </resource>

            <resource>
                <directory>src/main/resources/view/templates</directory>
                <targetPath>${basedir}/target/classes/templates</targetPath>
            </resource>

            <resource>
                <directory>src/main/resources/prop/sh</directory>
                <targetPath>${basedir}/target</targetPath>
            </resource>

            <resource>
                <directory>src/main/resources/normal</directory>
                <targetPath>${basedir}/target/classes</targetPath>
                <includes>
                    <include>ehcache.xml</include>
                </includes>
                <excludes>
                    <exclude>**/*.*</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources/prop/inner/${env}</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources/prop/inner/${env}</directory>
            </testResource>
        </testResources>

        <!– Plugins –>
        <plugins>

            <!– For Spring BOOT  –>
            <!– Define main-class for executable jar –>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                    <addResources>true</addResources>
                    <mainClass>com.net.MainClass</mainClass>
                </configuration>
            </plugin>

            <!– For Compiling Groovy Sources  –>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerId>groovy-eclipse-compiler</compilerId>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-compiler</artifactId>
                        <version>2.9.2-01</version>
                    </dependency>
                    <!– for 2.8.0-01 and later you must have an explicit
                        dependency on groovy-eclipse-batch –>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-batch</artifactId>
                        <version>2.4.3-01</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!– For Surefire <build log> and skip test during build  –>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>

            <!– ajc compiler –>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.8</version>
                <configuration>
                    <complianceLevel>${java.version}</complianceLevel>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <showWeaveInfo>true</showWeaveInfo>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>       <!– use this goal to weave all your main classes –>
                            <goal>test-compile</goal>  <!– use this goal to weave all your test classes –>
                        </goals>
                    </execution>
                </executions>

                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!– place resource files to desired location –>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <!– here the phase you need –>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/config</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/prop/outer/${env}/config</directory>
                                    <filtering>true</filtering>
                                </resource>

                                <resource>
                                    <directory>src/main/resources/normal</directory>
                                    <includes>
                                        <include>**/*.*</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>

                </executions>
            </plugin>

            <!– run outer ant configuration –>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>process-test-classes</phase>
                        <configuration>
                            <target>
                                <chmod file=”target/start.sh”
                                    perm=”755″ />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!– copy library (jar) files to desired location  –>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/libs</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

      <!– aop build  –>
        <pluginManagement>
            <plugins>
                <!–This plugin’s configuration is used to store Eclipse
                    m2e settings only. It has no influence on the Maven build itself. –>
                <!– Only for eclips env –>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.codehaus.mojo</groupId>
                                        <artifactId>
                                            aspectj-maven-plugin
                                        </artifactId>
                                        <versionRange>[1.8,)</versionRange>
                                        <goals>
                                            <goal>compile</goal>
                                            <goal>test-compile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.apache.maven.plugins
                                        </groupId>
                                        <artifactId>
                                            maven-compiler-plugin
                                        </artifactId>
                                        <versionRange>
                                            [3.3,)
                                        </versionRange>
                                        <goals>
                                            <goal>compile</goal>
                                            <goal>testCompile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

Leave a Reply

Your email address will not be published. Required fields are marked *