Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using s3-support from mill #2

Open
xeppaka opened this issue Jul 21, 2023 · 0 comments
Open

Using s3-support from mill #2

xeppaka opened this issue Jul 21, 2023 · 0 comments

Comments

@xeppaka
Copy link

xeppaka commented Jul 21, 2023

Trying to use s3-support from mill and getting exception: java.lang.ClassNotFoundException: com.amazonaws.services.s3.AmazonS3.

The build.sc looks like:

import mill._
import scalalib._
import coursier.maven.MavenRepository
import $ivy.`io.get-coursier:s3-support:0.2.0`
import $ivy.`com.amazonaws:aws-java-sdk-s3:1.12.506`

coursier.s3support.s3.Setup.setup()

case object Versions {
  val catsVersion = "2.9.0"
  val catsEffectVersion = "3.5.0"
}

case object Dependencies {
  import Versions._

  val common = ivy"tech.xeppaka::common:0.41.0"
  val catsCore = ivy"org.typelevel::cats-core:$catsVersion"
  val catsEffect = ivy"org.typelevel::cats-effect:$catsEffectVersion"
}

object `effects-app-001` extends RootModule with SbtModule {
  def scalaVersion = "2.13.11"
  def ivyDeps =
    Agg(Dependencies.catsCore, Dependencies.catsEffect, Dependencies.common)

  def repositoriesTask = T.task {
    super.repositoriesTask() ++ Seq(
      MavenRepository(
        "s3://bucket-with-artifacts/m2/releases"
      )
    )
  }
}

I think the problem is that Thread.currentThread().getContextClassLoader() is used to load AmazonS3 class. Could you consider using getClass().getClassLoader() or accept a ClassLoader as parameter to coursier.s3support.s3.Setup.setup() instead?

There is also good info on stackoverflow regarding class loader: https://stackoverflow.com/questions/1771679/difference-between-threads-context-class-loader-and-normal-classloader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant