I hava an example java project package
package com.example.testing;
with such file tree
app
|
src->com->example->testing->Main
The question is about "Adding"; the question of the text is describing a more concrete scenario. If one just wants to add an existing directory, this is the way to add:
sourceSets.main.java.srcDirs += ['src/gen/java']
An example full build.gradle is as follows:
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
implementation 'com.squareup:javapoet:1.12.1'
}
sourceSets.main.java.srcDirs += ['src/gen/java']
JavaPoet s a Java API for generating .java source files. It is just used as example library for the build.gradle file.