[JAVA] Copy dependent jars in Gradle 5

It stopped working after using Gradle 5

I cherished the clarinet I got from my dad. Do, Re, Mi, Fa, So, La, and Shi aren't there. Okay, calm boy. ** The one you have in your mouth is a chikuwa. ** **

By the way, broken without doing anything is a common story, and although it usually does something, the most common pattern is aside. ** "I just did XX, but it broke" **.

In my case, I set Gradle to 5 and rewrote build.gradle, so it seems difficult to insist that I haven't done anything.

Where did it get stuck? This is a copy task for externally dependent jars.

Original source code

build.gradle


task copyDependencies(type:Copy) {
    new File('libs').mkdirs()
    copy {
        from configurations.runtime
        into 'libs'
    }
}

It is a task to copy the dependent jar to the libs folder normally. This suddenly stopped spitting out any jars.

What did you edit?

The compile of dependencies was deprecated, so I replaced it with ╩╗implementatin`. Replace all files with EmEditor. I'm masculine to do. I wonder if Han, not a man, is me.

build.gradle


dependencies {
	implementation project (':hoge')
	implementation project (':fuga')
	implementation project (':piyo')

	implementation(
		  'commons-io:commons-io:2.5'
		, 'org.apache.commons:commons-lang3:3.5'
		, 'ch.qos.logback:logback-core:1.2.3'
		, 'ch.qos.logback:logback-classic:1.2.3'

Well, the cause is, of course, because I rewrote it to ╩╗implementation`. I wonder if it is natural to say that it is natural because the propagation range of dependence has changed.

And of course I'm in trouble. You're in trouble when you release it. It took me a long time to find a solution, so if I write it in Qiita, I might be able to reduce somebody's wasted man-hours, which would be nice.

Is there too much bad writing? ** No, I wrote on Qiita without taking a break. Talk about yourself not what you hate but what you like! (Unknown) **

The copy task was rewritten

If you're looking for ** configurations.implementation **, you'll find ** runtimeClasspath **.

build.gradle


task copyDependencies(type:Copy) {
    new File('libs').mkdirs()
    copy {
        from configurations.runtimeClasspath
        into 'libs'
    }
}

It was just this story.

Recommended Posts

Copy dependent jars in Gradle 5
Jigsaw notes in Gradle
Spring Boot 2 multi-project in Gradle
Control tasks performed in Gradle
Generate a single executable jar with dependent libraries in Gradle 4.9
Deep copy collection in Java
Popular trends in gradle and maven
Automatically specify version in gradle project
Do HelloWorld in Java / IntelliJ / Gradle
How to run Ant in Gradle
Make multi-project executable JAR in Gradle
Browse local Maven artifacts in Gradle
Implement Spring Boot application in Gradle
About file copy processing in Java
Hello world in Java and Gradle
(Note) Get a set of dependent library jars with the help of Gradle