Daniele Segato
05/22/2023, 2:09 PMfun Project.getEnvironmentProperties(env: String): Properties {
val properties = Properties()
val envFile = File(projectDir, "environment.$env.properties")
try {
properties.load(envFile)
} catch (e: Exception) {
logger.warn("Failed to load environment [$env] properties", e)
}
return properties
}
Simple question: how do I export this in a common file and use it in multiple build scripts?Shaun Reich
05/22/2023, 4:10 PMNipuna Shantha
05/22/2023, 6:06 PMcore/build.gradle
I have add logger as a dependency as below
dependencies {
implementation project(':logger')
implementation 'org.scala-lang:scala-library:2.12.0'
}
This occur issues while publishing the jar of core (core module does not have a main class It is just common methods and dependencies)
I used below code to publish the jar to maven local
publishing {
publication {
mavenJava(MavenPublication) {
from components.java
groupId = 'com.example'
artifactId = 'core'
version = '0.0.1'
}
}
}
In .m2 repository jar is created with files
• core-0.0.1.jar
• core-0.0.1.module
• core-0.0.1.pom
Inside .pom file It contain logger module which I added as a dependency to core module as below
<dependencies>
<dependency>
<groupId>Utilities</groupId>
<artifactId>logger</artifactId>
<version>unspecified</version>
<scope>runtime</scope>
<dependency>
........................
<dependencies>
In simply when using this in different location It cannot identify logger module with proper location. My requirement is to add content files (classes and objects) of logger to core while publishing the jar. But cannot first publish logger separately then import it again core as dependency is not a good approach for my planned implementations. Can you guys make any suggestions to solve this issue or point out any thing that I done wrong that would be very helpful.Roberto Fuentes
05/22/2023, 6:45 PMkt
function
fun functionThatReturnsSomething(): Boolean {
return true
}
In my settings.gradle.kts
pluginManagement {
val bool = functionThatReturnsSomething()
}
And in my build.gradle.kts
root
buildscript {
val bool = functionThatReturnsSomething()
}
Giuseppe Barbieri
05/23/2023, 9:36 AMShalom Ben-Zvi Kazaz
05/23/2023, 6:57 PMSid B
05/23/2023, 7:34 PMresources
folder?Shaun Reich
05/23/2023, 8:05 PMSuraj Singh
05/24/2023, 1:23 AM* What went wrong:
A problem occurred evaluating root project 'opensearch-security-analytics'.
> 'org.gradle.internal.jvm.inspection.JvmInstallationMetadata org.gradle.internal.jvm.inspection.JvmMetadataDetector.getMetadata(java.io.File)'
Vinay Nagaraj
05/24/2023, 1:23 PMfun RepositoryHandler.customRepo(provider: ProviderFactory) {
maven("<https://release-url>") {
mavenContent { releasesOnly() }
artifactoryCredentials(provider)
}
maven("<https://snapshot-url>") {
mavenContent { snapshotsOnly() }
artifactoryCredentials(provider)
}
}
fun AuthenticationSupported.artifactoryCredentials(provider: ProviderFactory) {
val userName = provider.propOrEnv("artifactory_username").get()
val apiKey = provider.propOrEnv("artifactory_api_key").get()
credentials {
username = userName
password = apiKey
}
}
fun ProviderFactory.propOrEnv(key: String): Provider<String> {
return gradleProperty(key).orElse(environmentVariable(key))
}
What's the best way to make this function available in both (buildSrc & root) settings.gradle?Martin
05/24/2023, 1:33 PMProvider
that determines lazily whether it has a value or not ?
project.provider {
if (somethingIsThere) {
something
} else {
// What do I put here to get an empty provider?
}
}
Clayton Walker
05/24/2023, 4:11 PMmodel {
platforms {
x64 {
architecture "x86_64"
}
}
be converted to the kotlin build syntax?Andrew Tasso
05/24/2023, 10:18 PM./gradlew build
the build task for the consuming project will saying that the zip file can't be find, (since it hasn't been created yet). What am I missing?
Producing Project (A project with java-application
applied named "Dummy")
configurations {
appDistribution {
canBeConsumed = true
canBeResolved = false
}
}
artifacts {
appDistribution(distZip)
}
Consuming Project:
configurations {
bundledApps {
canBeConsumed = false
canBeResolved = true
}
}
dependencies {
bundledApps(project(path: ":Dummy", configuration: 'appDistribution'))
}
configurations.bundledApps.each { file ->
distributions.main.contents {
from(zipTree(file)) {
into "tools"
}
}
}
kartikey sood
05/25/2023, 3:05 AMDoni
05/25/2023, 3:52 AM* What went wrong:
Execution failed for task ':credit:compileGeneralStagingKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* Try:
> Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':credit:compileGeneralStagingKotlin'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:147)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:135)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
but the root cause is:
e: file:///Users/vagrant/workspace/Traveloka-Android/build/credit/src/main/.....
Is it possible to put the original error above inside "What went wrong" part or somewhere on the end of build?
We wasting lot of time to find the original error from our large log file, would be nice if we can highlight that on the end of log.Hantsy Bai
05/25/2023, 7:10 AMtestImplementation(libs.starterTest) {
// use mockk as mocking framework
exclude(module = "mockito-core")
exclude(module = "android-json")
}
Miroww328
05/25/2023, 6:39 PMGiuseppe Barbieri
05/26/2023, 10:19 AMgithubToken
in gradle.properties
in my home on Linux, everything fine.
The very same on Windows doesn't work.. C:\Users\x\.gradle\gradle.properties
_println_(providers.gradleProperty("githubToken").get())
Cannot query the value of this provider because it has no value available.I have tried to reboot (maybe properties loading only on boot), nothing What is going on?
Clayton Walker
05/26/2023, 7:24 PMSu5eD
05/27/2023, 6:51 PMThao Nguyen lu
05/28/2023, 7:25 AMFailed to apply plugin 'com.android.internal.application'. java.io.UncheckedIOException: java.nio.file.AccessDeniedException: C:\android.lock• Exception is: org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'com.android.application'] Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin 'com.android.internal.application'. Caused by: java.lang.RuntimeException: java.io.UncheckedIOException: java.nio.file.AccessDeniedException: C:\android.lock *And this is my Android studio information: AS: Flamingo | 2022.2.1 Patch 1 Kotlin plugin: 222-1.8.20-release-AS3739.54 Android Gradle Plugin: 8.0.1 Gradle: 8.0 Gradle JDK: JetBrains Runtime version 17.0.6 *My dependencies: dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.5.0-alpha05"
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.5.1'
implementation platform('androidx.compose:compose-bom:2022.10.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}
I even change my grale JDK but it doesn't work. I need for your help. This bug makes me crazy!Igor Wojda
05/29/2023, 8:29 PM.
character is messing something up with Gradle parameters. The command works fine on Ubuntu but on windows I get this:
./gradlew publishToMavenLocal -Pkonsist.releaseTarget=local -Pkonsist.signingKey='***' -Pkonsist.signingPassword='***' -Pkonsist.ossrhUsername='***' -Pkonsist.ossrhPassword='***'
...
10 actionable tasks: 10 executed
FAILURE: Build failed with an exception.
* What went wrong:
Task '.releaseTarget=local' not found in root project 'konsist' and its subprojects.
BTW there is a slight chance that Github Actions is messing things up but I am not sure, since I don't have Windows machine to test. Any ideas here? 🤔Ganeshwaran Gabilan
05/30/2023, 4:45 AMerror: module not found: <module name> requires <module name>
errors even I added the required modules to the module-info.java
file. Can someone explain what's the issue here?Ganeshwaran Gabilan
05/30/2023, 4:47 AMcompileJava
tasks to the build.gradle
files?
compileJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}
Igor Wojda
05/30/2023, 9:38 AMRun ./gradlew publishToMavenLocal -P konsist.releaseTarget=local -P konsist.signingKey='***' -P konsist.signingPassword='***' -P konsist.ossrhUsername='***' -P konsist.ossrhPassword='***'
> Task :buildSrc:generateExternalPluginSpecBuilders UP-TO-DATE
...
> Task :lib:publishToMavenLocal
BUILD SUCCESSFUL in 51s
18 actionable tasks: 8 executed, 10 up-to-date
'ui' is not recognized as an internal or external command,
operable program or batch file.
Error: Process completed with exit code 1.
Any clues on how to make this one work?Hantsy Bai
05/30/2023, 9:46 AMcommons-logging
in my project, and find out all deps that include commons-logging.
such as
+--- org.apache.xmlgraphics:xmlgraphics-commons:2.8
| +--- commons-io:commons-io:2.11.0
| \--- commons-logging:commons-logging:1.0.4
Add :
implementation(libs.xmlgraphicsCommons) {
exclude(group = "commons-logging", module = "commons-logging")
}
Others dep used the similar scripts works, the commons-logging are excluded as expected.
But this xmlgraphics-common
, it (commons-logging) is still included in the dependency tree.Sebastian Schuberth
05/30/2023, 12:43 PMbuildSrc
or build-logic
to organize shared build logs. https://docs.gradle.org/current/samples/sample_convention_plugins.html#organizing_build_logic seem to advocate for buildSrc
, but https://docs.gradle.org/release-nightly/userguide/structuring_software_products.html#an_example advocates for build-logic
. What gives?Philip W
05/30/2023, 4:45 PMrunBlocking
. Is this usage okay, because it would block the current thread, or do you have another idea?Daniele Segato
05/31/2023, 11:59 AMenvironments {
create("dev") {
propertiesFile = file("dev.properties")
disableReleaseBuild = true
}
// ...
}
Ideally with some default that can be overridden.
Bonus question: can I extend another plugin extension and add that inside it? (Aka = would I be able to add that conf inside the android { }
plugin?)
Bonus question 2: I would use those configurations in my plugin to configure flavors for the android build in the android plugin, how is the ordering of plugins execution determined?Thomas Keller
05/31/2023, 3:17 PM