https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
gradle
  • t

    therealbluepandabear

    03/20/2021, 10:51 PM
    I keep getting 'gradle' is not recognized as an internal or external command, operable program or batch file.
    e
    • 2
    • 24
  • t

    tyrondis

    03/21/2021, 5:08 PM
    How can I ensure that a custom task created with
    tasks.register()
    runs as part of the
    check
    lifecycle in Gradle's Kotlin DSL?
    e
    • 2
    • 2
  • t

    therealbluepandabear

    03/22/2021, 4:12 AM
    HI in my Kotlin gradle project I'm getting no 'src' folder even though Kotlin is configured. An old solution was to go to Build Tools --> select gradle and you will get the option 'create directories for empty content root automatically'; but this was removed in 2019 - here is my current project:
    v
    n
    • 3
    • 12
  • r

    ribesg

    03/22/2021, 12:17 PM
    I just started having a weird issue after updating A JDK I DON’T USE from 15 to 16
    ribesg:myProject/ (develop) $ ./gradlew
    
    > Task :buildSrc:compileKotlin FAILED
    e: No class roots are found in the JDK path: /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':buildSrc:compileKotlin'.
    > Compilation error. See log for more details
    
    * 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 1s
    ribesg:myProject/ (develop) $ /usr/libexec/java_home -V
    Matching Java Virtual Machines (3):
        16 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 16" /Library/Java/JavaVirtualMachines/adoptopenjdk-16.jdk/Contents/Home
        11.0.10 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 11" /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
        1.8.0_282 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
    /Library/Java/JavaVirtualMachines/adoptopenjdk-16.jdk/Contents/Home
    ribesg:myProject/ (develop) $ echo $JAVA_HOME
    /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
    Something seem to be looking for the JDK 15 which no longer exists now that it has been updated to 16. I verified using logs I added to my
    gradlew
    scripts that it’s calling my JDK 11's java. What references the JDK 15 here? Does the kotlin compiler/plugin itself has some kind of cache ? I removed
    .gradle
    and
    build
    folders multiple times and stopped Gradle daemons
    • 1
    • 1
  • j

    Jishin Dev [JD]

    03/22/2021, 1:56 PM
    How can I access
    ~/<username>/.gradle/gradle.properties
    file from kotlin code (not
    kts
    ) in an android project?
    m
    • 2
    • 2
  • m

    Marc Knaup

    03/22/2021, 4:25 PM
    Is there a simpler way to specify dependency versions in a central location in a type-safe and auto-complete friendly way other than using
    buildSrc
    ? So that it can be used across all build scripts. https://github.com/fluidsonic/raptor/blob/master/buildSrc/sources/Versions.kt
    b
    j
    n
    • 4
    • 35
  • m

    miqbaldc

    03/26/2021, 11:00 AM
    _*Solved*_: using this approach _*Context*_: Needs helps and guidance to configure
    build.gradle.kts
    inside
    buildSrc
    to be used as a common/base dependencies, such as:
    // myapp2/build.gradle
    apply plugin: 'commons.android-dynamic-feature'
    
    // myapp3/build.gradle
    apply plugin: 'commons.android-dynamic-feature'
    _*Problems*_:
    // image on the left
    com.android.build.gradle.internal.dsl.BaseAppModuleExtension
    
    // image on the middle
    com.android.build.gradle.AppExtension
    I’ve 3 gradle files
    1. |-app/build.gradle.kts
    2. |-buildSrc/build.gradle.kts // this is to configure below
    3. |-buildSrc/commons/build.gradle.kts
    In the no. 3, is using
    AppExtension
    instead of
    BaseAppModuleExtension
    , with
    AppExtension
    , I’m unable to define
    android.buildFeatures.*
    (see image on the right) lmk if you guys needs more information to know about this 🙏
    • 1
    • 3
  • c

    Carter

    03/29/2021, 7:56 PM
    I’m trying to test out Gradle 7.0-rc1, although my multiplatform app project immediately fails with an exception included below. If I comment out the withJava in my module that uses the application plug-in, it bypasses the gradle crash and I can at least run my unit tests.
    kotlin {
        jvm {
            // Comment to bypass failure with Gradle 7.0
            // withJava()
        }
        ...
    }
    Is there a workaround or an issue on YouTrack I can follow? This is the exception I see:
    java.lang.NoSuchMethodError: 'java.lang.String org.gradle.api.tasks.SourceSet.getCompileConfigurationName()'
        at org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget.setupDependenciesCrossInclusionForJava(KotlinJvmTarget.kt:155)
        at org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget.access$setupDependenciesCrossInclusionForJava(KotlinJvmTarget.kt:27)
        at org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget$withJava$3.execute(KotlinJvmTarget.kt:78)
        at org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget$withJava$3.execute(KotlinJvmTarget.kt:62)
        at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:100)
        at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:95)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
        at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.execute(DefaultCollectionCallbackActionDecorator.java:92)
        at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:163)
        at org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget.withJava(KotlinJvmTarget.kt:62)
    a
    h
    h
    • 4
    • 5
  • p

    PHondogo

    03/31/2021, 10:51 AM
    Hello! I have kotlin MPP gradle module with targets jvm1, jvm2. How can i depend on both targets from another gradle module? (module2.dependencies{???})
    t
    • 2
    • 1
  • p

    pabl0rg

    03/31/2021, 7:21 PM
    Hi everyone. I use the sqldelight 1.5.0-SNAPSHOT gradle plugin and as of today, that plugin seems to require artifacts that are not available on any of the usual maven repos. Is there a way to tell gradle (preferably in kts) to use a specific snapshot version from this list? (i'd like to use yesterday's builds) https://oss.sonatype.org/content/repositories/snapshots/com/squareup/sqldelight/gradle-plugin/1.5.0-SNAPSHOT/
    t
    • 2
    • 3
  • t

    therealbluepandabear

    04/04/2021, 5:04 AM
    Gradle is running on my JRE, how do I change this to run on the JDK? Thanks.
    :not-kotlin: 3
    e
    c
    • 3
    • 3
  • i

    Ivan Đorđević

    04/05/2021, 1:39 PM
    Hi, is it possible to add
    kotlin-gradle-plugin
    to
    buildSrc
    ? My idea is to write reusable extensions of various gradle types to provide usages for multiple KMM modules. But no matter what I've tried it won't work. 1.
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31")
    fails with
    Unable to load class 'com.android.build.gradle.BaseExtension'.
    2. ``compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31")` fails latter down the line
    Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
    Here's the full
    build.gradle.kts
    for `buildSrc`:
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    
    plugins {
        `kotlin-dsl`
    }
    
    dependencies {
        compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31")
    }
    
    kotlinDslPluginOptions {
        experimentalWarning.set(false)
    }
    j
    • 2
    • 14
  • s

    Slackbot

    04/07/2021, 5:13 AM
    This message was deleted.
    t
    n
    v
    • 4
    • 7
  • y

    Yasutaka Kawamoto

    04/07/2021, 9:20 AM
    Is there the way outputs all dependencies with or without updates using gradle-versions-plugin ?
    t
    v
    • 3
    • 22
  • t

    turansky

    04/07/2021, 8:59 PM
    Is there way to enable trailing comma in
    buildSrc
    (Kotlin
    1.4.32
    , Gradle
    6.8.3
    )?
    e
    v
    +4
    • 7
    • 10
  • p

    Paul Woitaschek

    04/08/2021, 9:58 AM
    I have a plugin in my buildSrc that generates kotlin code. I consume that plugin through a task in one of my modules. Naively I let the KotlinCompile task depend on that task:
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
      dependsOn(generateKotlinCodeTask)
    }
    However this one now fails on multiplatform. I debugged the task names and I can make it work if I add that task dependency for
    KotlinNativeCompile
    as well. However I'm asking myself if this is the correct approach to hook code generation into the build process.
    v
    • 2
    • 14
  • m

    Marc Knaup

    04/08/2021, 12:11 PM
    IDEA 2021.1 breaks Gradle sync for me. In
    settings.gradle.kts
    the value of
    System.getProperty("user.dir")
    is now
    /
    instead of the project’s path. Gradle command line works fine though 🤔
    y
    t
    v
    • 4
    • 26
  • j

    Joel

    04/12/2021, 11:30 PM
    Is it possible to download gradle sources from an alternate URL? It certainly doesn't seem that way, but it would be useful given that the gradle bin itself can be downloaded from alternate URLs.
    j
    v
    • 3
    • 4
  • c

    christophsturm

    04/13/2021, 9:29 AM
    is it better to wait for kotlin 1.5 before upgrading to gradle 7?
    p
    t
    +2
    • 5
    • 4
  • z

    Zach Klippenstein (he/him) [MOD]

    04/13/2021, 4:48 PM
    I just noticed that if you have a gradle module in your project that defines a custom
    RequiresOptIn
    annotation, and another module that depends on that module and annotates some code with the custom annotation, the Kotlin compiler won’t actually enforce the opt-in if the dependency on the module containing the annotation is specified as
    implementation
    or
    compileOnly
    – it must be an
    api
    dependency. Even weirder, the IDE (Android Studio Arctic Fox) actually will still enforce the annotation with those other configurations – only command-line gradle builds don’t. I haven’t seen any documentation about this requirement, and it doesn’t really make sense to me. Is this a gradle bug? A Kotlin bug? Kotlin gradle plugin bug? Or just expected behavior?
    t
    • 2
    • 2
  • m

    Marc Knaup

    04/14/2021, 4:18 PM
    Is there any info on how to use
    -Xir-per-module
    with Gradle in Kotlin 1.5? With the previous approach I get this error:
    FileNotFoundException: /Users/marc/Documents/project/modules/web/build/classes/kotlin/main (Is a directory)
    t
    • 2
    • 3
  • k

    Karlo Lozovina

    04/15/2021, 3:15 PM
    When running the app via
    gradle run
    console output of the app and of Gradle itself are interleaved - is there a way to stop Gradle printing how much the run task is been running for?
    e
    • 2
    • 3
  • t

    turansky

    04/15/2021, 8:49 PM
    Is it possible to override
    jvmargs
    , which declared in
    gradle.properties
    :
    org.gradle.jvmargs=-Xmx2g
    to have less memory on CI only?
    v
    t
    • 3
    • 4
  • c

    Chilli

    04/16/2021, 8:03 AM
    1. What's the actual, under-the-hood difference between
    implementation
    and
    compileOnly
    ? The only difference I found on Google is that
    implementation
    is available at runtime, but what does it mean exactly? Without a special plugin, Gradle doesn't shade dependencies anyway, no?
    👀 1
    b
    a
    +4
    • 7
    • 11
  • s

    Shabinder Singh

    04/17/2021, 11:21 PM
    How to skip all test tasks when executing ./gradlew clean build ? I tried -x tests, didnt worked.
    e
    t
    • 3
    • 2
  • r

    robstoll

    04/18/2021, 10:34 AM
    Not sure if I should post this here or in #multiplatform. How can I exclude a transitive dependency from all sourceSets?
    e
    t
    v
    • 4
    • 25
  • b

    Benjamin AIMONE

    04/19/2021, 8:16 AM
    Hello, I upgraded my project to gradle 6.8.3 and I can’t decide if I should use
    `java-library` to replace ``java-gradle-plugin`
    with toolchain in my project, it can build with or without, any suggestion ? https://github.com/klaxit/hidden-secrets-gradle-plugin
    v
    e
    • 3
    • 15
  • m

    melatonina

    04/19/2021, 9:44 AM
    Hello. I'm collecting dependencies in my jar file in order to create a Docker image. I'm using:
    jar {
        // ... Manifest stuff
    
        from {
            configurations.compile.collect {
                it.isDirectory() ? it : zipTree(it)
            }
        }
    }
    This works with my test project but has no effect in my actual project. What could be the cause?
    v
    f
    • 3
    • 22
  • g

    gabrielfv

    04/19/2021, 9:20 PM
    Hello, does anyone know a way to find which modules depend on a given module? For example, for a project with dependencies laid out like this:
    a -- b
      \- c
    b -- c
    c -- d
    I´m trying to find a way to find which modules depend on
    d
    , in this case
    c
    . If I wanted to know about
    c
    ,
    a
    and
    b
    . Ultimately, being able to do this recursively would be convenient. Since, transitively, every module would depend on
    d
    .
    m
    v
    • 3
    • 13
  • j

    jean

    04/20/2021, 8:13 AM
    How does one configure custom maven dependency in
    gradle.build
    while using
    dependencyResolutionManagement
    in
    settings.gradle
    ? What I have so far:
    // build.gradle.kts
    repositories {
        maven {
            url = uri("<https://maven.pkg.jetbrains.space/myTeam/p/myProject/maven>")
            credentials {
                username = project.extra["space_usr"].toString()
                password = project.extra["space_pwd"].toString()
            }
        }
    }
    
    // settings.gradle.kts
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
        }
    }
    But I get the following error :
    Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'app/build.gradle.kts'
    If I remvove
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    then I get the following error :
    Could not determine the dependencies of task ':app:kaptDebugKotlin'.
    > Could not resolve all dependencies for configuration ':app:kotlinKaptWorkerDependencies'.
      The project declares repositories, effectively ignoring the repositories you have declared in the settings.
      You can figure out how project repositories are declared by configuring your build to fail on project repositories.
      See <https://docs.gradle.org/7.0-rc-1/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories> for details.
       > Could not find org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.4.32.
         Searched in the following locations:
           - <https://maven.pkg.jetbrains.space/>...
           - <https://maven.pkg.jetbrains.space/>...
         Required by:
             project :app
    I could add my custom maven dependency in
    settings.gradle.kts
    but
    project.extra
    is not accessible and requires clear text
    v
    • 2
    • 2
Powered by Linen
Title
j

jean

04/20/2021, 8:13 AM
How does one configure custom maven dependency in
gradle.build
while using
dependencyResolutionManagement
in
settings.gradle
? What I have so far:
// build.gradle.kts
repositories {
    maven {
        url = uri("<https://maven.pkg.jetbrains.space/myTeam/p/myProject/maven>")
        credentials {
            username = project.extra["space_usr"].toString()
            password = project.extra["space_pwd"].toString()
        }
    }
}

// settings.gradle.kts
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
But I get the following error :
Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'app/build.gradle.kts'
If I remvove
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
then I get the following error :
Could not determine the dependencies of task ':app:kaptDebugKotlin'.
> Could not resolve all dependencies for configuration ':app:kotlinKaptWorkerDependencies'.
  The project declares repositories, effectively ignoring the repositories you have declared in the settings.
  You can figure out how project repositories are declared by configuring your build to fail on project repositories.
  See <https://docs.gradle.org/7.0-rc-1/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories> for details.
   > Could not find org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.4.32.
     Searched in the following locations:
       - <https://maven.pkg.jetbrains.space/>...
       - <https://maven.pkg.jetbrains.space/>...
     Required by:
         project :app
I could add my custom maven dependency in
settings.gradle.kts
but
project.extra
is not accessible and requires clear text
v

Vampire

04/20/2021, 9:41 AM
Yeah, you cannot sum them. Either you declare in project or in settings, but not both. You should actually not use
project.extra
. Using extra properties has actually very few valid use-cases and for all other use-cases it is either an error or there are better ways. In your case
project.findProperty
or
project.property
would probably more appropriate as I guess you set those credentials as Gradle property and you can get Gradle properties from the settings object too. And besides that, you might consider using the idiomatic way of credentials handling: https://docs.gradle.org/current/userguide/userguide_single.html#sec:handling_credentials
j

jean

04/20/2021, 5:54 PM
It did work, thanks for the help! 🙂
View count: 5