jar.dependsOn(myOtherJar) // This is creating another jar in build/libs
However here is the tricky part. I have the following function. which collects all the jars besides the myOtherJar and I dont know why? This one configurations.testRuntime.allArtifacts collects all the jar besides myOtherJar however I made sure that all the jars are in src/build/libs. It only picks one but not the other
task linkToBin(dependsOn: jar) {
doLast{
File installDir = new File(rootProject.projectDir.getPath() + "/install/bin")
installDir.mkdirs()
configurations.testRuntime.allArtifacts.files.forEach { // Every jar reaches here besides myOtherJar
Path targetPath = Paths.get(installDir.getPath() + '/' + it.getName())
if(new File(targetPath.toString()).exists())
Files.delete(targetPath)
Files.createSymbolicLink(targetPath, Paths.get(it.getPath()))
}
}
}
Hi Thanks for the response. That helped to some extent. It did move all the jars to linkToBin Area however it also created another problem which is when I run my anchorHttpServerJar by running the following command java -jar anchor_echo_http_server-1.0.jar it still runs the main class under the jar block (com.hello.echoserver.AnchorEchoServer) instead of running com.hello.httpserver.AnchorHttpServer? any idea? I also dont know why anchor_echo_http_server-1.0.jar is getting created instead anchor_echo_http_server-1.0-SNAPSHOT.jar. There seems to be some conflict. isn’t it?