Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: Configuration with name 'default' not found

I am attempting to add a dependency an external gradle project (Lib-2) into another gradle project (Lib-1), where it is used in a module (Project-1). When attempting to sync Lib-1 I receive the error

Configuration with name 'default' not found.

While I am aware this error is typically caused by missing build.gradle files, both files have relevant gradle files as shown in the file tree illustrated below.

- Containing File 
  | Lib-1
     |build.gradle
     |settings.gradle
     |Module-1
        |src
        |build.gradle
  | Lib-2
     |build.gradle
     |settings.gradle
     |Module-2
        |src
        |build.gradle

The settings.gradle file for Lib-1

include 'Module-2'
include ':Lib-2'
project(':Lib-2').projectDir = new File(rootDir,'../Lib-2')

The dependencies in build.gradle file for Module-1

dependencies {
    compile project(':Lib-2')
}

Running the "build --info" give the following dump.

Starting Build Settings evaluated using settings file '/Users/$user/Containing File/Lib-1/settings.gradle'. Projects loaded. Root project using build file '/Users/$user/Containing File/Lib-1/build.gradle'. Included projects: [root project 'Lib-1', project ':Lib-2', project ':Module-1'] Evaluating root project 'Lib-1' using build file '/Users/$user/Containing File/Lib-1/build.gradle'. Evaluating project ':Lib-2' using build file '/Users/$user/Containing File/Lib-2/build.gradle'. Evaluating project ':Module-1' using build file '/Users/$user/Containing File/Lib-1/Module-1/build.gradle'. RELEASE BUILD All projects evaluated. Selected primary task 'build' from project :

FAILURE: Build failed with an exception.

  • What went wrong: Could not determine the dependencies of task ':Module-1:javadoc'. Configuration with name 'default' not found.
like image 960
Beryllium Avatar asked Nov 09 '22 13:11

Beryllium


1 Answers

When adding a dependency, this error usually means that the new project you've added is not found. In this case it happens because while you did add it in the main lib setting file, the module doesn't contain that setting.

You can go two ways here: 1. Have a build.gradle file for each lib, and within that one define each module. Then, compile each module (separately if you want to) through the same build file. 2. Go with a multi-project setting - you'll be able to compile from the module folder, but will need another settings file.

Since it's a module and not multi projects, option 1 seems like the right way to go. Just add a configuration for each module, and set the appropriate dependencies and so on. Something like this:

configurations {
 module1
 module2
}

sourceSets{ 
 module1 {
     java {
         srcDir 'src/module1'
     }
 }

 module2 {
     java {
         srcDir 'src/module2'
     }
 }
}

dependencies {
 module1 'some.dependency'
 module2 'some.other.dependenty'
}
like image 101
r02 Avatar answered Nov 14 '22 22:11

r02