[英]replace classes with library classes
I have a quite large amount of java sources (an open Source Project), where i want to "patch" some class files with my own for debugging pruposes, without touching the original code. 我有大量的Java源代码(一个开放源代码项目),在这里我想用自己的“补丁”一些类文件来调试目的,而不用触碰原始代码。
So I made Patch-Project where i altered eg. 所以我做了补丁项目,我修改了例如。 com.package.abc.java
com.package.abc.java
Now i want to tell eclipse and/or maven to build the original Project, but overwirte its own (original) com.package.abc.java from /src with the patched abc.java from my second Project, which i exported as a library.jar and added to /libs in the original Project. 现在我想告诉eclipse和/或maven构建原始项目,但是用我第二个项目中修补的abc.java覆盖了/ src中它自己的(原始)com.package.abc.java。 .jar并添加到原始项目的/ libs中。
The Stucture looks like this 结构看起来像这样
Original:
/src
com/package/
abc.java
def.java
/libs
patch.jar
patch:
/src
com/package/
abc.java
How do i do this with eclipse and maven plugin? 如何使用Eclipse和Maven插件执行此操作?
Side-Node: This would be a perfect case for Dependency injection. 旁节点:这将是依赖注入的完美案例。
But to solve your problem, use the maven compiler plugin and edit the pom of the open source project: 但是要解决您的问题,请使用Maven编译器插件并编辑开源项目的pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<excludes>
<exclude>**/src/main/java/com/package/abc.java</exclude>
</excludes>
</configuration>
</plugin>
Edit: If you don't want to edit the pom of the original project (this is a bit hacky in my opinion): 编辑:如果您不想编辑原始项目的pom(在我看来,这有点麻烦):
Create a profile in your ~/.m2/settings.xml which contains the plugin configuration: 在〜/ .m2 / settings.xml中创建一个配置文件,其中包含插件配置:
<profiles>
<profile>
<id>ig</id>
<plugins>
<!-- snippet from above -->
</plugins>
</profile>
</profiles>
and then build the open source project with this profile: 然后使用此配置文件构建开源项目:
mvn -Pig verify
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.