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

Make shadowJar task cacheable #524

Merged
merged 5 commits into from
Nov 10, 2019
Merged

Make shadowJar task cacheable #524

merged 5 commits into from
Nov 10, 2019

Conversation

ghale
Copy link
Contributor

@ghale ghale commented Oct 29, 2019

These changes make the shadowJar task compatible with the build cache.

The task will still be cacheable if any of the following transformers are used:

  • AppendingTransformer
  • XmlAppendingTransformer
  • ServiceFileTransformer
  • GrroovyExtensionModuleTransformer

But the other out-of-the-box transformers are not cacheable yet (if they are added, the task will be marked as un-cacheable) but I can add caching for those with a future PR. User-defined transformers will also make the task un-cacheable unless they declare the inputs of the transformer and annotate it with @CacheableTransformer.

Similarly, SimpleRelocator has been marked as cacheable, but any custom relocators will disable caching unless the class is annotated with @CacheableRelocator.

We've seen fairly significant task execution times for projects with large dependency graphs, so making this task usable with the build cache could provide a decent performance improvement.

Please pay special attention to the test coverage and let me know if there are any potential edge cases not covered. I'm happy to discuss anything if it doesn't make sense or seems wrong.

@johnrengelman johnrengelman merged commit 57a26d6 into GradleUp:master Nov 10, 2019
@johnrengelman johnrengelman added this to the 5.2.0 milestone Nov 10, 2019
cbeams added a commit to cbeams/bisq that referenced this pull request Nov 19, 2019
After the upgrade from Gradle 4.10.2 to 5.6.4 in commit 5fe71fa,
all of Bisq's shadowJar tasks started failing Gradle's incremental build
checks. This meant that repeated invocations of `gradle build` went from
a handful of seconds to more than a minute, because shadowJar tasks had
to be re-executed on every build.

For example, with --info enabled, one would see entries like this in the
build output:

    > Task :seednode:shadowJar
    Custom actions are attached to task ':seednode:shadowJar'.
    Caching disabled for task ':seednode:shadowJar' because:
      Caching has not been enabled for the task
    Task ':seednode:shadowJar' is not up-to-date because:
      Output property 'archiveFile' file [...]libs/seednode.jar has changed.

This problem was solved by in GradleUp/shadow#524 and made
available in the project's recent 5.0.2 release. This patch simply bumps
the shadow plugin version to that value, and gets us back to snappy
incremental builds, e.g.:

    $ gradle build

    BUILD SUCCESSFUL in 7s
cbeams added a commit to cbeams/bisq that referenced this pull request Nov 19, 2019
After the upgrade from Gradle 4.10.2 to 5.6.4 in commit 5fe71fa,
all of Bisq's shadowJar tasks started failing Gradle's incremental build
checks. This meant that repeated invocations of `gradle build` went from
a handful of seconds to more than a minute, because shadowJar tasks had
to be re-executed on every build.

For example, with --info enabled, one would see entries like this in the
build output:

    > Task :seednode:shadowJar
    Custom actions are attached to task ':seednode:shadowJar'.
    Caching disabled for task ':seednode:shadowJar' because:
      Caching has not been enabled for the task
    Task ':seednode:shadowJar' is not up-to-date because:
      Output property 'archiveFile' file [...]libs/seednode.jar has changed.

This problem was solved by in GradleUp/shadow#524 and made
available in the project's recent 5.0.2 release. This patch simply bumps
the shadow plugin version to that value, and gets us back to snappy
incremental builds, e.g.:

    $ gradle build

    BUILD SUCCESSFUL in 7s
cbeams added a commit to cbeams/bisq that referenced this pull request Nov 19, 2019
After the upgrade from Gradle 4.10.2 to 5.6.4 in commit 5fe71fa,
all of Bisq's shadowJar tasks started failing Gradle's incremental build
checks. This meant that repeated invocations of `gradle build` went from
a handful of seconds to more than a minute, because shadowJar tasks had
to be re-executed on every build.

For example, with --info enabled, one would see entries like this in the
build output:

    > Task :seednode:shadowJar
    Custom actions are attached to task ':seednode:shadowJar'.
    Caching disabled for task ':seednode:shadowJar' because:
      Caching has not been enabled for the task
    Task ':seednode:shadowJar' is not up-to-date because:
      Output property 'archiveFile' file [...]libs/seednode.jar has changed.

This problem was solved by in GradleUp/shadow#524 and made
available in the project's recent 5.0.2 release. This patch simply bumps
the shadow plugin version to that value, and gets us back to snappy
incremental builds, e.g.:

    $ gradle build

    BUILD SUCCESSFUL in 7s
Comment on lines +194 to +212
@Input
String getPattern() {
return pattern
}

@Input
String getPathPattern() {
return pathPattern
}

@Input
String getShadedPattern() {
return shadedPattern
}

@Input
String getShadedPathPattern() {
return shadedPathPattern
}
Copy link
Member

@Goooler Goooler Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghale

These getters are immutable and unused, can we remove them? I'm planning to remove them and migrate includes and excludes to org.gradle.api.provider.SetProperty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if these are being removed in favor of property objects, then yes, these can be removed. They were only added in order to expose the inputs from the relocator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, the new property objects should also be exposed as inputs (i.e. a getter with an @Input annotation) in order to maintain proper cacheability after these are removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you take a review for #1079?

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

Successfully merging this pull request may close these issues.

3 participants