Gradle Java Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 23: Line 23:
  src/test/java
  src/test/java


All files under
All files under:


  src/main/resources  
  src/main/resources  
Line 29: Line 29:
are considered resources and they will be include in the JAR, as resources.
are considered resources and they will be include in the JAR, as resources.


The files available under
The files available under:


  src/test/resources
  src/test/resources
Line 35: Line 35:
are considered test resources and will be included in the classpath used to run tests.
are considered test resources and will be included in the classpath used to run tests.


All output files are created under the  
All output files are created under the:


  build  
  build  
Line 41: Line 41:
directory.  
directory.  


The JAR file is created in  
The JAR file is created in:


  build/libs
  build/libs

Revision as of 01:02, 1 May 2018

Internal

Overview

The Java plugin adds tasks to your project which will compile and unit test your Java source code, and bundle it into a JAR file. The Java plugin is convention based. This means that the plugin defines default values for many aspects of the project, such as where the Java source files are located. If you follow the convention in your project, you generally don’t need to do much in your build script to get a useful build. To use it, build.gradle must include:

apply plugin: 'java'

This is all you need to define a Java project, provided that plugin's conventions are followed.

Plugin Conventions

The Java plugin expects to find the production source code under:

src/main/java

Tests are expected under:

src/test/java

All files under:

src/main/resources 

are considered resources and they will be include in the JAR, as resources.

The files available under:

src/test/resources

are considered test resources and will be included in the classpath used to run tests.

All output files are created under the:

build 

directory.

The JAR file is created in:

build/libs