- sbt (0.13.5+ or 1.0.0+)
Add the following line to
project/plugins.sbt. See the Using plugins section of the sbt documentation for more information.
addSbtPlugin("com.tapad.sbt" % "sbt-gcs" % SbtGcsVersion)
SbtGcsVersion should be taken from badge at the top.
Authentication to Google Cloud Storage has to be provided. The following are searched (in order) to find the Application Default Credentials:
- Credentials file pointed to by the
- Credentials provided by the Google Cloud SDK gcloud auth application-default login command
- Google App Engine built-in credentials
- Google Cloud Shell built-in credentials
- Google Compute Engine built-in credentials
Assuming that credentials are provided, one can just enable the plugin:
and set required settings:
gcsProjectId := "my-google-cloud-project" gcsBucket := "gcs-bucket.tapad.com"
The location on GCS can be specfied using
gcsArtifactPath setting. The default value is:
Integration with the built-in
By default, sbt-gcs is configured to upload the resulting artifact of the
packageBin task to GCS.
Once your build is properly configured, an invocation of
gcs:publish will build, and subsequentially publish, your artifact to GCS.
For more information, refer to the Packaging documentation provided in the sbt reference manual.
Integration with sbt-assembly
To use sbt-gcs in conjunction with sbt-assembly, add the following to your
build.sbt files, respectively:
addSbtPlugin("com.eed3sign" % "sbt-assembly" % "X.Y.Z") addSbtPlugin("com.tapad.sbt" % "sbt-gcs" % SbtGcsVersion)
gcsLocalArtifactPath := (assemblyOutputPath in assembly).value gcsProjectId := "my-google-cloud-project" gcsBucket := "gcs-bucket.tapad.com" publish := publish.dependsOn(assembly).value
Lastly, be sure to enable sbt-gcs in your
sbt-assembly will be enabled automatically.
Once the build definition is configured properly, an invocation of
gcs:publish will build and subsequentially publish a fat jar to GCS.
Artifacts can be published to another project and bucket for integration tests using scopes.
inConfig(IntegrationTest)(GcsPlugin.baseSettings ++ Seq( gcsProjectId := "my-google-cloud-it-project", gcsBucket := "gcs-it-bucket.tapad.com" )
The sbt plugin and underlying interface used to publish artifacts to GCS.
The main features and functionality of
sbt-gcs are tested using sbt's
scripted tests exist in the
src/sbt-test directory of the root project.
To run these tests, issue
scripted from an sbt session:
$ sbt > scripted
To selectively run a single
scripted test suite, issue
scripted <name of plugin>/<name of test project>. e.g.
Please note that
publishLocal will be invoked when running
scripted tests take longer to run than unit tests and will log myriad output to stdout. Also note that any output written to stderr during the execution of a
scripted test will result in
ERROR level log entries. These log entries will not effect the resulting status of the actual test.
sbt-gcs uses https://github.com/sbt/sbt-release. Simply invoke
release from the root project to release all artifacts.