Sea*_*ver 3 java design-by-contract intellij-idea
我是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
Run Code Online (Sandbox Code Playgroud)
我的项目是针对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>
Run Code Online (Sandbox Code Playgroud)
从maven命令行构建项目时,我没有收到遇到的错误.
编辑:
这是一个使用maven编译好的cofoja项目示例,但我无法在IntelliJ中构建.
https://github.com/konvergeio/cofoja-example
我cofoja在GitHub上的项目票证中附加了此项目的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"
Run Code Online (Sandbox Code Playgroud)
我把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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
989 次 |
| 最近记录: |