In gradle how to use sources from relative path outside of project

5.3k views Asked by At

I have following 2 projects placed adjacent to each other in some folder and I want to include specific sources from a non-gradle project into this project with the structure as follows.

rootfolder/
  my-gradle-project/
    src/main/java
    build.gradle

  my-non-gradle-project/
    src/main/java/com/example/utils

In build.gradle why would following not work ? What alternative do I have ?

Additionally I need to included specific java sources from the non-gradle project.

build.gradle

sourceSets.main.java.srcDirs = [
          'src/main/java', 
           '../my-non-gradle-project/src/main/java/com/example/util')]
1

There are 1 answers

0
Dávid Tóth On BEST ANSWER

The following worked in intelliJ:

...
group 'org.example'
version '1.0-SNAPSHOT'

sourceSets {
    main {
        java{
            srcDirs '../my-non-gradle-project/src/main/java/com/example/util' /* include proto files from base project level */
        }
    }
}

sourceCompatibility = 1.11
...