gpt4 book ai didi

maven - 2 POM 中定义的 exec-maven-plugin - 不工作

转载 作者:行者123 更新时间:2023-12-04 19:53:54 26 4
gpt4 key购买 nike

我有两个 Java 主类,需要在构建过程的不同部分执行。在 generate-sources 阶段,需要始终作为我的标准构建过程的一部分执行。另一个需要作为配置文件的一部分执行,但该配置文件应在 process-classes 阶段结束时执行,该阶段还应包括 generate-sources 阶段在此之前。

我能够在标准构建过程的 generate-sources 阶段让第一个插件正常工作:

            <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.MySourceGenerator</mainClass>
</configuration>
</plugin>

但是,当我将同一插件的第二个实例添加到配置文件时,在我的构建过程中不再调用定义为标准构建一部分的插件,从而导致编译错误。这是配置文件中的配置:

<profiles>
<profile>
<id>initSchema</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.SomeOtherClass</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

这是我在命令行上运行的:mvn process-classes -PinitSchema。我的配置有什么问题?我希望这两个插件在各自的阶段执行。

澄清一下:第一个 exec-maven-plugin 生成源,第二个初始化我的数据库模式。

编辑:这是输出

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ABC Web Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @ web-app ---
[INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/msg added.
[INFO]
[INFO] --- maven-processor-plugin:2.0.6:process (process) @ web-app ---
[INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt added
[INFO] javac option: -cp
...
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: com.company.vocab.generator.VocabAnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
[INFO] javac option: -d
[INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
[INFO] javac option: -s
[INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.2.0.Final
[INFO] diagnostic /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/AccountDto.java:5: error: cannot find symbol
import com.telos.xacta.util.Messages;
...
(more similar messages)
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (default) @ web-app ---
[INFO] Generating source...
[INFO] parsing a schema...
[INFO] compiling a schema...
...
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ web-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 16 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ web-app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 281 source files to /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
[INFO] -------------------------------------------------------------
...
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/ProjectHeadDto.java:[4,28] cannot find symbol
symbol: class Messages
location: package com.company.util
...
(more similar errors)
...
[INFO] 29 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.817s
[INFO] Finished at: Thu Aug 01 20:49:07 EDT 2013
[INFO] Final Memory: 31M/282M
[INFO] ------------------------------------------------------------------------

最佳答案

给两个执行 block 一个不同的 id,因为现在它们都使用默认 id,所以一个会覆盖另一个。

关于maven - 2 POM 中定义的 exec-maven-plugin - 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17885813/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com