Background
I now use gradle
to manage my project, but use vscode-java
to compile the project. The principle of vscode-java
to compile the project is:
1. vscode-java
calls buildship
to initialize the project and synchronize the configuration information of the project.
2. Call IProject.build()
to indirectly call the ECJ
compiler.
Differences appear (
gradle
compile VSeclipse
compile):
1. The sourceSets
defined in gradle will be synchronized to the classpathentry
element of .classpath
. Here multiple sourceSets
are converted into multiple classpathentry
. Each classpathentry
has a separate output directory. E.g: <classpathentry output="bin/a" kind="src" path="a/src">
2. Before compiling, javabuilder
will translate each classpathentry
into a SourceFile
with an independent output directory. All SourceFiles
are passed as parameters to the ECJ
compiler.
Question:
Eclipse
will treat all sourceSets
as the same project and compile them at the same time; however, gradle
’s sourceSets
all correspond to a compilation task (which may have dependencies) and cannot be compiled at the same time.
Need:
Each source directory in sourceSets
may have interdependencies, and each source directory needs to be compiled into a different independent output directory. E.g:
sourceSets {
a {
java {
srcDirs = [a/src]
}
}
b {
java {
srcDirs = [b/src]
}
}
}
output:
build
----- a
----- b