Reputation: 8335
I have two projects A and B which are inside one repository. B uses some functions from A so I want to compile A before running B. I found out this can be done using Gradle composite build. I created Gradle projects like below structure.
Structure:
|
|--A
| |src
| |build.gradle
| |settings.gradle
|
|--B
| |src
| |build.gradle
| |settings.gradle
A.build.gradle:
apply plugin: 'idea'
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
group "com.check"
version "1.0"
repositories {
jcenter()
}
}
A.settings.gradle:
rootProject.name = 'A'
B.build.gradle:
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'idea'
group "com.check"
version "1.0"
mainClassName = "com.check.B.Inititate"
dependencies {
compile "com.check:A:1.0"
}
repositories {
jcenter()
}
B.settings.gradle:
rootProject.name = 'B'
B project initiate method:
package com.try.run;
import com.check.A.check;
public class Initiate {
public static void main(String[] args) {
System.out.println(check.ret());
}
}
While building this using gradle I get below error
CONFIGURE SUCCESSFUL
Total time: 0.268 secs
Could not resolve: com.check:A:1.0
Note: I am using ecilipse Oxygen version and run refresh gradle project to build the project
Upvotes: 0
Views: 824
Reputation: 8335
I forgot to add the following line on b.settings.gradle:
b.settings.gradle:
includeBuild '../A'
After which it worked perfectly.
Upvotes: 2