Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin won't include a jar in another jar? #319

Closed
Sushisource opened this issue Aug 23, 2017 · 5 comments · Fixed by #1233
Closed

Plugin won't include a jar in another jar? #319

Sushisource opened this issue Aug 23, 2017 · 5 comments · Fixed by #1233
Labels

Comments

@Sushisource
Copy link

Hi there. Great plugin. One problem:
I have a project with multiple subprojects. One of them is a server (cat) which contains the jar of another (agent) so that users can auto-download the client from the server when using our provided wrapper program.

I can't include the entire build scripts here, but these should be informative snippets:

In top-level build.gradle. This part works great in terms of making fat jars for all the subprojects we need and they execute OK.

subprojects { subproj ->
    // These projects need fat jars
    if (subproj.name in ["agent", "cat", "box", "commit-server"]) {
        apply plugin: 'application'
        apply plugin: 'com.github.johnrengelman.shadow'
        shadowJar {
            // Our jars are... pretty fat.
            zip64 true
            mergeServiceFiles()
            exclude 'META-INF/*.DSA'
            exclude 'META-INF/*.RSA'
            transform(AppendingTransformer.class) {
                resource = 'reference.conf'
            }
        }
    }
}

In the cat build.gradle:

sourceSets {
    main {
        resources {
            // Don't include every node module under the sun
            exclude 'node_modules/**/*'
            exclude '__tests__/**/*'
        }
    }
}

task copyAgentJar(type: Copy) {
    from project(':agent').shadowJar.archivePath
    into 'src/main/resources'
}
processResources.dependsOn(copyAgentJar)

This copy task works as expected. The agent fat jar ends up in the resources directory. The cat jar gets built with everything I expect in it except the agent jar file.

I would expect since it's just sitting there in my resources, and my resources source set by default includes everything in there except some specific things, that it'd end up in the shadow jar, but apparently no? Maybe I'm doing this in an awful way, but any tips would be much appreciated. Thanks!

Shadow Version 2.0.1

Gradle Version 4.1

Expected Behavior

agent--all.jar is included in cat.jar

Actual Behavior

It's not

@Sushisource
Copy link
Author

BTW I've managed to work around this by doing this:

shadowJar {
    doLast {
        ant.jar(update: "true", destfile: shadowJar.archivePath.path) {
            fileset(file: project(':agent').shadowJar.archivePath)
        }
    }
}

But it is quite slow

@johnrengelman
Copy link
Collaborator

try:

task copyAgentJar(type: Copy) {
    from project(path: 'agent', configuration: 'shadow')
    into 'src/main/resources'
}

@Sushisource
Copy link
Author

Doesn't seem to like that:
> Could not find method project() for arguments [{path=agent, configuration=shadow}] on task ':cat:copyAgentJar' of type org.gradle.api.tasks.Copy.

@rehevkor5
Copy link

Does it need to be path: ':agent'?

@Goooler
Copy link
Member

Goooler commented Feb 27, 2025

I believe this should be fixed by #1233.

@Goooler Goooler closed this as completed Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants