2012-03-17 11 views
11

मुझे बस इतना ही चाहिए। अतिरिक्त विवरण: मेरे पास एक src/bootstrap/जावा फ़ोल्डर और नियमित src/main/जावा फ़ोल्डर है। स्पष्ट कारणों से प्रत्येक को एक अलग जार जाना होगा। मैं एक बूटस्ट्रैप जार this का उपयोग कर उत्पन्न करने में सक्षम था:मैवेन बिल्ड जार से पैकेजों का एक सेट कैसे बाहर निकालना है?

<plugin> 
    <artifactId>maven-jar-plugin</artifactId> 
    <version>2.3.1</version> 
    <executions> 
     <execution> 
     <id>only-bootstrap</id> 
     <goals><goal>jar</goal></goals> 
     <phase>package</phase> 
     <configuration> 
      <classifier>bootstrap</classifier> 
      <includes> 
      <include>sun/**/*</include> 
      </includes> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

लेकिन नियमित रूप से जार अभी भी बूटस्ट्रैप वर्ग शामिल है। मैं this answer के साथ बूटस्ट्रैप कक्षाओं को संकलित कर रहा हूं।

बूटस्ट्रैप कक्षाओं के बिना myproject.jar उत्पन्न करने के लिए कोई प्रकाश?

उत्तर

16

आप आईडी के लिए उपयोग "डिफ़ॉल्ट-जार" होगा:

<plugin> 
    <artifactId>maven-jar-plugin</artifactId> 
    <version>2.3.1</version> 
    <executions> 
     <execution> 
     <id>only-bootstrap</id> 
     <goals><goal>jar</goal></goals> 
     <phase>package</phase> 
     <configuration> 
      <classifier>bootstrap</classifier> 
      <includes> 
      <include>sun/**/*</include> 
      </includes> 
     </configuration> 
     </execution> 
     <execution> 
     <id>default-jar</id> 
     <phase>package</phase> 
     <goals> 
      <goal>jar</goal> 
     </goals> 
     <configuration> 
      <excludes> 
      <exclude>sun/**/*</exclude> 
      </excludes> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 
+2

आप मुझे बता सकते हैं क्या आदेश आप विशिष्ट निष्पादन आईडी को चलाने के लिए इस्तेमाल किया है। –

+0

धन्यवाद! 'डिफ़ॉल्ट-जार 'निर्दिष्ट करने का क्या सौदा है? क्या मैवेन-जार-प्लगइन इसके लिए दिखता है? – asgs

0

शायद ProGuard का उपयोग करें? अप्रयुक्त कोड को बाहर निकालने के लिए मैं इसका उपयोग करता हूं। यह seems है कि आप इसे एक मेवेन प्लगइन के रूप में जोड़ सकते हैं।

1

मुझे लगता है कि आप एक पोम से दो जार उत्पन्न करने का निर्णय लेने से पहले इसे देख सकते हैं।

Maven best practice for generating multiple jars with different/filtered classes?

आप अभी भी दो जार करने का फैसला, तो आप शायद यह इस का उपयोग करते हैं कर सकते हैं। आपको उचित बहिष्करण निर्दिष्ट करना होगा।

<build> 
    <plugins> 
     <plugin> 
     <artifactId>maven-jar-plugin</artifactId> 
     <executions> 
      <execution> 
      <id>only-bootstrap</id> 
      <goals><goal>jar</goal></goals> 
      <phase>package</phase> 
      <configuration> 
       <classifier>only-library</classifier> 
       <includes> 
       <include>**/*</include> 
       </includes> 
       <excludes> 
       <exclude>**/main*</exclude> 
       </excludes> 
      </configuration> 
      </execution> 
      <execution> 
      <id>only-main</id> 
      <goals><goal>jar</goal></goals> 
      <phase>package</phase> 
      <configuration> 
       <classifier>everything</classifier> 
       <includes> 
       <include>**/*</include> 
       </includes> 
       <excludes> 
       <exclude>**/bootstrap*</exclude> 
       </excludes> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 
संबंधित मुद्दे

 संबंधित मुद्दे