[英]Using cofoja annotations in IntelliJ
我是IntelliJ的新手。 嘗試使用cofoja代碼注釋時,我在構建時會收到以下錯誤。
Error:java: error in contract: package com.google.java.contract.core.agent does not exist
Error:java: error in contract: package com.google.java.contract does not exist
我的項目是針對Oracle JDK 1.7。 我正在使用io.konverge發布的cofoja版本和IntelliJ 14.1.4。
<dependency>
<groupId>io.konverge</groupId>
<artifactId>cofoja</artifactId>
<version>2.0.0</version>
</dependency>
從maven命令行構建項目時,我沒有收到遇到的錯誤。
編輯:
這是一個使用maven編譯好的cofoja項目示例,但我無法在IntelliJ中構建。
https://github.com/konvergeio/cofoja-example
我已經在GitHub上的cofoja
項目票證中附加了此項目的IntelliJ DEBUG構建日志: https : //github.com/nhatminhle/cofoja/issues/45
編輯2:
更新了特定於cofoja-example
項目的問題。
我能夠成功配置IntelliJ。 希望有人發現這很有用。
我必須為當前項目配置Annotation Processors。 它默認啟用,但沒有classoutput
, classpath
和sourcepath
設置所需的適當配置。 我發現了$PROJECT_DIR$
宏來創建相應的項目目錄的相對路徑。 IntelliJ有一個預先配置的宏/變量到我的本地maven存儲庫,所以我用它來引用konvergeio發布的cofoja版本。
我拍了一下我配置的截圖:
IntelliJ生成的構建日志:
2015-07-12 14:04:11,448 [ 1223] DEBUG - s.incremental.java.JavaBuilder - Compiling chunk [cofoja-example] with options: "-g -deprecation -encoding UTF-8 -source 1.7 -target 1.7 -Acom.google.java.contract.sourcepath=/home/seglo/source/cofoja-example/src/main/java -Acom.google.java.contract.classpath=/home/seglo/.m2/repository/io/konverge/cofoja/2.0.0/cofoja-2.0.0.jar -Acom.google.java.contract.classoutput=/home/seglo/source/cofoja-example/target/classes -s /home/seglo/source/cofoja-example/target/generated-sources/annotations"
我將Nas的cofoja-example
項目的分支推送到我的github。 我包含了IntelliJ項目設置。
https://github.com/seglo/cofoja-example
我的項目是.idea/compiler.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
<profile default="false" name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<option name="com.google.java.contract.classoutput" value="$PROJECT_DIR$/target/classes" />
<option name="com.google.java.contract.classpath" value="$MAVEN_REPOSITORY$/io/konverge/cofoja/2.0.0/cofoja-2.0.0.jar" />
<option name="com.google.java.contract.sourcepath" value="$PROJECT_DIR$/src/main/java" />
<processorPath useClasspath="true" />
<module name="cofoja-example" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="cofoja-example" target="1.7" />
</bytecodeTargetLevel>
</component>
</project>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.