2013-08-18 49 views
1

我有一些需要修补的依赖关系。目前,我从一个终端(运行Ubuntu的)将修补程序作为maven构建步骤的一部分

patch -R -p1 <Myfolder/Tests/mypatch.patch 

从指定的工作目录。现在我想做这个作为我的maven构建的一部分。我曾尝试(基于如何 “<” 应该在一个xml这里指定:What characters do I need to escape in XML documents?):

<plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>exec-maven-plugin</artifactId> 
     <version>1.2.1</version> 
     <executions> 
      <execution> 
       <id>apply-patch</id> 
       <phase>initialize</phase> 
       <goals> 
        <goal>exec</goal> 
       </goals> 
       <configuration> 
        <executable>patch</executable> 
        <workingDirectory>../../wdir</workingDirectory> 
        <arguments> 
         <argument>R</argument> 
         <argument>p1</argument> 
         <argument>&lt;Myfolder/Tests/mypatch.patch</argument> 
        </arguments> 
       </configuration> 
      </execution>      
     </executions> 
    </plugin> 

但失败:

[INFO] --- exec-maven-plugin:1.2.1:exec (apply-patch) @ my-project --- 
patch: '<Myfolder/Tests/mypatch.patch': extra operand 
patch: Try `patch --help' for more information. 

什么想法?

编辑:现在我试图与-i选项来代替:

<execution> 
    <id>apply-patch</id> 
    <phase>initialize</phase> 
    <goals> 
     <goal>exec</goal> 
    </goals> 
    <configuration> 
     <executable>patch</executable> 
     <workingDirectory>target/tmp</workingDirectory>       
     <arguments> 
      <argument>R</argument> 
      <argument>p1</argument> 
       <argument>i</argument>        
       <argument>mypatch.patch</argument> 
     </arguments> 
    </configuration> 
</execution> 

,但它给人的错误:

[INFO] --- exec-maven-plugin:1.2.1:exec (apply-patch) @ my-project --- 
patch: i: extra operand 
patch: Try `patch --help' for more information. 

这似乎是可能的:

http://security-automation-content-repository.googlecode.com/svn-history/r242/branches/new-shredder/eXist-db/pom.xml

所以我想它只是我想念的一个小细节,任何想法?

回答

0

我不认为你可以从Exec插件做流重定向,但你可以通过patch-i选项指定从stdin读取输入文件,而不必patch

patch手册页

-i patchfile or --input=patchfile
Read the patch from patchfile. If patchfile is -, read from standard input, the default.

+0

请参阅已编辑的帖子,我已尝试使用选项-i但 我犯了同样的错误。 – u123

+0

@ u123尝试单个' imypatch.patch',而不是将它们分隔为两个参数。 – Dev

1

我知道这是一个老问题,但有一个专门做应用补丁插件:在我当前的项目来修补一些类http://maven.apache.org/plugins/maven-patch-plugin/

我用它我生成使用JAXB/XJC(也可作为maven插件),它似乎工作得很好:

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-patch-plugin</artifactId> 
      <version>1.1.1</version> 
      <configuration> 
       <patchFile>${basedir}/src/main/patches/my/package/jaxb-generated-classes.patch</patchFile> 
       <targetDirectory>${basedir}</targetDirectory> 
      </configuration> 
      <executions> 
       <execution> 
        <id>patch</id> 
        <phase>process-sources</phase> 
        <goals> 
         <goal>apply</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
相关问题