[GRADLE-2963] "org.apache.commons.io.FileUtils" class is available for compile, but isn't available in runtime Created: 26/Nov/13 Updated: 27/Jan/17 Resolved: 24/Jan/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 2.14-rc-6 |
Type: | Bug | ||
Reporter: | Gradle Forums | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 2 |
Description |
This issue is similar to [1]http://forums.gradle.org/gradle/topic... I try to use class from "commons-io-1.4.jar" library in my custom task. If I don't define any dependencies, I get successfull compile and "ClassNotFoundException" error on execution. If I copy "commons-io-1.4.jar" into "lib" project folder and define it as dependency, then all works fine. But if I set dependency on library file from standard Gradle instalation, then I get the same error "ClassNotFoundException". Look at details below. If you can't give access to library classes in my code, then you need to raise error, when I try to use this library in dependencies. c:\Temp\GradleBug\build.gradle c:\Temp\GradleBug\buildSrc\build.gradle c:\Temp\GradleBug\buildSrc\src\main\java\IOTask.java public class IOTask private Object from; @TaskAction public IOTask from(Object sourcePath) { |
Comments |
Comment by Gradle Forums [ 26/Nov/13 ] |
Please enclose code and output in HTML code tags. Which exception do you get? |
Comment by Gradle Forums [ 26/Nov/13 ] |
c:\Temp\GradleBug\build.gradle c:\Temp\GradleBug\buildSrc\build.gradle c:\Temp\GradleBug\buildSrc\src\main\java\IOTask.java public class IOTask private Object from; @TaskAction public IOTask from(Object sourcePath) { I get "ClassNotFoundException" on "org.apache.commons.io.FileUtils" class. Caused by: java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils |
Comment by Gradle Forums [ 26/Nov/13 ] |
You should never set an explicit dependency on a Jar in the Gradle distribution. Gradle plugins should declare a `compile gradleApi()` dependency. For `buildSrc`, this dependency is declared automatically. |
Comment by Gradle Forums [ 26/Nov/13 ] |
You contradict to yourself. If "commons-io-1.4.jar" library is part of "Gradle API", then it must be available to my code without any error. If it's not part, then why I can't make dependency on already existing file? Why I must make copy of this library and make dependency on this copy? It have so sense. I think, the root of this problem lie in Gradle classloader, which put "commons-io-1.4.jar" library in some classloader's tree node, where it is not available for my plugin code. |
Comment by Gradle Forums [ 26/Nov/13 ] |
Looking at this again, the problem may be related to your use of an internal Gradle class (`org.gradle.api.internal.file.FileResolver`). Please try without using that (or any other) internal class, and see if it solves the problem. |
Comment by Gradle Forums [ 26/Nov/13 ] |
The same problem. c:\Temp\GradleBug\buildSrc\src\main\java\IOTask.java import java.io.File; public class IOTask private Object from; @TaskAction public IOTask from(Object sourcePath) { this.from = sourcePath; return this; } } |
Comment by Per Agerbæk [ 18/Mar/14 ] |
Same problem in 1.11. Had to add commons-io to classpath in buildscript. |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Benjamin Muschko [ 24/Jan/17 ] |
Gradle 2.14 changed the behavior. For more details see the release notes. |