I need the com.sun.tools jar as a compile dependency, so I just copied it to my libs folder in my Intellij project. However, I'm trying to use gradle. I only need it as a dependency for ONE of my modules. How do I do this. I currently have this in my module jar task:
jar {
from('build/classes/main/')
from('libs/tools.jar')
manifest {
attributes 'Manifest-Version': '1.0',
'Class-Path': configurations.runtime.files.collect {"../lib/${it.name}" },
}
I also tried this in my module's "dependencies" closure:
compile fileTree(dir: 'lib', include: '*.jar')
I also just tried putting the jar on my entire project classpath and it's still not compiling:
classpath ":tools"
Maybe it's correct but my IDE isn't refreshing correctly? I have the plugin already
apply plugin: 'idea'
and it's been working perfectly until I try to do this.
EDIT: it's for an annotation processor, so I'm trying to include it in my module jar build and not have other modules depend on it. Is there a better way to do it than copying the jar?
The "buildscript" configuration section is for gradle itself (i.e. changes to how gradle is able to perform the build). So this section will usually include the Android Gradle plugin. Follow this answer to receive notifications.
A configuration is simply a named set of dependencies. The compile configuration is created by the Java plugin. The classpath configuration is commonly seen in the buildSrc {} block where one needs to declare dependencies for the build. gradle, itself (for plugins, perhaps).
There is a way to express dependency on tools.jar without copying the jar:
dependencies {
compile files("${System.getProperty('java.home')}/../lib/tools.jar")
}
Intellij 2017.1 is able to recognize and import it as a module dependency without issues.
It only works when run on JDK though, as bare JRE has no tools.jar included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With