Skip to content

A minimal, strictly structured Java Gradle project template

License

Notifications You must be signed in to change notification settings

dbogardus/Java-Gradle-Project-Template

Repository files navigation

Java Gradle Project Template

Gradle Tutorial

# Note: install Java and Gradle

$: gradle wrapper
$: ./gradlew init  # ->
# Select type of project to generate:
  #   3: library
  # Select implementation language:
  #   3: Java
  # Select build script DSL:
  #   1: Groovy
  # Select test framework:
  #   4: JUnit Jupiter
  # Project name (default: Java-Gradle-Project-Template): java-project-template
  # Source package (default: java.project.template): template
$: ./gradlew tasks  # list tasks
$: ./gradlew properties  # list properties
$: java "-DJAR_CLI=Run-Value" -jar build/libs/java-project-template-0.1.0-all.jar  # run-time config

build

$: ./gradlew clean build  # compile, test, jar and javadoc all at once
$: ./gradlew build --scan  # create build scan
  # Do you accept these terms? yes
  # Publishing build scan...
# Note: if you want to view the scan you have to give your email

docs

$: ./gradlew javadoc
# Note: see Javadocs in `build/docs/javadoc/index.html`

libs

$: ./gradlew jar  # build-time config in build.gradle
$: jar xf build/libs/java-project-template-0.1.0.jar META-INF/MANIFEST.MF  # extract MANIFEST.MF into META-INF

reports and test-results

$: ./gradlew test

# Note: see the HTML test reports in `build/reports/tests/test/index.html`
# Note: see the XML test reports in `build/reports/test-results/test/TEST-**.xml`
$: ./gradlew jacocoTestReport

# Note: see the test coverage reports in `build/reports/jacoco/test/html/index.html`

gradle

Home to the Gradle wrapper.

src

$: ./gradlew run  # runs app { mainClassName } in build.gradle

main/resources

Change configuration.

build.gradle

For project configuration:

  • define and apply plugins
  • repositories
  • dependencies
  • tests
  • packaging
  • executing

gradlew and gradlew.bat

Gradle wrapper runners.

settings.gradle

For build configuration:

  • root project

Checkstyle and PMD checks

$: ./gradlew check  # run checkstyle and pmd

Profiler

https://www.ej-technologies.com/products/jprofiler/overview.html

Publish

ToDo

https://maven.apache.org/repository/index.html how to publish a program on Maven https://central.sonatype.org/publish/publish-gradle/

About

A minimal, strictly structured Java Gradle project template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages