티스토리 뷰

공부

Adding a custom jar as a maven dependency

Vincent Park 2016.04.27 12:16

Adding a custom jar as a maven dependency

local repository 를 통해서 maven 빌드할때 custom-jar 파일을 WEB-INF/lib 으로 포함시는방법입니다.


custom-jar : ${project.basedir}/lib/mes-common-libs-0.0.1.jar

dependency.scope:system, dependency.systemPath 를 이용하는 방법

  1. pom.xml
    <dependencies>
        <dependency>
            <groupId>com.custom.jar/groupId>
            <artifactId>custom-jar</artifactId>
            <version>0.0.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/custom-jar-0.0.1.jar</systemPath>
            <optional>false</optional>
        </dependency>
    </dependencies>

    * 그러나 이 방법은 maven build 시에 해당 jar 가 WEB-INF/lib 에 포함되지 않는 문제가 있다

local repository 를 이용한 방법

  1. pom.xml
    <dependencies>
        <dependency>
            <groupId>com.custom.jar</groupId>
            <artifactId>custom-jar</artifactId>
            <version>0.0.1</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>local-repository</id>
            <name>custom-jars</name>
            <url>file://${project.basedir}/lib</url>
        </repository>
    </repositories>

    <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-install-plugin</artifactId>
      <version>2.4</version>
      <executions>
        <execution>
          <phase>initialize</phase>
          <goals>
            <goal>install-file</goal>
          </goals>
          <configuration>
            <groupId>{groupId}</groupId>
            <artifactId>{artifactId}</artifactId>
            <version>0.0.1</version>
            <packaging>jar</packaging>
            <file>${basedir}/lib/custom-jar-0.0.1.jar</file>
          </configuration>
        </execution>
      </executions>
    </plugin>
    </plugins>

    * maven build 로 WEB-INF/lib 에 포함되며, ${project.basedir}/lib/ 위치가 custom-jar 파일들이 위치할 local-repository 가 된다


저작자 표시
신고
댓글
댓글쓰기 폼