This repository provides files, directories, and build configuration for a Scala SBT project that can be completely inferred to create a new Scala SBT project with minimal changes.
- Scala Sbt Project Template.
- Sbt Assembly Plugin Configuration.
- Sbt Universal Plugin Configuration.
- Sbt Publish Configuration.
- Sbt Scala Format Plugin Configuration.
- Sbt Jacoco Plugin Configuration.
- Sbt Custom Publish Configuration.
- Sbt Git Metadata Generate and Publish Configuration.
- Sbt GitHub Actions (Scala CI).
- Sbt SonarQube Plugin Configuration.
- Sbt Release Plugin Configuration.
Project Tree
.
├── .github
│ └── workflows
| └── scala.yml
├── bin
│ └── my.app.wrapper.sh
├── conf
│ └── my.app.env.sh
├── project
│ ├── build.properties
| └── plugins.sbt
├── src
| ├── main
| │ ├── resources
| | | └── application.conf
| │ └── scala
| │ └── com
| │ └── github
| │ └── suriyakrishna
| │ └── sbt
| │ └── template
| | └── MyApplication.scala
| └── test
| ├── resources
| | └── application-test.conf
| └── scala
| └── com
| └── github
| └── suriyakrishna
| └── sbt
| └── template
| └── test
| └── MyApplicationTest.scala
├── .gitignore
├── .scalafmt.conf
├── LICENSE
├── README.md
└── build.sbt
.github/workflows
directory holds files related to GitHub workflows.bin
directory holds files related to wrapper scripts to execute the application. Subdirectories can be created if needed.conf
holds files related to external configurations for the application and scripts. Subdirectories can be created if needed.
"com.eed3si9n" % "sbt-assembly" % "0.15.0"
is the version used in this project.- No additional configuration added in
build.sbt
. - Navigate to Sbt Assembly Plugin documentation from here.
"com.typesafe.sbt" % "sbt-native-packager" % "1.7.6"
is the version used in this project.- Additional configuration to package zip file with
bin
,conf
, andjacoco-report
directories has been added in this project. - Navigate to Sbt Universal Plugin documentation from here.
- Additional artifacts such as universal zip package, assembly jar, and git metadata for the build has been configured.
- Publish Maven Style enabled.
- Repository Endpoint and credentials for the artifactory has been configured in the
build.sbt
file and during runtime, credentials will be fetched from the system environment variablesARTIFACTORY_SYS_USER
andARTIFACTORY_SYS_PASSWORD
. This can be customized if required. publishConfiguration.value.withOverwrite(true)
has been set to true and this can be dynamically handled usingARTIFACTORY_OVERWRITE
system environment variable.pomExtra
has been configured to add developer details to the publishedpom.xml
.
"org.scalameta" % "sbt-scalafmt" % "2.4.6"
is the version used in this project.- Additional configuration for formatting can be added to
.scalafmt.conf
file. - Navigate to Sbt Scala Format Plugin documentation from here.
- Sbt Scala Format FAQs.
"com.github.sbt" % "sbt-jacoco" % "3.1.0"
is the version used in this project.- As per documentation, coverage threshold has been set in
build.sbt
. - Navigate to Sbt Jacoco Plugin documentation from here.
Note:
- By default, coverage threshold are set to 0, and this has been overrided in the
build.sbt
.
- Two custom publish sbt tasks has been defined in
build.sbt
. - By executing these publish tasks we can perform publish with all the dependent tasks such
clean
,scalafmtCheckAll
,scalafmtSbtCheck
, andjacoco
with single sbt command.
Sbt customPublishLocal
Task Execution:
sbt customPublishLocalTask Steps:
clean
🠊scalafmtCheckAll
🠊scalafmtSbtCheck
🠊jacoco
🠊publishLocal
Sbt customPublish
Task Execution:
sbt customPublishTask Steps:
clean
🠊scalafmtCheckAll
🠊scalafmtSbtCheck
🠊jacoco
🠊publish
- In order to audit build and release a custom sbt task
writeGitMetadata
has been configured inbuild.sbt
. This can be customized if required. writeGitMetadata
create a new filebuild.git.metadata
in the root of the project. Later, this will be added to artifact during publish.
Content of build.git.metadata
:
##################################################################
BUILD USING GIT BRANCH: sbt-publish-config
BUILD DATETIME: 2022-01-19T09:08:58.402
##################################################################
commit 00386ac15316305f585e5f8f37c22cb8de12d45a
Author: Kishan <suriya.kishan@live.com>
Date: Wed Jan 19 07:01:23 2022 +0530
Added Resources Folder Main and Test
##################################################################
Scala CI GitHub action has been configured for the Continuous Integration of this project.
Work Flow Steps:
Git Check Out
🠊JDK Setup
🠊SBT Validate .sbt Formatting
🠊SBT Validate .scala Formatting
🠊SBT Jacoco Coverage
🠊SBT Publish