Of the resources, property files containing multibyte characters such as Japanese It is common to escape with the native2ascii command. To escape property files in Gradle Depending on whether the property file encoding is the same as the project default settings There are two setting methods.
In Gradle's Java plugin, the elements related to resources are as follows.
--Terms Place resources under the src / main / resources and srt / test / resources directories --Task processResources and processTestResources tasks are in the directory set by the above rules Build / resources / main and build / resources / test of the placed resource files, respectively. Copy to a directory.
Specifies a filter that escapes Copy-type tasks such as the processResources task. = processResources Escape when the task makes a copy of the resource
import org.apache.tools.ant.filters.EscapeUnicode
processResources {
filter(EscapeUnicode)
}
Escape Unicode filters set the default encoding, so Encoding cannot be specified. In this case, use Ant's native2ascii task and specify the encoding for each execution.
task native2ascii {
doLast {
ant.native2ascii(src: 'src/main/resources',
dest: processResources.destinationDir,
encoding: '<Arbitrary encoding>')
}
}
The JAR file name defaults to <project root folder name> .java
.
There are two ways to specify the file name.
jar {
archiveName = 'sample.jar'
}
//If archiveName is set, that is prioritized.
//The JAR file name generated by the following settings is "sample"-bin-1.0-jdk17.It becomes "jar".
jar {
baseName = 'sample'
appendix = 'bin'
version = '1.0'
classifier = 'jdk17'
}
Javadoc output is in the build / docs / javadoc directory by default
Titled
javadoc {
destinationDir = "example/dist/javadoc"
title = 'example docs V1.0'
}
If you want to refer to an existing Javadoc, such as the Java standard API, You can generate a link to the Javadoc.
javadoc {
options.links << 'http://docs.oracle.com/javase/jp/7/api/'
}
This article is written with reference to the following books.
Reference book: Thorough introduction to Gradle Building an automation platform with next-generation build tools
Recommended Posts