2013-03-07 16 views
5

Buduję archetyp, w którym chcę dołączyć folder z plikami wykonywalnymi. Problem polega na tym, że podczas tworzenia nowego projektu z archetypu pliki wykonywalne są tworzone bez uprawnień do wykonywania.Jak zachować uprawnienia do wykonywania plików w archetypie maven archetyp

Jak mogę poinformować maven o zachowaniu uprawnień do wykonywania tych plików? A może jest jakiś sposób, aby powiedzieć mavenowi, aby automatycznie dodawał uprawnienia do wykonywania w czasie generowania?

Odpowiedz

1

Rozwiązałem podobną funkcję z exec-maven-plugin z dwoma wykonaniami, jednym zamieniłem zip na dyrektorów, a drugi wdrożyłem z klasyfikatorem bin do repozytorium w moim przypadku do strony trzeciej. Więc zapisałem wszystkie uprawnienia uniksowe w pliku zip.

<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> 

Jeśli używasz wynik jako depenency nie zapomni „bin” klasyfikator:

<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

Zobacz ten post na innym przykładzie maven calls external script on both Linux and Windows platforms

więc pracowałem okrągłe to poprzez dodanie następującego :

  <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> 

Jednak wydaje się, że to marnotrawstwo dla eac h zainstalować, a nie tylko generowanie archetypu, więc jeśli ktoś ma jakieś lepsze sugestie, to chciałbym je usłyszeć.

+0

Również to staje się bardziej niepotrzebne, ponieważ musisz wziąć pod uwagę okna, dodać profil itp. –

1

To pytanie jest dość stare, ale znalazłem się w tej samej sytuacji i znalazłem rozwiązanie, więc oto jest. Here mówi, że możesz napisać groovy skrypt o nazwie archetype-post-generate.groovy w folderze src/main/resources/META-INF/swojego archetypu w celu wykonania akcji po wygenerowaniu nowego projektu. Skrypt powinien wyglądać jak ten:

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

gdzie request.getOutputDirectory() jest katalogiem, w którym nowy projekt zostanie utworzony i request.getArtifactId() jest id artefakt projektu.

Powiązane problemy