การใช้ Dependency Plugin ของ Maven 2 ในการ copy Dependency file

Posted: ตุลาคม 17, 2008 in Java
ป้ายกำกับ:,

วันนี้มีปัญหาเรื่อง build jar จาก maven project ได้แล้ว แต่จะเอา dependency jar ทั้งหมดของมันออกมาได้ยังไงหว่า เนื่องจากผมใช้ Eclipse ในการพัฒนา project ดังนั้นวิธีสุดเถื่อนคือ copy จาก Eclipse นั่นล่ะ แต่… มันทำไม่ได้แฮะ เลยต้องมานั่งหาวิธีใหม่ ไปค้นเจอพระเอกของเรื่องคือ Dependency Plugin ของ Maven วิธีการก็แสนง่าย เขียนตามนี้เลย

<plugins>
<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <version>2.0</version>
      <executions>
         <execution>
            <id>copy-dependencies</id>
<phase>package</phase>
            <goals>
               <goal>copy-dependencies</goal>
            </goals>
            <configuration>
               <!-- configure the plugin here -->
            </configuration>
        </execution>
     </executions>
   </plugin>
</plugins>

พอ run maven package เราก็จะได้ dependency jar ทั้งหมดมาอยู่ใน folder ชื่อ dependency

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Connecting to %s