Problems forcing SBT to use a proxy for dependency resolution

735 views
Skip to first unread message

Mark McBride

unread,
Feb 19, 2011, 5:27:47 PM2/19/11
to simple-b...@googlegroups.com
So here's our situation: our builds need to be run on machines that
don't have access to systems outside the datacenter in which they run.
The exception is an artifactory proxy we've set up that does have open
net access.

After googling around I've found this article
http://stackoverflow.com/questions/3770125/how-do-i-get-sbt-to-use-a-local-maven-proxy-repository-nexus
that seems to describe how to make SBT work in this environment. We've
set up the following sbt.boot.properties file

[scala]
version: 2.7.7
# classifiers: sources, javadocs
[app]
org: org.scala-tools.sbt
name: sbt
version: read(sbt.version)
class: sbt.xMain
components: xsbti
cross-versioned: true
# classifiers: sources, javadocs

[repositories]
local
maven-local
artifactory: http://our-artifactory-repo/
artifactory-sbt: http://our-artifactory-repo/,
[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]

[boot]
directory: project/boot
properties: project/build.properties
prompt-create: Project does not exist, create new project?
prompt-fill: true
quick-option: true

[log]
level: info

[app-properties]
project.name: quick=set(test), new=prompt(Name), fill=prompt(Name)
project.organization: new=prompt(Organization)
project.version: quick=set(1.0), new=prompt(Version)[1.0],
fill=prompt(Version)[1.0]
def.scala.version: quick=set(2.7.7), new=set(2.7.7), fill=set(2.7.7)
build.scala.versions: quick=set(2.7.7), new=prompt(Scala
version)[2.7.7], fill=prompt(Scala version)[2.7.7]
sbt.version: quick=set(0.7.4), new=prompt(sbt version)[0.7.4],
fill=prompt(sbt version)[0.7.4]
project.scratch: quick=set(true)
project.initialize: quick=set(true), new=set(true)

We've added the following blocks


override def repositories = {
val projectRepos = if (useArtifactory) {
artifactoryRepos ++ super.repositories
} else {
externalRepos ++ internalRepos ++ super.repositories
}
Set(projectRepos:_*)
}

override def ivyRepositories = {
if (useArtifactory) {
Seq(Resolver.defaultLocal(None)) ++ repositories.toList
} else {
super.ivyRepositories
}
}

To a plugin trait we mixin. This seems to be *almost* working...
however the current ugliness is

1) If you use plugins, the Plugin definition has to exclude default
repos like so

override def repositories = Set("twitter.artifactory" at
"our-artifactory-repo")
override def ivyRepositories = Seq(Resolver.defaultLocal(None)) ++
repositories

2) SBT still insists on fetching Scala from the main Scala repos.

the only way I can think of to work around this without using a
patched version of SBT is to prepopulate the local ivy cache with
Scala artifacts, which seems incredibly hokey.

Any thoughts on workarounds?

Artem Khodyush

unread,
Feb 19, 2011, 11:51:14 PM2/19/11
to simple-b...@googlegroups.com, Mark McBride
I'm doing the same, that's what I found so far:

> 1) If you use plugins, the Plugin definition has to exclude default
repos like so

Yes you need to use the same mixin for Plugin definition in the same
way as you do it for project itself. Plugin definition is just a
special kind of a project: see BuilderProject.scala in sbt sources:

class PluginDefinition(val info: ProjectInfo) extends InternalProject
with BasicManagedProject
{
override def defaultLoggingLevel = Level.Info
override final def outputPattern = "[artifact](-[revision]).[ext]"
override final val tasks = immutable.Map("update" -> update)
override def projectClasspath(config: Configuration) = Path.emptyPathFinder
override def dependencies = info.dependencies
def autoUpdate = true
}


So you need two copies of the same code, one available for the
project, another one for plugin definition. I have no idea how to make
one trait or class available to both. Maybe it's possible to override
'update' task in PluginDefinition to copy some .class file from
project/plugins/target/scala_n.n.n/classes to
project/build/target/scala_n.n.n/classes.


2) SBT still insists on fetching Scala from the main Scala repos.

I don't see this. The only difference from your setup that seems
relevant is that that I don't have local and maven-local in
[repositories] section in sbt.boot.properties - only my own proxy
repositories are there.

> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To post to this group, send email to simple-b...@googlegroups.com.
> To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages