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

Support configuration cache #387

Closed
wyhasany opened this issue Mar 28, 2021 · 16 comments
Closed

Support configuration cache #387

wyhasany opened this issue Mar 28, 2021 · 16 comments

Comments

@wyhasany
Copy link

Newest version of axion-release-plugin doesn't support configuration cache. Here you can see why it fails:

./gradlew currentVersion --configuration-cache
2 problems were found storing the configuration cache, 1 of which seems unique.
- Task `:currentVersion` of type `pl.allegro.tech.build.axion.release.OutputCurrentVersionTask`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/6.8.3/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

Both problems are related with using Project during task execution:
image
image

Here you can see how to resolve typical problems with using Project inside a task:
https://docs.gradle.org/6.8.3/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

It's also related to that issue:
gradle/gradle#13490

@bgalek
Copy link
Member

bgalek commented Mar 28, 2021

@wyhasany thx for pointing it out, I'll fix this

@bgalek
Copy link
Member

bgalek commented Mar 28, 2021

It will take a while, almost every tasks uses project to reconfigure some properties at runtime ;(

@bgalek
Copy link
Member

bgalek commented Mar 28, 2021

did older version work ok?

@wyhasany
Copy link
Author

To be honest I don't know. I've tested it only with newest version. However I don't think so :)

@bgalek
Copy link
Member

bgalek commented Mar 29, 2021

I think so too. Please be assured that from now on we'll refactor each task to support configuration cache during regular development!

@cloudshiftchris
Copy link
Contributor

cloudshiftchris commented May 18, 2022

...as of 1.13.6 the following tasks fail when doing 'release':

- Task `:release` of type `pl.allegro.tech.build.axion.release.ReleaseTask`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/7.4.2/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
- Task `:verifyRelease` of type `pl.allegro.tech.build.axion.release.VerifyReleaseTask`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/7.4.2/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

@cloudshiftchris
Copy link
Contributor

cloudshiftchris commented Jun 1, 2022

@bgalek starting to look through this one. Worked through a simple slice below to illustrate the nature of required changes. Biggest challenge is maintaining VersionConfig compatibility with existing users while migrating to managed properties. Will see what options (if any) exist to accomplish that.

Primary activity to make tasks configuration-cache compatible is to remove use of 'project'.

One slice for LocalOnlyResolverFactory (nested in GradleAwareContext):

// existing code: pl.allegro.tech.build.axion.release.infrastructure.config.LocalOnlyResolverFactory
static LocalOnlyResolver create(Project project, VersionConfig config) {
    boolean baseValue = project.hasProperty(LOCAL_ONLY) || config.localOnly
    return new LocalOnlyResolver(baseValue)
}

// changes to remove project dependency (using managed properties)

// in plugin, maintain reference to versionConfigExtension
def versionConfigExtension = project.extensions.create(VERSION_EXTENSION, VersionConfig, project)

// where localOnly is Property<Boolean>; convention sets its default (plugin consumers can optionally set a value, if not set the convention will be used)
versionConfigExtension.localOnly.convention(project.hasProperty(LOCAL_ONLY) )


// in VersionConfig
// BREAKING CHANGE if done this way, changes type of variable;
// consumers would need to do localOnly.set(true) vs localOnly = true
// need to investigate compatibility options to not break existing users of these properties, while migrating to managed properties
@Input
def Property<Boolean> localOnly;

// in tasks (code is partway there already)
@Nested
def VersionConfig versionConfig;

// in task execution method; note that property is only resolved via get() when required

def localOnlyResolver = new LocalOnlyResolver(versionConfig.localOnly.get())

// ... use localOnlyResolver

... in the end, the same result is achieved: create a LocalOnlyResolver based on the resolved configuration at execution time.

@cloudshiftchris
Copy link
Contributor

Looks like this will be clean for Groovy consumers, but not for Kotlin consumers of the plugin:

Note that Gradle Groovy DSL generates setter methods for each Property-typed property in a task implementation. These setter methods allow you to configure the property using the assignment (=) operator as a convenience.

In Kotlin DSL, the set() method on the property needs to be used instead of =.

(from: https://docs.gradle.org/current/userguide/lazy_configuration.html#lazy_configuration)

Thoughts on best release target to tackle this partially-breaking change?

@bgalek
Copy link
Member

bgalek commented Jun 1, 2022

@cloudshiftchris I'm ok with 1.14.0 release with realse notes explaining what people need to change

@cloudshiftchris
Copy link
Contributor

Excellent. Into this now, it will take a bit to wade through it all.

cloudshiftchris added a commit to cloudshiftinc/axion-release-plugin that referenced this issue Jun 3, 2022
cloudshiftchris added a commit to cloudshiftinc/axion-release-plugin that referenced this issue Jun 3, 2022
bgalek added a commit that referenced this issue Aug 3, 2022
* #387 Gradle configuration cache compatibility

* #387 attempt to fix mysterious CI build failure

* fixing maven jar publication problems

* Update ci.yml

* fixing maven jar publication problems

* fixing maven jar publication problems

* Update build.gradle

* setAutomatedPublishing set to default (true) (#486)

* MavenPublication artifact changed

* publishing artifact configuration changed

* Bump mkdocs-material from 8.2.16 to 8.3.2 (#485)

Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.2.16 to 8.3.2.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@8.2.16...8.3.2)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update README.md

* Update README.md

* fix: customize pom, not create another publication (#487)

* Update publish.yml

* Implement #480: handle empty overriddenBranchName same as not set (#489)

* Bump pl.allegro.tech.build.axion-release from 1.13.9 to 1.13.14 (#496)

Bumps [pl.allegro.tech.build.axion-release](https://github.com/allegro/axion-release-plugin) from 1.13.9 to 1.13.14.
- [Release notes](https://github.com/allegro/axion-release-plugin/releases)
- [Commits](v1.13.9...v1.13.14)

---
updated-dependencies:
- dependency-name: pl.allegro.tech.build.axion-release
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mkdocs-material from 8.3.2 to 8.3.4 (#494)

Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.3.2 to 8.3.4.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@8.3.2...8.3.4)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mkdocs-material from 8.3.4 to 8.3.6 (#498)

Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.3.4 to 8.3.6.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@8.3.4...8.3.6)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* GH-490 Support encoding in `fileUpdate` hook (Fix #490) (#493)

* Bump com.coditory.integration-test from 1.4.0 to 1.4.2 (#508)

Bumps com.coditory.integration-test from 1.4.0 to 1.4.2.

---
updated-dependencies:
- dependency-name: com.coditory.integration-test
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mkdocs-material from 8.3.6 to 8.3.9 (#504)

Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.3.6 to 8.3.9.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@8.3.6...8.3.9)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump objenesis from 3.2 to 3.3 (#514)

Bumps [objenesis](https://github.com/easymock/objenesis) from 3.2 to 3.3.
- [Release notes](https://github.com/easymock/objenesis/releases)
- [Commits](easymock/objenesis@3.2...3.3)

---
updated-dependencies:
- dependency-name: org.objenesis:objenesis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mkdocs from 1.3.0 to 1.3.1 (#512)

Bumps [mkdocs](https://github.com/mkdocs/mkdocs) from 1.3.0 to 1.3.1.
- [Release notes](https://github.com/mkdocs/mkdocs/releases)
- [Commits](mkdocs/mkdocs@1.3.0...1.3.1)

---
updated-dependencies:
- dependency-name: mkdocs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump org.jetbrains.kotlin.jvm from 1.4.0 to 1.7.10 (#507)

Bumps [org.jetbrains.kotlin.jvm](https://github.com/JetBrains/kotlin) from 1.4.0 to 1.7.10.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.7.10/ChangeLog.md)
- [Commits](JetBrains/kotlin@v1.4.0...v1.7.10)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin.jvm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump sshd-git from 2.8.0 to 2.9.0 (#511)

Bumps [sshd-git](https://github.com/apache/mina-sshd) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/apache/mina-sshd/releases)
- [Changelog](https://github.com/apache/mina-sshd/blob/master/CHANGES.md)
- [Commits](apache/mina-sshd@sshd-2.8.0...sshd-2.9.0)

---
updated-dependencies:
- dependency-name: org.apache.sshd:sshd-git
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump sshd-core from 2.8.0 to 2.9.0 (#513)

Bumps [sshd-core](https://github.com/apache/mina-sshd) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/apache/mina-sshd/releases)
- [Changelog](https://github.com/apache/mina-sshd/blob/master/CHANGES.md)
- [Commits](apache/mina-sshd@sshd-2.8.0...sshd-2.9.0)

---
updated-dependencies:
- dependency-name: org.apache.sshd:sshd-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: Chris Lee <chris@cloudshiftconsulting.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Artur Frysiak <artur@frysiak.net>
Co-authored-by: David <david0@users.noreply.github.com>
Co-authored-by: Dzikoysk <dzikoysk@dzikoysk.net>
@mateuszkwiecinski
Copy link

mateuszkwiecinski commented Apr 15, 2023

Seeing this issue is still opened, I'll share that I started observing the plugin throwing an error when running with Gradle 8.1 (which has the Configuration Cache feature stabilized)

I apply plugin within my own convention plugin:

class VersioningPlugin : Plugin<Project> {

    override fun apply(target: Project): Unit = with(target) {
        if (this != rootProject) throw GradleException("Versioning plugin can be applied to the root project only")
        pluginManager.apply(ReleasePlugin::class.java)

        val scmConfig = extensions.getByType<VersionConfig>()

        allprojects { project ->
            project.version = scmConfig.version
        }
    }

which should somewhat transform into what Basic Usage section presents.

The error is

FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

2 problems were found storing the configuration cache.
- Plugin 'com.starter.versioning': external process started '/usr/local/bin/git --version'
  See https://docs.gradle.org/8.1/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Plugin 'com.starter.versioning': external process started '/usr/local/bin/git config --system --show-origin --list -z'
  See https://docs.gradle.org/8.1/userguide/configuration_cache.html#config_cache:requirements:external_processes

See the complete report at file://{project_path}/build/reports/configuration-cache/bw6o1r9owtj2rruhd9167sy1u/663y7tyiq194f3u0xfz72ugjn/configuration-cache-report.html
> Starting an external process '/usr/local/bin/git --version' during configuration time is unsupported.
> Starting an external process '/usr/local/bin/git config --system --show-origin --list -z' during configuration time is unsupported.

+

one of stacktraces from `configuration-cache-report.html`
org.gradle.api.InvalidUserCodeException: Starting an external process '/usr/local/bin/git --version' during configuration time is unsupported.
	at org.gradle.configurationcache.initialization.DefaultConfigurationCacheProblemsListener.onExternalProcessStarted(ConfigurationCacheProblemsListener.kt:87)
	at org.gradle.configurationcache.InstrumentedInputAccessListener.externalProcessStarted(InstrumentedInputAccessListener.kt:110)
	at org.gradle.internal.classpath.Instrumented.externalProcessStarted(Instrumented.java:501)
	at org.gradle.internal.classpath.Instrumented.externalProcessStarted(Instrumented.java:509)
	at org.gradle.internal.classpath.Instrumented.start(Instrumented.java:363)
	at org.eclipse.jgit.util.FS.readPipe(FS.java:1379)
	at org.eclipse.jgit.util.FS.readPipe(FS.java:1341)
	at org.eclipse.jgit.util.FS.discoverGitSystemConfig(FS.java:1530)
	at org.eclipse.jgit.util.FS.getGitSystemConfig(FS.java:1627)
	at org.eclipse.jgit.util.SystemReader$Default.openSystemConfig(SystemReader.java:86)
	at org.eclipse.jgit.util.SystemReader.getSystemConfig(SystemReader.java:363)
	at org.eclipse.jgit.util.SystemReader.getUserConfig(SystemReader.java:311)
	at org.eclipse.jgit.internal.storage.file.FileRepository.<init>(FileRepository.java:161)
	at org.eclipse.jgit.lib.BaseRepositoryBuilder.build(BaseRepositoryBuilder.java:625)
	at org.eclipse.jgit.api.Git.open(Git.java:93)
	at org.eclipse.jgit.api.Git.open(Git.java:73)
	at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.<init>(GitRepository.java:70)
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:72)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
	at org.gradle.internal.classpath.intercept.CallInterceptorsSet$DecoratingCallSite.access$401(CallInterceptorsSet.java:128)
	at org.gradle.internal.classpath.intercept.CallInterceptorsSet$DecoratingCallSite$4.callOriginal(CallInterceptorsSet.java:180)
	at org.gradle.internal.classpath.intercept.CallInterceptorsSet$1.doIntercept(CallInterceptorsSet.java:54)
	at org.gradle.internal.classpath.intercept.CallInterceptorsSet$DecoratingCallSite.callConstructor(CallInterceptorsSet.java:177)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)
	at pl.allegro.tech.build.axion.release.infrastructure.di.ScmRepositoryFactory.create(ScmRepositoryFactory.groovy:23)
	at pl.allegro.tech.build.axion.release.infrastructure.di.ScmRepositoryFactory$create.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
	at pl.allegro.tech.build.axion.release.infrastructure.di.VersionResolutionContext.create(VersionResolutionContext.groovy:43)
	at pl.allegro.tech.build.axion.release.infrastructure.di.VersionResolutionContext$create.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
	at pl.allegro.tech.build.axion.release.infrastructure.di.VersionSupplier.resolve(VersionSupplier.groovy:10)
	at pl.allegro.tech.build.axion.release.infrastructure.di.VersionSupplier$resolve.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
	at pl.allegro.tech.build.axion.release.infrastructure.di.MemoizedVersionSupplier.resolve(VersionSupplier.groovy:25)
	at pl.allegro.tech.build.axion.release.infrastructure.di.MemoizedVersionSupplier$resolve.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
	at pl.allegro.tech.build.axion.release.domain.VersionConfig$_versionProvider_closure4.doCall(VersionConfig.groovy:221)
	at pl.allegro.tech.build.axion.release.domain.VersionConfig$_versionProvider_closure4.doCall(VersionConfig.groovy)

The stacktrace points at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.<init>(GitRepository.java:70) as the offender.
Related gradle docs: https://docs.gradle.org/8.1/userguide/configuration_cache.html#config_cache:requirements:external_processes

The interesting part is I don't observe the error at every run, it pops up at occasionally (a guess: when gradle tries to create new configuration cache entry?)

@ikstewa
Copy link

ikstewa commented Jul 14, 2023

Any update on this? axion-release-plugin is currently blocking us from enabling configuration cache.

@ikstewa
Copy link

ikstewa commented Jul 18, 2023

I'm able to consistently reproduce the configuration cache problem by stopping the gradle daemon beforehand:

./gradlew --stop && ./gradlew currentVersion

The issue appears to stem from JGit attempting to load the system config. You can disable this feature in JGit using the GIT_CONFIG_NOSYSTEM environment variable. Using the reproducer above this now successfully supports the configuration cache:

./gradlew --stop && GIT_CONFIG_NOSYSTEM=true ./gradlew currentVersion

@bgalek
Copy link
Member

bgalek commented Nov 27, 2023

I have not yet found any time to do this fix, I'll appreciate a PR :)

@bgalek
Copy link
Member

bgalek commented Nov 28, 2023

Hope to release with a fix soon

@bgalek bgalek closed this as completed Feb 16, 2024
@artemptushkin
Copy link

@bgalek @SmialyKot are you sure this is fixed? I got this on 1.7.0

Calculating task graph as configuration cache cannot be reused because file '.git/config' has changed.

having only axion in place, if I remove it - I don't have this issue anymore

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

No branches or pull requests

6 participants