2013-03-07 6 views
5

में फ़ाइलों पर निष्पादन योग्य अनुमतियों को कैसे रखा जाए, मैं एक आर्केटाइप बना रहा हूं जहां मैं कुछ निष्पादन योग्य बाइनरी वाले फ़ोल्डर को शामिल करना चाहता हूं। समस्या यह है कि जब मैं archetype से एक नई परियोजना बनाते हैं, निष्पादन योग्य बाइनरी निष्पादन योग्य अनुमतियों के बिना बनाए जाते हैं।मैवेन आर्केटाइप

मैं उन फ़ाइलों पर निष्पादन अनुमतियों को रखने के लिए मैवेन कैसे बता सकता हूं? या शायद पीढ़ी के समय निष्पादन अनुमतियों को जोड़ने के लिए मेवेन को बताने का मतलब है?

उत्तर

1

मैंने निष्पादन-मैवेन-प्लगइन के साथ दो निष्पादन के साथ समान मुकदमा हल किया है, एक निर्देशिका को ज़िप करता है और अन्य को मेरे मामले में तीसरे पक्ष में भंडार में बिन क्लासिफायर के साथ तैनात किया जाता है। तो मैंने ज़िप फ़ाइल में सभी यूनिक्स अनुमतियों को सहेजा।

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.2.1</version> 
    <executions> 
     <execution> 
      <id>1</id> 
      <phase>package</phase> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
      <configuration> 
       <executable>zip</executable> 
       <workingDirectory>${basedir}</workingDirectory> 
       <arguments> 
        <argument>-r</argument> 
        <argument>target/com.example.test.ext.zip</argument> 
        <argument>Out</argument> 
        <argument>-x</argument> 
        <argument>*.svn*</argument> 
       </arguments> 
      </configuration> 
     </execution> 
     <execution> 
      <id>2</id> 
      <phase>package</phase> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
      <configuration> 
       <executable>mvn</executable> 
       <workingDirectory>${basedir}/target</workingDirectory> 
       <arguments> 
        <argument>deploy:deploy-file</argument> 
        <argument>-Dfile=com.example.test.ext.zip</argument> 
        <argument>-Dclassifier=bin</argument> 
        <argument>-DgroupId=com.example</argument> 
        <argument>-DartifactId=test</argument> 
        <argument>-Dversion=1.0</argument> 
        <argument>-Dpackaging=zip</argument> 
        <argument>-DrepositoryId=releases</argument> 
        <argument>-Durl=http://nexus..../nexus/content/repositories/thirdparty 
        </argument> 
       </arguments> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

आप एक depenency के रूप में परिणाम का उपयोग करते हैं न "बिन" वर्गीकारक भूल:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <version>2.8</version> 
    <executions> 
     <execution> 
      <id>unpack1</id> 
      <phase>generate-resources</phase> 
      <goals> 
       <goal>unpack</goal> 
      </goals> 
      <configuration> 
       <artifactItems> 
        <artifactItem> 
         <groupId>com.example</groupId> 
         <artifactId>test</artifactId> 
         <version>1.0-SNAPSHOT</version> 
         <classifier>bin</classifier> 
         <type>zip</type> 
         <overWrite>true</overWrite> 
         <outputDirectory>output</outputDirectory> 
        </artifactItem> 
       </artifactItems> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
0

एक और उदाहरण निम्नलिखित maven calls external script on both Linux and Windows platforms

तो मैं जोड़कर इस दौर काम के लिए यह पोस्ट देखें :

  <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <version>1.2.1</version> 
      <executions> 
       <execution> 
        <id>script-chmod</id> 
        <phase>install</phase> 
        <goals> 
         <goal>exec</goal> 
        </goals> 
        <configuration> 
         <executable>chmod</executable> 
         <arguments> 
          <argument>+x</argument> 
          <argument>myscript</argument> 
         </arguments> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

हालांकि, यह ईएसी के लिए यह बेकार लगता है एच आर्केटाइप पीढ़ी के बजाय स्थापित करें ताकि अगर किसी के पास कोई बेहतर सुझाव हो तो उन्हें सुनना अच्छा लगेगा।

+0

यह भी अधिक गन्दा हो जाता है क्योंकि आपको खिड़कियों पर विचार करने, प्रोफ़ाइल जोड़ने आदि की आवश्यकता होती है। –

1

यह प्रश्न काफी पुराना है, लेकिन मैंने खुद को एक ही स्थिति में पाया और मुझे एक समाधान मिला, इसलिए यह यहां जाता है। Here यह कहता है कि नई परियोजना उत्पन्न होने के बाद कार्रवाई करने के लिए आप अपने आर्केटाइप के स्रोत/मुख्य/संसाधन/मेटा-आईएनएफ/फ़ोल्डर में archetype-post-gener.groovy नामक एक ग्रोवी स्क्रिप्ट लिख सकते हैं। स्क्रिप्ट यह एक तरह दिखना चाहिए:

def file = new File(request.getOutputDirectory(), request.getArtifactId()+"RELATIVE_PATH"); 
file.setExecutable(true, false); 

जहां request.getOutputDirectory() निर्देशिका नई परियोजना बनाया जाएगा जहां और request.getArtifactId() परियोजना विरूपण साक्ष्य आईडी है।

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