Using cofoja annotations in IntelliJ

I'm new to IntelliJ. When trying to use the cofoja code annotations, I get the following errors on creation.

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

      

My project targets Oracle JDK 1.7. I am using the version of cofoja that io.konverge released and IntelliJ 14.1.4.

<dependency>
  <groupId>io.konverge</groupId>
  <artifactId>cofoja</artifactId>
  <version>2.0.0</version>
</dependency>

      

I am not getting any error when building a project from the command line using maven.

EDIT:

Here's a sample cofoja project that compiles with maven, but I can't seem to embed it in IntelliJ.

https://github.com/konvergeio/cofoja-example

I have attached the IntelliJ DEBUG build log for this project in the project ticket cofoja

on GitHub: https://github.com/nhatminhle/cofoja/issues/45

EDIT 2:

Updated project-specific question cofoja-example

.

+3


source to share


1 answer


I was able to set up IntelliJ successfully. Hope someone finds this helpful.

I had to set up annotation processors for the current project. It was enabled by default, but without the appropriate setting required for settings classoutput

, classpath

and sourcepath

. I discovered a macro $PROJECT_DIR$

to make relative paths to the respective project directories. IntelliJ had a preconfigured macro / variable in my local maven repository, so I used that to reference the posted confoja version in convergeio.

I took a screenshot of my config:

intellij-cofoja-annotation-processor

Completed IntelliJ build log:



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" 

      

I have pushed the fork of the Nas project cofoja-example

to my github. I have enabled IntelliJ project settings.

https://github.com/seglo/cofoja-example

My project .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>

      

+6


source







All Articles