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

How do I save the transformed module so it can be deployed? #139

Closed
dahuber-github opened this issue Sep 12, 2024 · 2 comments
Closed

How do I save the transformed module so it can be deployed? #139

dahuber-github opened this issue Sep 12, 2024 · 2 comments
Labels
question Further information is requested

Comments

@dahuber-github
Copy link

First, thanks for this. This saved me serious amount of time in our product upgrade.

I need to deploy our product into a docker container. I need to include our build artifacts as well as the library dependencies. When I use this tool to transform a dependency, my output folder (dependencies) is get the original jar (un-transformed) as output.

I'm doing something like this....

configurations {
  localApi
  localImplementation
}

dependencies {

  localApi (group: 'com.google.guava', name: 'guava', version: '33.2.1-jre')
  ...

  localImplementation (group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.17.1')
  ...

  /* This is the magic to include the local configuration into the actual path */
  configurations.api.extendsFrom(configurations.localApi)
  configurations.implementation.extendsFrom(configurations.localImplementation)
}

task copyToDependencies(type: Copy) {
	delete "$buildDir/dependencies"

    into "$buildDir/dependencies"
    from configurations.localApi
    from configurations.localImplementation
}
copyToDependencies.mustRunAfter Jar

Thank you for your help.

@jjohannes
Copy link
Member

Thank you for your interest in the plugin. For custom Configurations, such as your localImplementation and localApi, you need to set the attribute javaModule = true in order to activate the plugin's functionality. This is the reverse of what the Readme describes here.

In your case, it should look roughly like this:

configurations {
    localApi {
        attributes { attribute(Attribute.of("javaModule", Boolean), true) }
        attributes { attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME)) }
    }
}

Since you did not use attributes on your custom Configurations before, you use legacy Gradle behavior. That's why you most likely also need to set the Usage attribute (it may work without that line).


There is an open feature request to add a simpler configuration option for this which we will add in a future version. Then I'll also extend the Readme to cover this better.

@jjohannes jjohannes added the question Further information is requested label Sep 13, 2024
@dahuber-github
Copy link
Author

That fixed it. Thank you for your help and for creating such a useful plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants