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
java
plugin
compileJava
processResources
classes
compileTestJava
processTestResources
testClasses
jar
javadoc
test
clean
cleanTaskName
SourceSet Tasks
SourceSet-Specific Tasks included in Gradle
java
plugin. e.g. If the source istest
, a task named ascompileTestJava
is configured. You already saw these tasks from above task list.
compileTestJava
processTestResources
testClasses
Lifecycle Tasks
Lifecycle tasks? The tasks defined by Base Plugin
assemble
check
build
buildNeeded
buildDependents
buildConfigName
Project layout
p. “The Java plugin assumes the project layout shown below.”
You can think of
main
andtest
as sourceSet provided by default, while you can define a custom sourceSet on your own. Below is the default layout.
src/main/java
src/main/resources
src/test/java
src/test/resources
src/sourceSet/java
src/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
Resolvable
mean?