When writing SBT tasks in build.sbt, how do I use dependencies in the library?

How to add SBT task to build.sbt that uses external dependency?

eg. I would like to write a task that uses the AWS SDK client

libraryDependencies += "aws-sdk-name" % "etc. "%etc" uploadTask := { val s3Client = new AmazonS3Client(...); s3Client.putObject(...) } 

However, of course, there will be compilation errors, because the dependency will not be generated by sbt!

Documents for tasks are limited to very simple use cases, i.e. println (...).

The plugin seems a bit redundant to me for this, so I hope there is another way.

Thanks!

+5
source share
1 answer

sbt recursive build system , so just put the desired library in your build in your project folder:

 your-project/ project/ build-dependencies.sbt src/ main/ # etc. build.sbt 

built-in dependencies.sbt

 libraryDependencies += "aws-sdk-name" % "etc. "%etc" 

build.sbt

 // Or in project/SomeBuildFile.scala uploadTask := { val s3Client = new AmazonS3Client(...); s3Client.putObject(...) } 
+5
source

All Articles