-
Notifications
You must be signed in to change notification settings - Fork 30
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
Uploading and releasing a multi-project build #84
Comments
First of all, publishing (uploading) and closing/releasing of a multi-project build is supported out of the box, assuming that you want to do it for all subprojects (e.g. different module of one project, not a mono repo with separate components). See our e2e test project. Nevertheless, close and release tasks are only orchestrated to Please note, however, up until #19 is implemented you need to do it (publishing and closing) in a one Gradle call. |
Well, that's a lot of ... Kotlin code. If I understood that example correctly, the nexus plugin is only applied to the root while the subprojects configure themselves with java-library, maven-publish, and sign plugins. If this is correct them all projects will be published to a staging repository from which closing & release may occur. How then must a subproject be marked to be skipped from uploading to a staging repository? |
Well, Gradle does whatever you ask it to do. If you ask it to publish all the artifacts, it does so. If you ask it to execute a subset of tasks it agrees, and it does not insist on doing all the tasks for all the projects every time 😉 Could you clarify what do you mean by "marked to be skipped"? What the plugin does is as follows: it adds a task to the root project to initialized the staging repository, then it rewrites all the URLs for all projects to point to the newly created staging repository. The singing and publishing are out of scope for |
Some people prefers that over Maven's XML ;-). We have also a complementary variant in Groovy, but just for a single module. As @vlsi already suggested, try to just call |
Good grief, what if I have more than 50+ projects (as Ikonli does). Do you expect people to: a) manually invoke :X:publishToSonatype where x = the number of projects? Again, the reason why I ask this is that the Bintray plugin handled aggregation automatically. I get it that this plugin provides the minimum building blocks to get the job done, I'm asking for convenient options that can be turned on/off when necessary. What's the point of having convention over configuration if not to avoid defining stuff over and over again? |
I'm well aware of that.
I'm well aware of that. |
@aalmiray I'm afraid, I do not fully follow your case. Do you have a multiproject build with |
That would be case b). Not all projects are publishable (for whatever reason) hence why I used the word subset in the beginning. |
Add up that some subprojects are publishable, just not to Maven Central. Could be to other Maven compatible repositories (non Nexus managed), could be a Gradle plugin (which would meet the criteria for publication but to a totally different repository). So in essence, I'd like to target just a subset of publishable subprojects with little to no configuration (conventions, let's use them) and without being forced to add custom code in build scripts (or pre compiled plugin scripts) or specifying publish targets in the command line. |
In that case, I assume there is no
and the plugin should automatically detect "publishable" subprojects, initialize the staging repository before the first artifacts upload and close/release that staging repository after the last artifacts are uploaded. |
It's somehow more complicated. We don't have that mechanism out of the box. Probably, it will be implemented once better support for monorepos is requeted (and provided). At the time being, you could try to use your own Update. If you have a good idea how we could distinguish the projects you would like to skip (without their enumeration in the project configuration or some marker property set) please let us know. |
I don't see what monorepo support has to do with this question. This is for a typical multi-project build where all subprojects reside in the same repository.
Given that the plugin already configures all projects in the build, using the extension it provides could be the way to go. Add a boolean property to mark the project for inclusion (default = true). |
In monorepos there is (might be) a need to release - on demand - only 3 projects (for example sharing some "subroot" or not) from 100, available in the whole repo, publishable projects. So, some kind of the mechanism we are talking about would problably be required.
We need to collect publishable projects in one place and synchronize the whole operation (init repo before the first upload and close/release after last). As a result this plugin is applied only in the root project and it tries to find all publishable (sub)projects. Therefore, there is no extension created in subprojects. We could try to check for some value in the |
I'm realizing that |
@aalmiray , I think you can exclude sub-module from being published to nexus by NOT applying
Then invoking @szpak , can you please confirm this ? |
Yes, but no. I do want the |
Here's a workaround for disabling the corresponding publishing tasks for the projects that should not be published to Maven Central in the build script: nexusPublishing {
repositories {
sonatype()
}
}
val nonMavenCentralProjects = listOf(
project(":a"),
project(":b")
)
nonMavenCentralProjects.forEach { subproject ->
subproject.tasks.withType<PublishToMavenRepository>().configureEach {
onlyIf {
repository.name != "sonatype"
}
}
} I agree, though, that it would be better to not create the publishing repository for those projects in the first place. I can see us adding an API to configure includes/excludes, potentially as a predicate, e.g.: nexusPublishing {
includeProjects(project(":a"), project(":b"))
includeProjects { it.name.startsWith("some-prefix") }
excludeProjects(project(":c"), project(":d"))
excludeProjects { it.name.startsWith("some-other-prefix") }
} @aalmiray Whichone would be better for your use case? @szpak WDYT? |
I'd prefer if the include/exclude lists were provided by the plugin's extension. Less code to copy around by consumers IMHO. |
So sth. like this? nexusPublishing {
includedProjects.set(mavenCentralProjects)
} |
It depends. What is If it's a list of Given the preference to defer computations as much as you can to speed up the configuration phase I'd say the predicate option would be best. You could also accept both options for those that prefer eager evaluation for whatever reason they deem necessary. And it has to be both include and exclude lists with the caveat that when both lists are defined the exclusions are taken from the inclusions. |
Ping. Wondering if the team has circled back to @marcphilipp's latest idea on this topic. |
I wonder if requiring Gradle 6.2 and moving to Shared Build Services would help here. |
The current inclusion rule is the presence of publish-plugin/src/main/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPlugin.kt Line 129 in 1c7b509
As a better solution, I would suggest moving that "withId maven-publish" into another sub-plugin. In other words: gnpp plugin (the current one): applies gnpp-base, then applies gnpp-publish to allprojects. |
I understand the current conditional on |
Would you please clarify (no trolling, really) why do you apply For instance: subprojects {
if (!name.contains("-test-")) {
apply(plugin = "maven-publish")
}
}
I think the split of GNPP would move the behavior towards all the other Gradle plugins. In other words, like with I do not say that all GNPP users have to suffer and copy-paste 100500 lines of configuration code. However, it looks like That seems to be a reasonable approach, especially in the |
The The idea is to let subprojects determine if publication should be enabled or disabled using the plugin's DSL, such as config {
publishing {
enabled = false
}
} Because of the nature of the An alternative would be to read a project property (instead of a DSL property) as this type of properties have their values visible immediately upon query, in contrast the plugin's DSL properties have not been signed a value by the developer as the plugin's Thsi is why I was interested in reading @marcphilipp's suggestion of using GNPP's existing extension (DSL) to achieve what I'm looking for. |
This is a nice catch. publish-plugin/src/main/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPlugin.kt Lines 125 to 129 in 1c7b509
On the other hand,
I have no idea how to resolve that. Gradle DSL does not allow to "freeze configuration", and it provides no way to tell "this is fully configured, you might analyze it, create tasks, etc". Frankly speaking, I am inclined that listing the plugin in
If GNPP splits plugins, then it would be useful for everybody:
Adding various include/exclude filters looks odd since it does not play well with That is why I am inclined that adding filtering to GNPP resolves a narrow use case (~ |
Perhaps I explained myself badly. The core maven-publish plugin uses There is a ticket at the Gradle issue tracker stating they want to remove And yes, so far it seems that adding includes/excludes to GNPP would benefit Kordamp directly but not so much other as no one else has brought up this concern before, have they? In which case I also wonder if indeed this should be added to GNPP or find another way in Kordamp to workaround this. |
Let me give it another try :) It looks like Gradle 5.0+ (2018-11-26) realizes publications eagerly: https://github.com/gradle/gradle/blob/39a81fc5e1eed33b98ef4e2561db54e08874fa13/subprojects/publish/src/main/java/org/gradle/api/publish/plugins/PublishingPlugin.java#L85 So I do not see which
#81 is somewhat related. #109 is interesting as well since it wants "publishing multiple unrelated groups into a single staging repository". I wonder what happens if AFAIK
A similar case happens when plugins need to treat WDYT? |
Hi, I have exactly same situation - I have 3 submodules in a project, all of them have |
FWIW I no longer use this plugin for the required behavior. I use JReleaser + Kordamp instead |
<!-- Thanks for opening a PR! Here are some quick tips: If this is your first time contributing, [read our Contributing Guidelines](https://github.com/openfga/.github/blob/main/CONTRIBUTING.md) to learn how to create an acceptable PR for this repo. By submitting a PR to this repository, you agree to the terms within the [OpenFGA Code of Conduct](https://github.com/openfga/.github/blob/main/CODE_OF_CONDUCT.md) If your PR is under active development, please submit it as a "draft". Once it's ready, open it up for review. --> <!-- Provide a brief summary of the changes --> Removes the example stub and organizes repo as single gradle project. ## Description <!-- Provide a detailed description of the changes --> It seems there is difficulty in publishing a single module of a multi-module project using the nexus plugin. Since the examples module is currently just a stub, this change just removes that module and makes this project a single gradle project. We can add the example as a separate directory later and pull the starter dependency from maven as the java SDK does. ## References <!-- Provide a list of any applicable references here (GitHub Issue, [OpenFGA RFC](https://github.com/openfga/rfcs), other PRs, etc..) --> gradle-nexus/publish-plugin#84 ## Review Checklist - [x] I have clicked on ["allow edits by maintainers"](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork). - [ ] I have added documentation for new/changed functionality in this PR or in a PR to [openfga.dev](https://github.com/openfga/openfga.dev) [Provide a link to any relevant PRs in the references section above] - [x] The correct base branch is being used, if not `main` - [ ] I have added tests to validate that the change in functionality is working as expected
This is perhaps more of a question than an actual bug/feature.
What's the minimal configuration required to publish a set of projects (the set may be a subset of all projects in the build) to Sonatype Nexus and release the staging repository once?
As I understand correctly, following the naming conventions in tasks, the plugin may create a staging repository per project. If that's the case, then multiple staging repositories would have to be closed & released, isn't it?
Thus, if it's possible to release a subset to the same staging repository so that a single staging repository is closed & released, I'd like to know how it may be done :-)
If it's not possible to have this scenario with the current release, then please consider adding it. As a reference the Bintray plugin registers a task at the root project that depends on individual
bintrayUpload
tasks (one per subproject). This "aggregating" task would then wait til all subtasks finish then proceed to sync uploaded artifacts to Maven Central. If not done already then this plugin would require a similar aggregating capability to close & release a single staging repository.The text was updated successfully, but these errors were encountered: