The Java Plugin
p. “You can find a comprehensive introduction and overview to the Java Plugin in the Building Java Projects chapter.”
p. “Instead of applying it directly to your project, you should look into the java-library or application plugins or one of the supported alternative JVM language.”
Java plugin is a basis for other plugins such as java-library and application
Tasks
Tasks included in Gradle
javaplugin
compileJavaprocessResourcesclassescompileTestJavaprocessTestResourcestestClassesjarjavadoctestcleancleanTaskName
SourceSet Tasks
SourceSet-Specific Tasks included in Gradle
javaplugin. e.g. If the source istest, a task named ascompileTestJavais configured. You already saw these tasks from above task list.
compileTestJavaprocessTestResourcestestClasses
Lifecycle Tasks
Lifecycle tasks? The tasks defined by Base Plugin
assemblecheckbuildbuildNeededbuildDependentsbuildConfigName
Project layout
p. “The Java plugin assumes the project layout shown below.”
You can think of
mainandtestas sourceSet provided by default, while you can define a custom sourceSet on your own. Below is the default layout.
src/main/javasrc/main/resourcessrc/test/javasrc/test/resourcessrc/sourceSet/javasrc/sourceSet/resources
Source sets
Source set properties
name,output,output.classesDirs,compileClasspath,resources,java.srcDirs, etc.
Defining new source sets
Dependency management
p. “The Java plugin adds a number of dependency configurations to your project, as shown below. Tasks such as compileJava and test then use one or more of those configurations to get the corresponding files and use them, for example by placing them on a compilation or runtime classpath.”
p. “For information on the default and archives configurations, please consult the Base Plugin reference documentation.”
p. “For information on the api or compileOnlyApi configurations, please consult the Java Library Plugin reference documentation and Dependency Management for Java Projects.”
Dependency Declaration Configurations
implementation,compileOnly,runtimeOnly,testImplementation,annotationProcessor, etc.
Resolvable Configurations
What does
Resolvablemean?