Slackbot
06/02/2022, 7:47 AMtony
06/02/2022, 8:04 AMtony
06/02/2022, 8:06 AMevaluationDependsOn
can mess with ordering, but that's also incompatible with project isolation, so maybe it doesn't matter). And of course you're using properties, so that should be fine so long as they're evaluated during execution and not configurationJavi
06/02/2022, 9:58 AMJavi
06/02/2022, 10:17 AMval myService =
target.gradle.sharedServices.registerIfAbsent("myService ", MyBuildService::class) {
parameters.hasBeenAppliedOnRoot.set(false)
}
if (target.path == ":") myService .get().parameters.hasBeenAppliedOnRoot.set(true)
Javi
06/02/2022, 10:17 AMis
prefixJavi
06/02/2022, 10:25 AMVampire
06/02/2022, 4:14 PMif (project == project.rootProject)
or if (project.parent == null)
, it of course does not work, as you modify the parameter only when executing configuration phase.
How to properly do it depends on your other code, where you use that information. For example if you use that at a task implementation, don't give the service to the task, but wire the services boolean property to the task.Javi
06/02/2022, 4:15 PMtony
06/02/2022, 4:16 PMJavi
06/02/2022, 4:16 PMtony
06/02/2022, 4:16 PMtony
06/02/2022, 4:17 PMJavi
06/02/2022, 4:19 PMtony
06/02/2022, 4:21 PMJavi
06/02/2022, 4:21 PMJavi
06/02/2022, 4:21 PMJavi
06/02/2022, 4:21 PMtony
06/02/2022, 4:21 PMJavi
06/02/2022, 4:22 PMtony
06/02/2022, 4:22 PMtony
06/02/2022, 4:22 PMJavi
06/02/2022, 4:27 PMgw createSemverTag
, boom π₯, multiple git tags will be created, and at the same time, I have to set the version to all the projects that apply my plugin.
So without that missing API, I can't see how to solve this problem supporting project isolation easily.Javi
06/02/2022, 4:28 PMVampire
06/02/2022, 6:06 PMThat doesn't break project isolation?I don't think so, why should it? Or you maybe didn't understand what I mean.
could you register the service in a settings plugin?What would that change? Settings script execution is part of configuration cache too.
but settings plugin can't change the version of all projects no?It should be able to without problem, nor sure why you should though
I know, and that is the problem IMO, it shouldIn what way should root project be special and why?
basically I need to register the task only in the root project, because this task create a git tagAnd what hinders you to do it?
if (target.parent == null) {
tasks.register("createSemverTag")
}
So without that missing API, I can't see how to solve this problem supporting project isolation easily.Which missing API?
Maybe the build service should create the tag instead of the task itself?I don't think so
tony
06/02/2022, 6:07 PMVampire
06/02/2022, 6:08 PMJavi
06/02/2022, 6:09 PMJavi
06/02/2022, 6:10 PMtony
06/02/2022, 6:11 PMJavi
06/02/2022, 6:14 PMVampire
06/02/2022, 6:15 PMif (currentlyOnRootProject) doTag() else if (!pluginHasBeenAppliedToRootProject.get()) logger.warn("apply the plugin to the root project")
.Javi
06/02/2022, 6:17 PMVampire
06/02/2022, 6:22 PMXavier Ducrohet
06/03/2022, 2:44 AMXavier Ducrohet
06/03/2022, 2:44 AMXavier Ducrohet
06/03/2022, 2:45 AMJavi
06/03/2022, 7:43 AMv
an library B can have w
. The rest of libraries has no git tags or uses the root one.
The approach I was using before is not very intuitive because I was passing the module name as a property, for example:
./gradlew createSemverTag "-Psemver.scope=minor" // all modules except library A and B
./gradlew createSemverTag "-Plibrary:semver.scope=minor" // library A, in reality, all v prefix I think...
I think I should avoid that and just pass a different property which should be the tag.
./gradlew createSemverTag "-Psemver.scope=minor" "-Psemver.usePrefix=v" // all modules with v prefix
And I am using gradle.properties because you can change the version without creating a tag, for example for publishing to:
./gradlew libraryA:publishToMavenLocal "-Psemver.scope=minor" "-Psemver.usePrefix=v"
Vampire
06/03/2022, 9:19 AMGradle clearly does not have a lot of API to manage applied plugins across many projects, except in Settings.Well, probably because it is a bad idea. Projects should be independent.
but since Settings plugins are optional themselvesWhat do you mean with that? Any plugin is optional.
Xavier Ducrohet
06/03/2022, 3:38 PMJavi
06/03/2022, 5:58 PMJavi
06/14/2022, 7:29 PM