How to edit java class file in build time maven?

问题描述 投票:0回答:0

有一个名为 App-A 的通用 java 模块,在两个应用程序中用作 maven 依赖项,如下所示:

<dependency>
    <groupId>com.co</groupId>
   <artifactId>App-a</artifactId>
    <version>1.0</version>
</dependency>

你假设在Myclass的顶部有两个注解:

@Annotation1
@Annotation2
public class MyClass {
    public String method1() {
       //...
    }
}

我希望当它依赖于 App-B 时,

Annotation1
仅显示在
MyClass.class
文件之上,而当它依赖于 App-C 时,
Annotation2
仅显示在文件之上
MyClass.class
文件.

我认为这只有在 Maven 构建时才有可能,但我不知道该怎么做。

这可能吗?是的,我该怎么做?

java maven maven-dependency-plugin
© www.soinside.com 2019 - 2024. All rights reserved.