2012-12-05 5 views
8

मैं निम्नलिखित विन्यास है:प्रति-निर्भरता लक्ष्य के दौरान मेवेन-निर्भरता-प्लगइन का उपयोग करके परीक्षण और संकलन के बीच कलाकृतियों को विभाजित करने का कोई तरीका है?

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <version>2.6</version> 
    <executions> 
     <execution> 
      <id>analyze</id> 
      <goals> 
       <goal>analyze-only</goal> 
      </goals> 
      <configuration> 
       <failOnWarning>false</failOnWarning> 
      </configuration> 
     </execution> 
     <!--Copy the dependencies so ant build has the same versions--> 
     <execution> 
      <id>copy-dependencies</id> 
      <phase>package</phase> 
      <goals> 
       <goal>copy-dependencies</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>${project.basedir}/lib</outputDirectory> 
       <overWriteIfNewer>true</overWriteIfNewer> 
       <stripVersion>true</stripVersion> 
       <overWriteReleases>false</overWriteReleases> 
       <overWriteSnapshots>true</overWriteSnapshots> 
       <excludeTransitive>false</excludeTransitive> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

ऊपर विन्यास ही फ़ोल्डर पर सब कुछ उदासीनता। मैं परीक्षण विन्यास जोड़कर जांच का दायरा छोड़कर कोशिश की, लेकिन एक त्रुटि देता है:

Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.6:copy-dependencies (copy-dependencies) on project pcgen: Can't exclude Test scope, this will exclude everything.

वहाँ एक रास्ता बाकी हिस्सों से परीक्षण निर्भरता को अलग तो मैं विभिन्न फ़ोल्डर के कॉपी कर सकते हैं करने के लिए है?

+0

आप क्यों करना चाहते हैं? चींटी के बजाय सीधे मेवेन का उपयोग क्यों नहीं करते? – khmarbaise

+1

बस मेरे नियंत्रण से बाहर एक आवश्यकता है। अभी परियोजना एएनटी से मेवेन में माइग्रेट कर रही है और माइग्रेशन पूर्ण होने पर मुझे दोनों को चालू रखने की आवश्यकता है। मैं मेवेन के साथ अपने सेट को फिर से बनाने की कोशिश कर रहा हूं। – javydreamercsw

उत्तर

8

I tried excluding the test scope by adding the test configuration but gives an error

मैं बस इस वजह से बहुत अलग कारणों से ठोकर खा गया, लेकिन मुझे लगता है कि मैंने हमें दोनों जवाब मिल गए हैं। उदाहरण के लिए, इसे आज़माएं। आपको वर्तमान निर्देशिका में pom.xml की आवश्यकता होगी।

mvn dependency:copy-dependencies \ 
-DincludeScope=runtime \ 
-DexcludeScope=provided \ 
-DoutputDirectory=target/war/WEB-INF/lib 

ब्रायन फॉक्स, जो Maven Dependency Plugin Issue #128 पर लिखता है के लिए एक बड़ी देर से लिया गया धन्यवाद:

You shouldn't ever need to include or exclude two scopes at the same time because they are comprised of each other. The default is to include test scope, which includes everything. If you don't want any test dependencies or provided dependencies, then include runtime and exclude provided.

The scopes being interpreted are the scopes as maven sees them, not as specified in the pom. So the "test" scope includes everything, runtime includes compile but not provided etc.

मई 2013 में includeScope documentation was updated रहे हैं: वास्तव में

/** 
    * Scope to include. An Empty string indicates all scopes (default). 
    * The scopes being interpreted are the scopes as 
    * Maven sees them, not as specified in the pom. In summary: 
    * <ul> 
    * <li><code>runtime</code> scope gives runtime and compile dependencies,</li> 
    * <li><code>compile</code> scope gives compile, provided, and system dependencies,</li> 
    * <li><code>test</code> (default) scope gives all dependencies,</li> 
    * <li><code>provided</code> scope just gives provided dependencies,</li> 
    * <li><code>system</code> scope just gives system dependencies.</li> 
    * </ul> 
    * 
    * @since 2.0 
    */ 
@Parameter(property = "includeScope", defaultValue = "") 
protected String includeScope; 
0

उपयोग includeScope, जांच का दायरा हर शामिल दायरा, यही कारण है कि विफल रहता है।

<includeScope>runtime</includeScope> 
संबंधित मुद्दे

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