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

mavenBom doesn't obey cacheChangingModulesFor for -SNAPSHOT bom #38

Closed
flozano opened this issue Mar 2, 2015 · 9 comments
Closed

mavenBom doesn't obey cacheChangingModulesFor for -SNAPSHOT bom #38

flozano opened this issue Mar 2, 2015 · 9 comments

Comments

@flozano
Copy link

flozano commented Mar 2, 2015

I have

        project.configurations.all {
            // check for updates every build
            resolutionStrategy {
                failOnVersionConflict()
                cacheChangingModulesFor 0, 'seconds'
            }
        }
/* ... */
        project.subprojects {
            repositories {
                maven {
                    // custom maven repo
                    url maven_repository
                    credentials {
                        username = maven_username
                        password = maven_password
                    }
                }
            }
            dependencyManagement { imports { mavenBom 'com.mycompany:bom-parent:'+version } }
        }

(where 'version' is something like 1.2.3-SNAPSHOT).

However, when the BOM is already in the gradle cache, gradle doesn't try to re-download again, even if there is a new SNAPSHOT version in the repository.

@flozano flozano changed the title mavenBom doesn't ovey cache instruction mavenBom doesn't obey cacheChangingModulesFor for -SNAPSHOT bom Mar 2, 2015
@effiban
Copy link

effiban commented Mar 2, 2015

I encountered the same issue - it seems that the 'resolutionStrategy' doesn't apply to the BOM. Not sure if this is a Gradle limitation or a plugin limitation

@flozano
Copy link
Author

flozano commented Mar 2, 2015

wow that was fast 👍

We've found out that the plugin actually obeys the --refresh-dependencies gradle command-line parameter, but it's a pain to change all builds to do that.

@wilkinsona
Copy link
Contributor

The plugin uses detached configurations. One for "global" dependency management that applies to every configuration and then separate configurations for each configuration-specific dependency management. The detached configurations aren't added to the configuration container so they're not in project.configurations.all – as a result your resolution strategy isn't applied to them.

I chose to use detached configurations as I wanted to avoid "cluttering up" people's builds with, what I had considered to be, an implementation detail of the plugin. I think your requirement to control the caching behaviour shows that it's not just an implementation detail. It would be quite straightforward to stop using detached configurations and expose them named something like globalDependencyManagement and <configuration>DependencyManagement

Thoughts?

@flozano
Copy link
Author

flozano commented Mar 2, 2015

I think it would be useful that those configurations are exposed, as long as their names are clearly identifiable as 'coming from dependency management plugin'.

In our workflow, depending on a -SNAPSHOT bom during development is essential, so we definitely need control over the cache of that artifact.

Something to think about is also that these "configurations" then become part of the plugin surface / API, and backward compatibility over them should be considered.

@wilkinsona
Copy link
Contributor

It would be quite straightforward to stop using detached configurations and expose them

I spoke too soon. There are some significant implementation benefits to treating the configuration(s) used to resolve imported boms separately, for example it makes it trivial to stop the plugin from trying to provide dependency management for its own configurations.

In our workflow, depending on a -SNAPSHOT bom during development is essential, so we definitely need control over the cache of that artifact.

I'll expose some other mechanism for configuring cacheChangingModulesFor and cacheDynamicVersionsFor for imported boms.

@flozano
Copy link
Author

flozano commented Mar 2, 2015

That would work perfectly, thank you!

@wilkinsona
Copy link
Contributor

The resolutionStrategy for any configuration that's created by the plugin can now be configured. For example:

dependencyManagement {
    resolutionStrategy {
        cacheChangingModulesFor 0, 'seconds'
    }
}

@flozano If you have a moment, please try 0.4.1.BUILD-SNAPSHOT available from https://repo.spring.io/plugins-snapshot.

@flozano
Copy link
Author

flozano commented Mar 3, 2015

Tried and seems to work:

Cached resource is up-to-date (lastModified: Mon Mar 02 22:30:36 CET 2015). [HTTP: https://maven.mycompany.com/artifactory/repo/com/mycompany/platform/platform-common-parent/1.2.3-SNAPSHOT/platform-common-parent-1.2.3-20150302.212906-159.pom]
Cached resource is up-to-date (lastModified: Mon Mar 02 22:30:35 CET 2015). [HTTP: https://maven.mycompany.com/artifactory/repo/com/mycompany/platform/platform-parent/1.2.3-SNAPSHOT/platform-parent-1.2.3-20150302.212906-160.pom]
Cached resource is up-to-date (lastModified: Mon Mar 02 22:30:35 CET 2015). [HTTP: https://maven.mycompany.com/artifactory/repo/com/mycompany/platform/platform-parent/1.2.3-SNAPSHOT/platform-parent-1.2.3-20150302.212906-160.pom]
Cached resource is up-to-date (lastModified: Mon Mar 02 22:30:36 CET 2015). [HTTP: https://maven.mycompany.com/artifactory/repo/com/mycompany/platform/platform-common-parent/1.2.3-SNAPSHOT/platform-common-parent-1.2.3-20150302.212906-159.pom]

However, #39 now happens even without --refresh-dependencies. I will keep trying to isolate that.

@wilkinsona
Copy link
Contributor

Thanks for trying out the snapshot

However, #39 now happens even without --refresh-dependencies.

That's reassuring in a way. From the plugin's perspective the behaviour should be the same as both have the effect of disabling caching.

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

No branches or pull requests

3 participants