guillaume le floch
03/06/2022, 7:13 AMtony
03/06/2022, 8:10 PM// build.gradle
def compileFunctionalTestKotlin = tasks.named('compileFunctionalTestKotlin')
tasks.named('compileFunctionalTestGroovy', AbstractCompile) {
dependsOn compileFunctionalTestKotlin
classpath += files(compileFunctionalTestKotlin.get().outputs.files)
}
I have a recollection that Gradle has a facility to wire this more automatically, but I can't find it anywhere. I think I saw it in some release notes a while agoLilly
03/07/2022, 6:27 PMprecompiled script plugin
that I have published to my public repo. When I apply it to the plugins
block I get:
An exception occurred applying plugin request [id: 'de.myorg.configuration.android-library']
> Failed to apply plugin 'de.myorg.configuration.android-library'.
> No value presentand further
Caused by: java.util.NoSuchElementException: No value presentI have everything broken down to the absolute minimum to figure out what causes it but I had no luck so far. I tried quite everything. Any ideas?
tomas-mrkvicka
03/07/2022, 9:02 PMProject
plugin which is applied to specific sub-projects within a multi-project build. The plugin does a time consuming computation whose output is the very same for all projects and is needed by all projects. Therefore I want to do the computation only once for all projects and reuse the output.
I am thinking about using rootProject
as an output holder. But what options do I have? ExtraPropertiesExtension
provides no synchronization on get and set methods so this is no go for me. Another option I am thinking of is to create a custom extension on the root project and have the synchronization done on the extension level. But I see no maybeCreate
method on the ExtensionContainer
so I would have to call ExtensionContainer.create
and catch the exception if the extension is already created by other project (parallel execution is enabled). But this seems ugly to me.
Or is there any other option of sharing synchronized data within a multi-project build?Zak Taccardi
03/07/2022, 10:52 PMDomainNameObjectCollection<MyClass>
- but I don’t want MyClass
to have to extend Named
(or be changed in any way to support Gradle). Does gradle support adding a MyClass
to a DomainNameObjectCollection<MyClass>
with a custom way to identify the name?
And if I don’t care about the name, is there a way to construct DomainObjectCollection<T>
without requiring a name? I only see objects.namedDomainObjectSet(..)
as a constructor function - and objects.domainObjectContainer(..)
(that is un-named)Emily V
03/08/2022, 6:38 AMMarkus Maier
03/08/2022, 12:49 PMgradle.taskGraph.whenReady
and gradle.projectsEvaluated
seem to be fired too early for my use-case. Is there any other callback I should use?TwoClocks
03/08/2022, 8:07 PMThor Rognan
03/08/2022, 8:16 PM- name: Build project
run: >
./gradlew build --scan
-Dorg.gradle.java.installations.auto-detect=false
-Dorg.gradle.java.installations.auto-download=false
-Dorg.gradle.java.installations.paths=${{ steps.configure-gradle-jdk.outputs.path }},${{ steps.configure-toolchain-jdk.outputs.path }}
However, on Windows the `-Dorg.`is interpreted as a task, so I get an error message like this: Task '.gradle.java.installations.auto-detect=false' not found in root project
.
This goes absolutely fine when instead running the build directly through gradle-build-action using the `arguments`option.
What is going on here?Lars Ködderitzsch
03/09/2022, 7:48 AMWorkAction
running in workerExecutor.classLoaderIsolation
using the runtime classpath. The second part could then run as a separate work action with no isolation (plugin classpath).
How can I connect these 2 work actions?
I haven't found a way to extract a result from the first action, to pass into the second.
Or: is it viable to trigger the second work action from within the first?tomas-mrkvicka
03/09/2022, 11:28 AMtomas-mrkvicka
03/09/2022, 4:58 PMthis
project. So far so good. But I would expect that it will work similar to default test
test suite, so that dependencies from implementation
configuration will be visible to new test suite as well. Do I really need to redeclare required dependencies from implementation
configuration? I can not think of a reason why this works differently.Zak Taccardi
03/09/2022, 8:09 PMallprojects { }
to generate a DomainObjectCollection<ModuleConfig>
value. This needs to only be done once per multi-project build. Is there a way to do this idiomatically so it’s only done once per build? or should every every subproject that needs DomainObjectCollection<ModuleConfig>
do the looping itself?Deepthi Kodatham
03/10/2022, 12:54 AM-rw-r--r-- 1 root root 497871506 Mar 10 00:45 abc-eds-audit-service-0.18.0-SNAPSHOT.jar
-rw-r--r-- 1 root root 245119 Mar 10 00:45 abc-eds-audit-service-0.18.0-SNAPSHOT-plain.jar
But when publishing using the com.jfrog.artifactory
its publishing only the `-plain`jar file and not the other jar which includes everything. I want to be able to publish the other one too named
abc-eds-audit-service-0.18.0-SNAPSHOT.jar
[pool-1-thread-1] Deploying artifact: <https://abc.jfrog.io/abc/libs-snapshot-local/com/xyz/abc/eds/audit/abc-eds-audit-service/0.18.0-SNAPSHOT/abc-eds-audit-service-0.18.0-SNAPSHOT-plain.jar>
[pool-1-thread-1] Deploying artifact: <https://abc.jfrog.io/abc/libs-snapshot-local/com/xyz/abc/eds/audit/abc-eds-audit-service/0.18.0-SNAPSHOT/abc-eds-audit-service-0.18.0-SNAPSHOT.module>
[pool-1-thread-1] Deploying artifact: <https://abc.jfrog.io/abc/libs-snapshot-local/com/xyz/abc/eds/audit/abc-eds-audit-service/0.18.0-SNAPSHOT/abc-eds-audit-service-0.18.0-SNAPSHOT.pom>
Below is a snippet of my build.gradle
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
artifactory {
publish {
contextUrl = '<https://abc.jfrog.io/abc/>' //The base Artifactory URL for the publisher
//A closure defining publishing information
repository {
repoKey = 'libs-snapshot-local'
username = project.getProperty("artifactory_user")
password = project.getProperty("artifactory_password")
maven = true
}
defaults {
//publications ('mavenJava')
publications 'ALL_PUBLICATIONS'
publishBuildInfo = true
publishArtifacts = true
publishPom = true
publishIvy = true
}
}
// Redefine basic properties of the build info object
clientConfig.setIncludeEnvVars(true)
clientConfig.setEnvVarsExcludePatterns('*password*,*secret*')
clientConfig.setEnvVarsIncludePatterns('*not-secret*')
clientConfig.info.addEnvironmentProperty('test.adding.dynVar',new java.util.Date().toString())
clientConfig.info.setBuildName('new-strange-name')
clientConfig.info.setBuildNumber('' + new java.util.Random(System.currentTimeMillis()).nextInt(20000))
clientConfig.timeout = 600 // Artifactory connection timeout (in seconds). The default timeout is 300 seconds.
clientConfig.setInsecureTls(false) // Set to true to skip TLS certificates verification (false by default).
}
Any help is highly appreciated.tomas-mrkvicka
03/10/2022, 12:56 AMclass TestExtension @Inject constructor(private val name: String, objectFactory: ObjectFactory, project: Project, sourceSetContainer: SourceSetContainer, configurationContainer: ConfigurationContainer, taskContainer: TaskContainer) : Named {
private val maxParallel: Property<Int>
init {
maxParallel = objectFactory.property(Int::class.java)
// Register new test suite and always use JUnit 5.
project.extensions.findByType(TestingExtension::class.java)?.apply {
suites.register(name, JvmTestSuite::class.java).configure { jvmTestSuite ->
jvmTestSuite.useJUnitJupiter()
}
}
// Configures new test suite dependencies the very same way like the default 'test' source set.
// See org.gradle.api.plugins.jvm.internal.DefaultJvmVariantBuilder and search for 'JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME'.
val sourceSet = sourceSetContainer.getByName(name)
val mainSourceSet = sourceSetContainer.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
val implementationConfiguration = configurationContainer.getByName(mainSourceSet.implementationConfigurationName)
configurationContainer.getByName(sourceSet.compileClasspathConfigurationName).extendsFrom(implementationConfiguration, configurationContainer.getByName(mainSourceSet.compileOnlyApiConfigurationName))
configurationContainer.getByName(sourceSet.runtimeClasspathConfigurationName).extendsFrom(implementationConfiguration, configurationContainer.getByName(mainSourceSet.runtimeOnlyConfigurationName))
// Create the service with parallelism set.
val basicService = project.gradle.sharedServices.registerIfAbsent(name, BasicService::class.java) {
// FIXME: It's always 'default'. It doesn't react to changes within maxParallel.
it.maxParallelUsages.set(maxParallel)
}
// Declare association between new Test task and the service.
taskContainer.getByName(name) {
it.usesService(basicService)
}
}
fun maxParallel(maxParallel: Int) {
this.maxParallel.set(maxParallel)
}
fun maxParallel(maxParallel: String) {
maxParallel(maxParallel.toInt())
}
override fun getName() = name
}
abstract class BasicService : BuildService<BuildServiceParameters.None>
And the configuration looks like:
plugin {
tests {
intTest {
maxParallel 4
}
}
}
When setting maxParallelUsages
I would expect, that the value from the maxParallel
Property would be obtained once it is needed, but it's not - it's always undefined. If I put println()
to the maxParallel()
method, I can see that the method is called and the maxParallel
property is changed according to the build script.
Am I missing something?Zak Taccardi
03/10/2022, 12:58 AMGiuseppe Barbieri
03/10/2022, 10:37 AM--Pargs=".."
but it doesn't seem to work
ps: the task does extend JavaExec
Jason Kolovsky
03/10/2022, 5:35 PMLilly
03/10/2022, 9:56 PMminifyEnabled
true, my locally published aar library is empty. I have uncomment any proguard lines. The library has only a bunch of util classes so far.
buildTypes {
getByName("release") {
// Enables code shrinking, obfuscation, and optimization for your project's release build type
isMinifyEnabled = true
// R8 configuration files
// proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "<http://proguard-rules.pro|proguard-rules.pro>")
}
}
Any ideas? 🤕
EDIT:
ok I guess I'm misusing it. It's disabled by default and
Minifying the library before consumption is not recommended, because you can not know what parts will actually be used before the final buildJust of curiosity, why are the classes removed?
Zak Taccardi
03/11/2022, 10:48 PMChris Doré
03/12/2022, 1:27 AMProperty
with tasks using the DSL such that it is considered an output and participates in inferred task dependencies? I'm pretty sure the answer is no
, but I thought I'd check in case I'm missing something (I know how to do it using task classes).
For example, running task b
results in task a
also running:
task a {
ext {
outDir = objects.directoryProperty()
}
outDir = layout.buildDirectory.dir('a')
outputs.dir(outDir)
doLast {
logger.lifecycle('building a')
outDir.get().asFile.mkdirs()
}
}
task b {
ext {
inDir = objects.directoryProperty()
}
inDir = a.outDir
inputs.dir(inDir)
doLast {
logger.lifecycle('building b')
}
}
Niv Sahar
03/14/2022, 11:26 AMChris
03/14/2022, 6:04 PMpublic void contents(Action<CopySpec> action)
Is this doable in some way without moving to non-managed properties?John Bellini
03/14/2022, 9:37 PMbuilder.build.gradle.kts
If my class needs dependencies, I put them in the buildSrc dependencies section of the build.gradle.kts
however this seems to not be working and so the dependencies are not found within my class. This is all within the context of the build scripts that I am working in here. Pic as a point of helping describe things here.Beat Kappert
03/15/2022, 7:44 PMval smokeTest by configurations.creating {
extendsFrom(configurations.testImplementation.get())
}
dependencies {
testImplementation("junit:junit:4.13")
smokeTest("org.apache.httpcomponents:httpclient:4.5.5")
}
I understand that the "smokeTest" scope includes "junitjunit4.13" as it is derived from "testImplementation".
But how can I control to what part of the build "smokeTest" applies?
The Java plugin probably does some crazy magic in order to make "testImplementation" be relevant for the src/test subdirectory.
Can/should I do the same?
The example given further down on the page with Jasper is not really accessible for me (not familiar with Ant and this syntax).
Can something useful be done with custom configurations without Ant?John Bellini
03/16/2022, 7:50 PMChris
03/17/2022, 7:17 PMBuildService
to create a temporary directory?TwoClocks
03/20/2022, 9:31 PMtomas-mrkvicka
03/21/2022, 10:35 AMmustRunAfter
correctly. mustRunAfter
doesn't work across projects within a multi-project setup. So If I specify taskB.mustRunAfter taskA
within projects' build scripts, it actually doesn't mean that any taskB
will start after all taskA
are done. The order is applied to project scope only.
So if I want to start execution of any taskB
only after all taskA
from all projects are done, I have to update the mustRunAfter
within all projects and actually iterate over rootProject.allprojects
within gradle.projectsEvaluated
action and locate each and every taskA
? Or is there any better option to apply the rule across all projects?joschi
03/21/2022, 11:11 AM