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

artifactory plugin usage with conventions plugin (buildSrc) #71

Open
TheBatOutOfHell opened this issue Sep 25, 2023 · 1 comment
Open
Labels
question Further information is requested

Comments

@TheBatOutOfHell
Copy link

TheBatOutOfHell commented Sep 25, 2023

How can we help?

Hello!

I am working on different projects with multiple artifacts (usually war and jar) which I all have configured similarly as multi module projects with a root project. And we are using artifactory plugin. In a recent question in Gradle Forum recommendations were to use conventions plugin to share logic between subprojects instead of allprojects { ... } or subprojects { ... } blocks. But I cannot get the artifactory configuration to work within the buildSrc-setup.

My Setup before adding buildSrc module was like:

root
build.xml
settings.gradle
-- warproject
    build.xml
    settings.gradle
-- jarproject
    build.xml
    settings.gradle
...

So my initial working setup for the artifactory plugin was:

in root project build.xml I have somethings like:

plugins {
  id 'com.jfrog.artifactory' version 5.+ apply true
}
artifactoryPublish.skip = true
artifactory {
    contextUrl = settings_url
    publish {
        repository {
            username = settings_user
            password = settings_pwd
        }
        defaults {
            publications('mavenJava')
            publishPom = true
        }
       version = version.replaceAll('SNAPSHOT', LocalDateTime.now().format('yyyyMMddHHmmss'))
    }

One problem I had with this was, that setting the version this way (last line in the script) did not work for the subprojects. version always endet up as "SNAPSHOT".
Now my solution in suprojects basically was overriding the version setting in subprojects:

plugins {
  id 'com.jfrog.artifactory' apply true
}

artifactory {
  publish {
    version = version.replaceAll(...)
  }
}

So one question (out of context) would be: is there a better solution to set the version?

But to the point:
I set up a buildSrc module with some working configurations. I then wanted to move artifactory closure to the myproject.conventions.gradle file. There is no error upon running artifactoryPublish, but it is also not deploying any artifacts.

So my core question: What would be the recommended way of or is there some example how to setup artifactory plugin with conventions plugin mechanism?

Thx.
Rob

@TheBatOutOfHell TheBatOutOfHell added the question Further information is requested label Sep 25, 2023
@TheBatOutOfHell
Copy link
Author

Seems that I was able to solve both the deployment and version issues by just placing the version = ... part in an afterEvaluate { ... } block and removing the overrides in the child project altogether.

So now I only have artifactory { ... } configuration in buildSrc groovy script and no additional artifactory config for any of the projects... just applying conventions plugin where needed...

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

1 participant