简体   繁体   中英

Is there an equivalent `mvn dependency:build-classpath` for gradle projects?

I'm looking for a command or a task that would achieve the equivalent output to maven mvn dependency:build-classpath for Gradle projects.

Here is some example output that maven produces:

/Users/test-user/.m2/repository/org/mongodb/mongodb-driver/3.4.3/mongodb-driver-3.4.3.jar:/Users/test-user/.m2/repository/org/mongodb/mongodb-driver-core/3.4.3/mongodb-driver-core-3.4.3.jar:/Users/test-user/.m2/repository/org/mongodb/bson/3.6.3/bson-3.6.3.jar:/Users/test-user/.m2/repository/junit/junit/4.8.2/junit-4.8.2.jar:/Users/test-user/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar

I don't believe there's a built-in task which does the same thing, though I'm not positive. However, you could always create your own task which prints out the classpath as a path. Here's an example using the Kotlin DSL:

tasks.register("buildClasspath") {
    val main by sourceSets
    doFirst {
        println(main.compileClasspath.asPath)
    }
}

Note: To print the runtime classpath use main.runtimeClasspath .

You can then execute:

./gradlew buildClasspath

You can use the following command to see all the dependencies.

gradle -q dependencies

You can refer below the link. https://docs.gradle.org/current/userguide/inspecting_dependencies.html#sec:listing_dependencies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM