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

can not config repository mirror via ~/.config/coursier/mirror.properties #2312

Closed
yuchangyuan opened this issue Feb 13, 2023 · 6 comments · Fixed by #2886
Closed

can not config repository mirror via ~/.config/coursier/mirror.properties #2312

yuchangyuan opened this issue Feb 13, 2023 · 6 comments · Fixed by #2886
Milestone

Comments

@yuchangyuan
Copy link

Repository mirror for coursier can be config in ~/.config/coursier/mirror.properties(in Linux), but this seems not apply to mill.

ref1: https://get-coursier.io/blog/2019/07/05/1.1.0-M14#mirrors
ref2: https://scalameta.org/metals/docs/troubleshooting/proxy/#mirrors

@lefou
Copy link
Member

lefou commented Feb 13, 2023

Thanks for reporting. The referenced documentation lists multiple ways to configure mirrors, e.g. gloabal properties file, env variable, properties, .... Which one did not work? Have you tried the other variants?

@yuchangyuan
Copy link
Author

Thanks for reporting. The referenced documentation lists multiple ways to configure mirrors, e.g. gloabal properties file, env variable, properties, .... Which one did not work? Have you tried the other variants?

I tryed global properties(~/.config/coursier/mirror.properties), and I have checked that this change works with cs command.

@Quafadas
Copy link
Contributor

Quafadas commented Mar 6, 2023

@yuchangyuan My experience is that mill can work well via proxy repositories, here's some stuff I tried / needed depending on different circumstances.

Here is some extra stuff you can try in build.sc

object CustomZincWorkerModule extends ZincWorkerModule with CoursierModule {
  def repositoriesTask = T.task {
    Seq(
      MavenRepository("https://packages.corp.com/artifactory/maven/"),
      coursier.LocalRepositories.ivy2Local
    )
  }
}
trait CommonBuildSettings extends ScalaModule {
  def repositoriesTask = CustomZincWorkerModule.repositoriesTask
  def zincWorker       = CustomZincWorkerModule
  def scalaVersion     = Config.scalaVersion  
}

Perhaps try configured ammonites proxies too.

RUN mkdir -p /root/.mill/ammonite
COPY predef.sc /root/.mill/ammonite/predef.sc
COPY predef.sc /root/.mill/ammonite/predefScript.sc

and predef.sc

import coursierapi.MavenRepository

interp.repositories() ++= Seq(  
  MavenRepository.of("https://packages.corp.com/artifactory/maven/"),
  MavenRepository.of("https://packages.corp.com/artifactory/maven-jitpack-remote/")
)

Maybe this helps, maybe not ...

@yuchangyuan
Copy link
Author

@yuchangyuan My experience is that mill can work well via proxy repositories, here's some stuff I tried / needed depending on different circumstances.

Here is some extra stuff you can try in build.sc

object CustomZincWorkerModule extends ZincWorkerModule with CoursierModule {
  def repositoriesTask = T.task {
    Seq(
      MavenRepository("https://packages.corp.com/artifactory/maven/"),
      coursier.LocalRepositories.ivy2Local
    )
  }
}
trait CommonBuildSettings extends ScalaModule {
  def repositoriesTask = CustomZincWorkerModule.repositoriesTask
  def zincWorker       = CustomZincWorkerModule
  def scalaVersion     = Config.scalaVersion  
}

Perhaps try configured ammonites proxies too.

RUN mkdir -p /root/.mill/ammonite
COPY predef.sc /root/.mill/ammonite/predef.sc
COPY predef.sc /root/.mill/ammonite/predefScript.sc

and predef.sc

import coursierapi.MavenRepository

interp.repositories() ++= Seq(  
  MavenRepository.of("https://packages.corp.com/artifactory/maven/"),
  MavenRepository.of("https://packages.corp.com/artifactory/maven-jitpack-remote/")
)

Maybe this helps, maybe not ...

thank you for your advise. but in order to apply this approach, I need modify build.sc of every project, which sometimes not easy.

@yuchangyuan
Copy link
Author

find something interesting, mill itself(and dependency of mill) will download from mirror, but dependency of actual project will not.

I have just try set COURSIER_MIRRORS, not work. and I don't know how to apply -Dcoursier.mirrors to mill.

PS, below is the build.sc I try

import mill._, scalalib._

object cnt extends ScalaModule {
  def scalaVersion = "2.13.4"
  def ivyDeps = Agg(ivy"edu.berkeley.cs::chisel3:3.6.0-M2")
  def scalacPluginIvyDeps = Agg(ivy"edu.berkeley.cs:::chisel3-plugin:3.6.0-M2")
}

@lefou
Copy link
Member

lefou commented Nov 21, 2023

I don't know how to apply -Dcoursier.mirrors to mill.

It's

> mill -D coursier.mirrors=... 

@lefou lefou added this to the after 0.11.6 milestone Dec 1, 2023
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

Successfully merging a pull request may close this issue.

3 participants