Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commons-io-unsafe-2.5 causes ParseException if missing commons-io dependency. #115

Closed
huxi opened this issue Dec 25, 2016 · 3 comments
Closed

Comments

@huxi
Copy link

huxi commented Dec 25, 2016

The below exception is causing forbiddenApis Gradle task to fail if commons-io-unsafe-2.5 is added to the bundledSignatures but the module isn't actually using commons-io.

While I understand why this happening, I think it shouldn't be an error or a cause for a failure of the forbiddenApis task. It should instead just skip the commons-io checks in that case.

The rationale for this is that I'd like to configure forbiddenApis once, globally, in case of a multi-module Gradle build without having to manually add the commons-io checks only to modules that actually use commons-io.

Stack trace

Caused by: org.gradle.api.InvalidUserDataException: Parsing signatures failed: Class 'org.apache.commons.io.CopyUtils' not found on classpath while parsing signature: org.apache.commons.io.CopyUtils#copy(byte[],java.io.Writer)
        at de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis.checkForbidden(CheckForbiddenApis.java:567)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:632)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:615)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
        ... 70 more
Caused by: de.thetaphi.forbiddenapis.ParseException: Class 'org.apache.commons.io.CopyUtils' not found on classpath while parsing signature: org.apache.commons.io.CopyUtils#copy(byte[],java.io.Writer)
        at de.thetaphi.forbiddenapis.Checker$UnresolvableReporting$1.parseFailed(Checker.java:100)
        at de.thetaphi.forbiddenapis.Checker.addSignature(Checker.java:396)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:529)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:519)
        at de.thetaphi.forbiddenapis.Checker.parseSignaturesFile(Checker.java:500)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:474)
        at de.thetaphi.forbiddenapis.Checker.addBundledSignatures(Checker.java:431)
        at de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis.checkForbidden(CheckForbiddenApis.java:540)
        ... 78 more
@uschindler
Copy link
Member

You can convert the error to a warning: failOnUnresolvableSignatures = false

@huxi
Copy link
Author

huxi commented Dec 25, 2016

That isn't documented over at Gradle Usage Instructions so I missed it.

It's also not exactly what I'm looking for since it causes lots of output in the described case.

The following is currently printed for each and every module that doesn't have the commons-io dependency:

Class 'org.apache.commons.io.CopyUtils' not found on classpath while parsing signature: org.apache.commons.io.CopyUtils#copy(byte[],java.io.Writer) [signature ignored]
Class 'org.apache.commons.io.CopyUtils' not found on classpath while parsing signature: org.apache.commons.io.CopyUtils#copy(java.io.InputStream,java.io.Writer) [signature ignored]
Class 'org.apache.commons.io.CopyUtils' not found on classpath while parsing signature: org.apache.commons.io.CopyUtils#copy(java.io.Reader,java.io.OutputStream) [signature ignored]
Class 'org.apache.commons.io.CopyUtils' not found on classpath while parsing signature: org.apache.commons.io.CopyUtils#copy(java.lang.String,java.io.OutputStream) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#toByteArray(java.io.Reader) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#toByteArray(java.lang.String) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#toString(byte[]) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#toString(java.io.InputStream) [signature ignored]
Class 'org.apache.commons.io.output.ByteArrayOutputStream' not found on classpath while parsing signature: org.apache.commons.io.output.ByteArrayOutputStream#toString() [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#copy(java.io.InputStream,java.io.Writer) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#copy(java.io.Reader,java.io.OutputStream) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#readLines(java.io.InputStream) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#toCharArray(java.io.InputStream) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#toInputStream(java.lang.String) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#write(byte[],java.io.Writer) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#write(char[],java.io.OutputStream) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#write(java.lang.StringBuffer,java.io.OutputStream) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#write(java.lang.String,java.io.OutputStream) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#writeLines(java.util.Collection,java.lang.String,java.io.OutputStream) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#lineIterator(java.io.File) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#readFileToString(java.io.File) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#readLines(java.io.File) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#writeLines(java.io.File,java.util.Collection) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#writeLines(java.io.File,java.util.Collection,java.lang.String) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#writeStringToFile(java.io.File,java.lang.String) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#toInputStream(java.lang.CharSequence) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#write(java.lang.CharSequence,java.io.OutputStream) [signature ignored]
Class 'org.apache.commons.io.output.WriterOutputStream' not found on classpath while parsing signature: org.apache.commons.io.output.WriterOutputStream#<init>(java.io.Writer) [signature ignored]
Class 'org.apache.commons.io.input.ReaderInputStream' not found on classpath while parsing signature: org.apache.commons.io.input.ReaderInputStream#<init>(java.io.Reader) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#write(java.io.File,java.lang.CharSequence) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#toString(java.net.URI) [signature ignored]
Class 'org.apache.commons.io.IOUtils' not found on classpath while parsing signature: org.apache.commons.io.IOUtils#toString(java.net.URL) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#write(java.io.File,java.lang.CharSequence,boolean) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#writeLines(java.io.File,java.util.Collection,boolean) [signature ignored]
Class 'org.apache.commons.io.FileUtils' not found on classpath while parsing signature: org.apache.commons.io.FileUtils#writeLines(java.io.File,java.util.Collection,java.lang.String,boolean) [signature ignored]
Class 'org.apache.commons.io.input.ReversedLinesFileReader' not found on classpath while parsing signature: org.apache.commons.io.input.ReversedLinesFileReader#<init>(java.io.File) [signature ignored]

@uschindler
Copy link
Member

There is already an issue about this: #83

The documentation about all the flags is available on Maven Central as part of the documentation artifact. In addition the Jenkins server also generates it (see link in Github Wiki). As Github does not allow to publish HTML pages as part of its Wiki, the "official" documentation is not visible on Github. There are many settings in Ant/Maven/Gradle that can be customized. The Wiki entries on Github are just a "quick" setup howto, not a documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants