私のプロジェクトは Eclipselink を使用するように構成されており、ビルド ツールは Maven です。コード内で JPA2 メタモデルを使用する必要があるため、pom.xml
関連する構成が含まれています。
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>${project.build.directory}/generated-sources/metamodel</outputDirectory>
<compilerArguments>
-Aeclipselink.persistencexml=${project.basedir}/src/main/resources/META-INF/business/user/persistence.xml
</compilerArguments>
<processors>
<processor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
を実行しようとするmvn clean compile
と、ビルド中にエラーが発生します。
[INFO] --- maven-processor-plugin:2.0.4:process (process) @ fsdp-user-service-datalayer ---
[INFO] Source directory: <path>\UserService\DataLayer\target\generated-sources\metamodel added
[INFO] Adding compiler arg: -Aeclipselink.persistencexml=<path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] javac option: -cp
[INFO] javac option: <jars list>
[INFO] javac option: -proc:only
[INFO] javac option: -Aeclipselink.persistencexml=<path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] javac option: -processor
[INFO] javac option: org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
[INFO] javac option: -d
[INFO] javac option: <path>\UserService\DataLayer\target\classes
[INFO] javac option: -s
[INFO] javac option: <path>\UserService\DataLayer\target\generated-sources\metamodel
[INFO] diagnostic <path>\UserService\DataLayer\src\main\java\user\dao\impl\UserDAOImpl.java:11: cannot find symbol
symbol : class UserEntity_
location: package user.entity
[INFO] diagnostic Note: Creating static metadata factory ...
[INFO] diagnostic Note: Found Option : eclipselink.persistencexml, with value: <path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] diagnostic Note: Optional file was not found: META-INF/orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/business/user/orm.xml continuing with generation.
[INFO] diagnostic warning: The following options were not recognized by any processor: '[eclipselink.persistencexml]'
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ fsdp-user-service-datalayer ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ fsdp-user-service-datalayer ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 11 source files to <path>\UserService\DataLayer\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <path>\UserService\DataLayer\src\main\java\user\dao\impl\UserDAOImpl.java:[11,57] cannot find symbol
symbol : class UserEntity_
location: package user.entity
[ERROR] <path>\UserService\DataLayer\src\main\java\user\dao\impl\UserDAOImpl.java:[99,22] cannot find symbol
symbol : variable UserEntity_
location: class user.dao.impl.UserDAOImpl
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.112s
を再度実行して初めて、mvn compile
コンパイルが成功しました。
[INFO] --- maven-processor-plugin:2.0.4:process (process) @ fsdp-user-service-datalayer ---
[INFO] Source directory: <path>\UserService\DataLayer\target\generated-sources\metamodel added
[INFO] Adding compiler arg: -Aeclipselink.persistencexml=<path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] javac option: -cp
[INFO] javac option: <jars>
[INFO] javac option: -proc:only
[INFO] javac option: -Aeclipselink.persistencexml=<path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] javac option: -processor
[INFO] javac option: org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
[INFO] javac option: -d
[INFO] javac option: <path>\UserService\DataLayer\target\classes
[INFO] javac option: -s
[INFO] javac option: <path>\UserService\DataLayer\target\generated-sources\metamodel
[INFO] diagnostic <path>\UserService\DataLayer\src\main\java\user\dao\impl\UserDAOImpl.java:11: cannot find symbol
symbol : class UserEntity_
location: package user.entity
[INFO] diagnostic Note: Creating static metadata factory ...
[INFO] diagnostic Note: Found Option : eclipselink.persistencexml, with value: <path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] diagnostic Note: Optional file was not found: META-INF/orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
[INFO] diagnostic Note: File loaded : META-INF/business/user/orm.xml, is eclipselink-orm file: false
[INFO] diagnostic Note: Found Option : eclipselink.persistencexml, with value: <path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] diagnostic Note: Optional file was not found: META-INF/orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
[INFO] diagnostic Note: File loaded : META-INF/business/user/orm.xml, is eclipselink-orm file: false
[INFO] diagnostic warning: The following options were not recognized by any processor: '[eclipselink.persistencexml]'
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ fsdp-user-service-datalayer ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ fsdp-user-service-datalayer ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 12 source files to <path>\UserService\DataLayer\target\classes
[INFO]
[INFO] --- aspectj-maven-plugin:1.4:compile (compile) @ fsdp-user-service-datalayer ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.720s
[INFO] Finished at: Thu Aug 02 17:45:18 MSK 2012
[INFO] Final Memory: 26M/62M
[INFO] ------------------------------------------------------------------------
2 つのログの主な違いは、「unsuccess clean compile」ログに次の行があることです。
[INFO] diagnostic Note: File loaded : META-INF/business/user/orm.xml, is eclipselink-orm file: false
[INFO] diagnostic Note: Found Option : eclipselink.persistencexml, with value: <path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] diagnostic Note: Optional file was not found: META-INF/orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
[INFO] diagnostic Note: File loaded : META-INF/business/user/orm.xml, is eclipselink-orm file: false
しかし、「成功コンパイル」ログはそうではありません。
質問は、なぜ私はとても奇妙な行動をするのですか?