我有一些依赖项需要修补。目前,我在终端上执行以下操作(运行ubuntu)
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><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
所以我猜这只是我遗漏的一个小细节,有什么想法吗?
发布于 2015-01-29 19:23:11
我知道这是一个老生常谈的问题,但是有一个专门用来打补丁的插件: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>发布于 2013-08-18 09:13:37
我不认为您可以从exec插件执行流重定向,但是您可以向patch传递-i选项来指定一个输入文件,而不是让patch从stdin读取。
来自patch手册页
输入补丁文件或-i =补丁文件
从patchfile中读取补丁。如果patchfile为-,则从标准输入读取,这是默认值。
https://stackoverflow.com/questions/18294701
复制相似问题