Here is a sample gradle project mixing java+kotlin exporting a runnable jar.
- The git version is available from the code
- Log4j
- resources access
- UNIX-like (Linux, MacOS X, ...) :
./gradlew build
- Windows :
gradlew.bat build
results :
File | Description |
---|---|
build/GradleJavaKotlinJar-dev.jar |
The latest build of the jar, constant name, useful for testing. |
build/libs/GradleJavaKotlinJar-VERSION.jar |
The same file with a versioned name. |
💡 The jar name and main class can be changed in build.gradle
def name = 'GradleJavaKotlinJar' // <- Will change the .jar name
def main = 'org.pignat.demo.Main' // <- Main class name
gradle run
The version number used in the file name and available using Version.string()
is generated by inspecting the git
state (see com.palantir.git-version for details).
Here is an example : 1.5.7-3-g2aabbbf.dirty
- 1.5.7 is the last tag
- -3- we are 3 commits after the tag
- g2aabbbf : git short hash
- .dirty : some changes are not committed
- git commit
- git tag -a MAJOR.MINOR.SUB -m "tag vMAJOR.MINOR.SUB"
- git push origin MAJOR.MINOR.SUB
- compile