且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Cofoja:错误:合同错误:包com.google.java.contract不存在

更新时间:2022-05-04 02:52:06

在这一问题上花费了一天的大部分时间之后,以下是解决方案

After spending best part of a day on this issue, the following was the solution

仅将针对合同的类路径,源路径和类输出编译器args添加到您的编译器中(看起来像这样)

Add the classpath, sourcepath and classoutput compiler args to your compile only for contracts (will look like this)

<!-- Compiles ONLY the contracts. -->
<mkdir dir="${contracts.dir}"/>
<javac srcdir="${src.dir}" destdir="${contracts.dir}">
  <classpath>
    <path refid="class.path"/>
    <!-- Add ${classes.dir} to the second compilation class path
         so that Cofoja finds your already compiled class files. -->
    <pathelement path="${classes.dir}"/>
  </classpath>
  <compilerarg value="-Acom.google.java.contract.classpath=${classpathBuild}" />
  <compilerarg value="-Acom.google.java.contract.sourcepath=${src.dir}" />
  <compilerarg value="-Acom.google.java.contract.classoutput=${classes.dir}"/>
  <compilerarg value="-proc:only" />
</javac>

致谢