How to get full path of maven dependency jar file?


(Sabari) #1

Hi,

I’m a newbie in gradle.

I’m trying to build a java 9 based modular application using gradle 3.5. The application has dependency on javaee-web-api-7.0.jar which gradle downloads from maven repo.
Since gradle doesn’t support module path yet, i’m trying to add the required jars into module path. Is there any way to get the complete path of the downloaded dependencies from maven to be passed to javac modulepath?


(James Justinic) #2

Here’s an example that uses a configuration called modules and will add any dependency you add there to the --modulepath. You don’t necessarily need a modules configuration, but it’s likely easier than additional logic to determine which dependencies should be on the module path. It may not do exactly what you want in your project, but the file paths will be in configurations.modules.resolvedConfiguration.files.

apply plugin: 'java'

configurations {
    modules
}

repositories {
    jcenter()
}

dependencies {
    modules 'javax:javaee-web-api:7.0'
}

compileJava {
    options.compilerArgs += ['--modulepath', "${configurations.modules.resolvedConfiguration.files.join(':')}"]
}