Javi
11/12/2022, 1:44 PMserve
task for websites). How should I test this task?Robert Elliot
11/13/2022, 6:06 PMStylianos Gakis
11/13/2022, 8:13 PMextra["KEY"] as? String ?: System.getEnv()
doesn’t work since extra.get completely fails if it does not find it.
I have to then do something like
val foo = if (extra.has("FOO")) {
extra["FOO"] as String
} else {
System.getenv("FOO") as String
}
but it’s such a chore to do this everywhere.
Am I missing some part of the API that could help me here? Some sort of getOrNull()
would be great on the extra
so I can avoid the has()
call, or even if there’s some API which looks at those three sources in that order.yang hai
11/14/2022, 6:35 AMPatrick van Zadel
11/14/2022, 2:30 PMjson
file from a external dependency to my local project.
The scenario I have is that we have a base project say Project A
and we create Project B
that use Project A
as a dependency.
Project A
holds an json
file in it’s resources
directory that we want to copy from the .jar
dependency to a directory in Project B
We sort of already do this for web
dependencies with configurations
like so:
configurations {
customWebDependency
}
dependencies {
implementation "org.company:project-a-core:${projectAVersion}"
customWebDependency "org.company:project-a-web:${projectAVersion}"
}
task copyWebFiles(type: Copy) {
doNotTrackState("Copy web files needs to be executed every time")
duplicatesStrategy = DuplicatesStrategy.INCLUDE
// Extract the contents of Project A
configurations.customWebDependency.iterator().forEachRemaining { dependency ->
from project.zipTree(dependency)
into buildDirectory
}
// copy all files from src/main/webapp to override
from 'src/main/webapp'
into buildDirectory
}
but when I add a custom configuration for the project-a-core
dependency I get an error during build cause my application can’t resolve the classes from that dependency. I tried adding a custom configuration that also extends like so: customProjectADependency.extendsFrom(implementation)
but that does not seem to fix it.
So I thought I might do it with a jar
task but this seems like the wrong way to do it. This should be possible with configurations and copy tasks
jar {
// TODO: This needs to be something like the CopySpec or ZipTree spec.
from provider {
zipTree(configurations.compileClasspath.filter {
it.name.contains("project-a-core-${projectAVersion}.jar")
}.getAsPath())
}
}
Dave L
11/15/2022, 6:31 AMLars Kaulen
11/15/2022, 8:08 AMjacoco-report-aggregation
plugin with a custom test suite from the jvm-test-suite
plugin?
I used the sample project at https://docs.gradle.org/current/samples/sample_jvm_multi_project_with_code_coverage_standalone.html and expanded the myproject.java-conventions
plugin with the following:
testing {
suites {
integrationTest(JvmTestSuite) {
dependencies {
implementation(project)
}
}
}
}
And the code-coverage-report/build.gradle
with:
reporting {
reports {
integrationTestCodeCoverageReport(JacocoCoverageReport) {
testType = TestSuiteType.INTEGRATION_TEST
}
}
}
tasks.named('check') {
dependsOn tasks.named('integrationTestCodeCoverageReport', JacocoReport)
}
Now when I run the check
task, the :utilities:test
, :list:test
and :application:test
are all executed due to the testCodeCoverageReport
and the dependencies.jacocoAggregation(project(':application'))
block (as expected).
But only the :application:integrationTest
task and not :utilities:integrationTest
and :list:integrationTest
are executed and included in the integrationTestCodeCoverageReport
.tomas-mrkvicka
11/15/2022, 12:58 PMA
after a test
task finished (successfully or failed), but only if another task B
is scheduled for execution.
Solution: Well, I can test.finalizedBy A
but do not know how to add the condition with task B
.
Any ideas?Eric Kolotyluk
11/15/2022, 6:05 PMeric.kolotyluk@Y2RCV7009N jas-lib % ./gradlew --version
------------------------------------------------------------
Gradle 6.5
------------------------------------------------------------
Build time: 2020-06-02 20:46:21 UTC
Revision: a27f41e4ae5e8a41ab9b19f8dd6d86d7b384dad4
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 11.0.13 (Azul Systems, Inc. 11.0.13+8-LTS)
OS: Mac OS X 12.6.1 aarch64
eric.kolotyluk@Y2RCV7009N jas-lib % ./gradlew clean test
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/eric.kolotyluk/git/autonomous-iam/jas/jas-lib/build.gradle' line: 31
* What went wrong:
A problem occurred evaluating root project 'jas-lib'.
> No signature of method: build_5rsi3x0twfhl0wxw4r4adqyoe.java() is applicable for argument types: (build_5rsi3x0twfhl0wxw4r4adqyoe$_run_closure3) values: [build_5rsi3x0twfhl0wxw4r4adqyoe$_run_closure3@3282e46e]
Possible solutions: wait(), any(), wait(long), tap(groovy.lang.Closure), each(groovy.lang.Closure), any(groovy.lang.Closure)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at <https://help.gradle.org>
BUILD FAILED in 364ms
java { // line 31
// Use Gradle JVM toolchain support to automatically use correct JVM for builds
// <https://docs.gradle.org/6.7/userguide/toolchains.html>
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
Does anyone have any idea what Gradle is saying?Martin
11/16/2022, 3:37 PMJoe Andolina
11/16/2022, 5:24 PMCould not create service of type ChecksumService using BuildSessionScopeServices.createChecksumService().
From what I can tell, the error is due to permissions issues. Is it possible to run scripts on a networked drive? If so what should my permissions be to do so?Eric Kolotyluk
11/16/2022, 5:41 PMBuild file '/Users/eric.kolotyluk/git/autonomous-iam/access/access-ai/build.gradle' line: 266
A problem occurred evaluating root project 'access-ai'.
> Could not resolve all files for configuration ':runtimeClasspath'.
> Could not resolve project :observability:bundle.
Required by:
project :
project : > project :common-utils
> No matching configuration of project :observability:bundle was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally but:
- None of the consumable configurations have attributes.
The project :observability:bundle
uses a Java 8 toolchain, so I have no idea why Gradle is complaining about it this way?
The project :common-utils
also uses a Java 8 toolchain, so I have no idea why Gradle is complaining about it too?
The problem seems to be in
jar {
archiveFileName = "${project.name}.jar"
manifest {
attributes('Main-Class': 'com.forgerock.access.access.Main',
'Class-Path': configurations.runtimeClasspath.files.collect { "libs/$it.name" }.join(' ') // line 266
)
}
}
Does anyone have any ideas on what Gradle is trying to say?Eric Kolotyluk
11/16/2022, 10:24 PMcompile 'org.scala-lang:scala-library:2.11.12'
Has the compile
method been removed?M3
11/17/2022, 5:58 PMC Hartman
11/17/2022, 6:01 PMC Hartman
11/17/2022, 6:07 PMsourceSets {
main {
resources {
srcDir(tasks.getByPath(":projB:build").outputs)
}
}
}
That is better than the old setup with a dependsOn and copy task. But is there a way to set the target dir?Eli Graber
11/17/2022, 9:57 PMresolutionStrategy
to use a specific version across a set of libraries (specifically the Jetpack compose libraries, because the Jetbrains compose for desktop brings in a different version than the one I want to use).
Recently, Google suggested to use the compose BOM; how could that be used with resolutionStrategy
and useVersion
?Martin
11/18/2022, 11:43 AMbuildscript {}
and pluginManagement {}
blocks (and maybe others?) written somewhere? Or does anyone have a pointer where this is happening in the source?Payal Sahoo
11/18/2022, 12:38 PMSriHarsha
11/18/2022, 2:34 PMSlackbot
11/18/2022, 2:40 PMTrevJonez
11/18/2022, 6:10 PMEric Kolotyluk
11/18/2022, 7:16 PMthadhouse
11/19/2022, 6:52 PMmattison chao
11/20/2022, 3:42 AMGaurav Kumar
11/21/2022, 12:21 PMEli Graber
11/22/2022, 2:47 AMmavenLocal
at the top of my list of repositories to make it easier to test libraries locally, but I don't want to accidentally resolve something from there that I didn't mean to. So I'd like to print something to catch my attention and say the dependency was resolved from maven local.Arimil
11/22/2022, 5:53 PM├── build.gradle.kts
├── catalog
│ └── build.gradle.kts
├── gradle.properties
├── platform
│ └── build.gradle.kts
└── settings.gradle.kts
How would I go about having platform/build.gradle.kts
depend on a build of catalog
? Something like below (this doesn't work). I've noticed this is fairly easy to clean up if you move everything over to a toml and instead import that instead of the built version catalog but was wondering how you would do it without a toml file.Sajeeb Roy
11/22/2022, 11:35 PMMartin
11/23/2022, 3:39 PMafterEvaluate{}
under control, I have another question. How do you add default behaviour without relying on afterEvaluate
? I get the trick of adding one nesting level so that my code executes in a function where I can register my tasks, etc...
... but what if I want to provide a default behaviour? I want the user to leave out the extension completely and still create tasks, etc based on default values. Can I do that without afterEvaluate {}
?