Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 20386

How to copy a folder from a dependent External Library's jar into the gradle project's jar?

$
0
0

@jendrik thanks fro your reply!

i tried this but it isn’t working ->

My gradle project has an external dependency. I want to include a class file from external dependency into my gradle project’s jar.

This class file “test.class” lives in a subdirectory within “my-lib.jar”.

This is my build.gradle:

dependencies {
    compile 'org.apache.commons:commons-lang3:3.9'
    testCompile 'my-lib'
}

jar {
    manifest {
        attributes("Implementation-Title": "com.my.modules#${project.name};${project.version}",
                "Implementation-Version": "${project.version}")
    }
	
	// this works but copies everything->
	from provider {
        zipTree(configurations.compileClasspath.filter {
            it.name == 'commons-lang3-3.9.jar'
        }.getAsPath())
    }
	
	// this doesn't ->
	from provider {
        zipTree(configurations.compileClasspath.filter {
            it.name == 'my-lib.jar'
        }.getAsPath())
    }
	
	// this doesn't either ->
	from provider {
        zipTree(configurations.testCompile.filter {
            it.name == 'my-lib.jar'
        }.getAsPath())
    } 
}

This is the error I’m getting:

Could not determine the dependencies of task ':jar'.
> path may not be null or empty string. path=''

How can I do this essentially?

Copy test.class from externaldependency my-lib.jar into my jar


Viewing all articles
Browse latest Browse all 20386

Trending Articles