tbroyer/gradle-errorprone-plugin-v0.0.x

Getting InvalidPathException for test compilation task.

mrt181 opened this issue · 2 comments

Posted detailed issue here: #1014

I can execute the following and get some output:

$ java -Xbootclasspath/p:error_prone_ant-2.3.1.jar com.google.errorprone.ErrorProneCompiler -source 1.8 -target 1.8 -d C:\cygwin64\home\r892107\sourcecode\COMjurer\build\classes\java\test -encoding UTF-8 -g -sourcepath -processorpath src/test/java/com/rwest/comjurer/xml/XMLParserTest.java                                                                                                                                                                                            

src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:4: error: cannot find symbol
import com.rwest.comjurer.Reply;
                         ^
  symbol:   class Reply
  location: package com.rwest.comjurer
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:5: error: cannot find symbol
import com.rwest.comjurer.TestObjects;
                         ^
  symbol:   class TestObjects
  location: package com.rwest.comjurer
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:6: error: cannot find symbol
import com.rwest.comjurer.XMLReplies;
                         ^
  symbol:   class XMLReplies
  location: package com.rwest.comjurer
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:7: error: package org.junit.jupiter.api does not exist
import org.junit.jupiter.api.Test;
                            ^
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:11: error: package org.junit.jupiter.api does not exist
import static org.junit.jupiter.api.Assertions.assertEquals;
                                   ^
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:11: error: static import only from classes and interfaces
import static org.junit.jupiter.api.Assertions.assertEquals;
^
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:12: error: package org.junit.jupiter.api does not exist
import static org.junit.jupiter.api.Assertions.assertTrue;
                                   ^
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:12: error: static import only from classes and interfaces
import static org.junit.jupiter.api.Assertions.assertTrue;
^
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:3: error: package com.rwest.api.trading.v1beta1 does not exist
import com.rwest.api.trading.v1beta1.*;
^
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:16: error: cannot find symbol
  @Test void parseReply_success() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:27: error: cannot find symbol
  @Test void parseReply_failure() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:39: error: cannot find symbol
  @Test void parseReply_noReply() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:43: error: cannot find symbol
  @Test void parseReplies() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:65: error: cannot find symbol
  @Test void parseReplies_noReply_shouldBeEmpty() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:69: error: cannot find symbol
  @Test void parseUsers() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:75: error: cannot find symbol
  @Test void parseCompanies() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:81: error: cannot find symbol
  @Test void parseSequentialInstrumentDerivedFromAtomic() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:89: error: cannot find symbol
  @Test void parseSequentialInstrumentDerivedFromCombination() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:97: error: cannot find symbol
  @Test void parseCombinationInstruments() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:105: error: cannot find symbol
  @Test void parseAtomicInstruments() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:113: error: cannot find symbol
  @Test void parseSequenceItems() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:121: error: cannot find symbol
  @Test void parseTermformats() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:133: error: cannot find symbol
  @Test void parseContractProperties() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:138: error: cannot find symbol
  @Test void parseTrades() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:144: error: cannot find symbol
  @Test void parseTrades_missingSecondSequenceItemID_shouldCreateSingleContractSpec() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:150: error: cannot find symbol
  @Test void parseTrades_spread_hasBothContractNames() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:156: error: cannot find symbol
  @Test void parseTrades_hasAllTerms() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:166: error: cannot find symbol
  @Test void parseOrders() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:172: error: cannot find symbol
  @Test void parseOrders_missingSecondSequenceItemID_shouldCreateSingleContractSpec() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:178: error: cannot find symbol
  @Test void parseOrders_spread_hasBothContractNames() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:184: error: cannot find symbol
  @Test void parseOrders_noClientId_shouldNotHaveResourceNameOrClientId() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:197: error: cannot find symbol
  @Test void parseOrders_withClientId_doNotSetResourceNameOrClientId() {
   ^
  symbol:   class Test
  location: class XMLParserTest
src\test\java\com\rwest\comjurer\xml\XMLParserTest.java:212: error: cannot find symbol
  @Test void parseOrders_hasAllTerms() {
   ^
  symbol:   class Test
  location: class XMLParserTest
33 errors

I debugged the plugin and the exception is raised in error-prone itself.

net.ltgt.gradle.errorprone.ErrorProneCompiler.java

    try (URLClassLoader cl = new SelfFirstClassLoader(urls.toArray(new URL[urls.size()]))) {
      Thread.currentThread().setContextClassLoader(cl);

      Class<?> builderClass = cl.loadClass("com.google.errorprone.ErrorProneCompiler$Builder");
      Object compilerBuilder = builderClass.getConstructor().newInstance();
      Object compiler = builderClass.getMethod("build").invoke(compilerBuilder);
      // exception thrown in invoke
      Object result =
          compiler
              .getClass()
              .getMethod("compile", String[].class)
              .invoke(compiler, (Object) args.toArray(new String[args.size()]));
      exitCode = result.getClass().getField("exitCode").getInt(result);
    } catch (Exception e) {
      throw UncheckedException.throwAsUncheckedException(e);
    } finally {
      Thread.currentThread().setContextClassLoader(tccl);
    }

Fwiw, you command-line above is missing the classpath, which would explain the cannot find symbol errors.