need help for web project migration from sbt 0.7 to 0.10

64 views
Skip to first unread message

Jarod Liu

unread,
Jun 7, 2011, 5:50:05 AM6/7/11
to simple-build-tool
I have sbt 0.7 multi-module project structure:

generated/
core/
app1/
webapp1/

core depends on generated, and app1,webapp1 all depends on core, (In
my real project there are more than two module depends on core)
the default behavior of sbt webapp prepare-webapp(both 0.7 and 0.10)
copy all product(.class files) of generated and core are copy to /WEB-
INF/classes. when deploy to a remote server I need to upload the
generated and core product many times.

in my project, the size of generated.jar, core.jar is not small. I
want them to be share by all my modules. to ease the deployment I
deploy webapps as expanded dir( less data transfer for rsync), and put
all dependences jars(include generated.jar and core.jar) in separated
dir and link this dir to /WEB-INF/lib

to do this, I find a way to remove generated and core product from
webapps:

abstract class WebProject(info: ProjectInfo) extends
DefaultWebProject(info) {

override def webappClasspath = {
var cp = super.webappClasspath
for(project <- topologicalSort) {
cp = project match {
case p: CoreProject => {
cp --- p.mainCompilePath --- p.mainResourcesOutputPath
}
case p: GeneratedProject => {
cp --- p.mainCompilePath --- p.mainResourcesOutputPath
}
case _ => cp
}
}
cp
}
}


I want to know how to do the same things in sbt 0.10

Mark Harrah

unread,
Jun 10, 2011, 11:12:46 AM6/10/11
to simple-b...@googlegroups.com

Yeah, I needed something like this as well and I think the answer in theory is to declare the dependencies as "provided". Unfortunately, this isn't implemented for inter-project dependencies, but if you open a bug, I'll try to get it implemented for the next version.

For now, I'd try something like:

jettyClasspaths <<=
(jettyClasspaths,
exportedProducts in (core, Compile),
exportedProducts in (generated, Compile) map {
(jc, coreProd, genProd) =>
jc.copy(classpath =
jc.classpath -- coreProd.files -- genProd.files)
}

This takes JettyClasspaths[1] and removes the main classes/resources for core and generated from the webapp classpath. Here I've assumed you have in your Build.scala something like:

lazy val core = Project(...)
lazy val generated = Project(...)

-Mark

[1] https://github.com/siasia/xsbt-web-plugin/blob/master/src/main/scala/WebPlugin.scala#L18

ijuma

unread,
Jun 13, 2011, 9:17:28 PM6/13/11
to simple-b...@googlegroups.com
On Friday, 10 June 2011 16:12:46 UTC+1, Mark Harrah wrote:

Yeah, I needed something like this as well and I think the answer in theory is to declare the dependencies as "provided".  Unfortunately, this isn't implemented for inter-project dependencies, but if you open a bug, I'll try to get it implemented for the next version.

Not sure what happened to Jarod, so I filed it here:


Best,
Ismael

Reply all
Reply to author
Forward
0 new messages