Thread: Gradle multi module project not resolving dependency [ignore fixed]

Results 1 to 5 of 5
  1. #1 Gradle multi module project not resolving dependency [ignore fixed] 
    Registered Member
    Join Date
    Dec 2013
    Posts
    419
    Thanks given
    127
    Thanks received
    85
    Rep Power
    349
    Fixed!!! I had to delete the .idea folder and re-import my project!

    Hello guys, I am currently building a Spring Boot application and have setup a multi-module Gradle project to do this.

    The issue that I have is that my project through Intellij won't resolve dependencies across modules e.g.

    parent {
    project_a,
    project_b
    }

    In project_b's build.gradle I have added
    Code:
    implementation project(':project_a')
    which works fine and I can use all of project_a's classes. This works when I run
    Code:
    gradle build
    and
    Code:
    gradle run
    runs the code fine.

    The issue is that Intellij is not resolving the import! Has anybody experienced this before/am I missing something or is this a bug with the Intellij ultimate (2022.2.1)?

    Thanks
    Reply With Quote  
     

  2. #2  
    Java Developer

    Anezka's Avatar
    Join Date
    Aug 2013
    Age
    30
    Posts
    373
    Thanks given
    96
    Thanks received
    95
    Rep Power
    174
    Code:
    allprojects {
    
        dependencies {
            testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
            testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
        }
    
    }
    if your using java dependencies you will also have to apply the java plugin here as well

    Not sure if your building with kotlin or groovy i use kotlin so looks like this

    Code:
    plugins {
        id("java")
    }
    
    group = "com.jagex"
    version = "1.0-SNAPSHOT"
    
    repositories {
        mavenCentral()
    }
    
    allprojects {
        apply(plugin = "java")
    
        dependencies {
            implementation("org.slf4j:slf4j-api:2.0.0-beta1")
            implementation("org.slf4j:slf4j-jdk14:2.0.0-beta1")
            implementation("com.google.guava:guava:31.1-jre")
            implementation("io.netty:netty-all:4.1.79.Final")
        }
    
    }
    
    dependencies {
        implementation(project(":JS5_Cache"))
        testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
        testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
    }
    
    tasks.getByName<Test>("test") {
        useJUnitPlatform()
    }
    Also make sure not to share other module depenecies this way or you can end up with a depenency loop you going to want to implement them for each individual modules gradle build file
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Dec 2013
    Posts
    419
    Thanks given
    127
    Thanks received
    85
    Rep Power
    349
    Quote Originally Posted by Anezka View Post
    Also make sure not to share other module depenecies this way or you can end up with a depenency loop you going to want to implement them for each individual modules gradle build file
    Thanks, yes I had fixed it. I am doing this to create a shared classes module which mainly consists of utils.
    Reply With Quote  
     

  4. #4  
    Java Developer

    Anezka's Avatar
    Join Date
    Aug 2013
    Age
    30
    Posts
    373
    Thanks given
    96
    Thanks received
    95
    Rep Power
    174
    Intellij can be super finicky sometimes with updating dependencies using on of the refresh button normally works, but sometimes you have to close the current class your working on for it to register for some reason.

    Attached image
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Dec 2013
    Posts
    419
    Thanks given
    127
    Thanks received
    85
    Rep Power
    349
    Quote Originally Posted by Anezka View Post
    Intellij can be super finicky sometimes with updating dependencies using on of the refresh button normally works, but sometimes you have to close the current class your working on for it to register for some reason.
    For some reason that didn't work either, I think it just bugged out but it's fine now.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [ANY] Kotlin Gradle Multi-Project Setup
    By Tyluur in forum Snippets
    Replies: 0
    Last Post: 01-14-2021, 05:28 PM
  2. Object not working right help
    By mightymalakai33 in forum Help
    Replies: 0
    Last Post: 02-19-2009, 02:54 PM
  3. Replies: 7
    Last Post: 02-03-2009, 05:55 AM
  4. Do Not Ask For Help Here!
    By Alex in forum Tutorials
    Replies: 9
    Last Post: 09-28-2007, 03:33 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •