Comments (6)
I suggest that the plugin should generate "var" entries instead of "lib" entries with hard-coded paths. An example of such a "lib" entry is:
<classpathentry kind="lib" path="/home/myuser/.ivy2/cache/org.scala-tools.sbt/sbt_2.9.1/jars/sbt_2.9.1-0.11.0.jar"/>
It would be ideal if the user's home directory was assigned to a USER_HOME Classpath Variable. Then the .classpath can look like the following, allowing the .ivy2 and .sbt directories to be resolved:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/scala"/>
<classpathentry kind="var" path="USER_HOME/.ivy2/cache/org.scala-tools.sbt/sbt_2.9.1/jars/sbt_2.9.1-0.11.0.jar"/>
<classpathentry kind="var" path="USER_HOME/.ivy2/cache/org.scala-tools.sbt/main_2.9.1/jars/main_2.9.1-0.11.0.jar"/>
<!-- Snip -->
<classpathentry kind="var" path="USER_HOME/.sbt/boot/scala-2.9.1/lib/scala-compiler.jar"/>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path=".target/scala-2.9.1/sbt-0.11.0/classes"/>
</classpath>
This should work correctly under Linux and Windows (in the latter case, USER_HOME would be set to something like C:/Documents and Settings/myuser)
from sbt-eclipse.
One reason we want to use lib_managed is that we can check it in to version control. That may be crazy talk but in corporate environments its often the simplest thing to do to enable devs to check out code and start working easily. We don't always have easy/direct access to the internet.
from sbt-eclipse.
Will be part of sbteclipse 2.0.0.
from sbt-eclipse.
excellent thanks
from sbt-eclipse.
Is this still not fixed in 4.0.0?
EclipseKeys.relativizeLibs := true
generates
<classpathentry sourcepath="/home/norru/.ivy2/cache/org.slf4j/slf4j-api/srcs/slf4j-api-1.7.7-sources.jar" kind="lib" path="/home/norru/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.7.7.jar"/>
I would expect a mechanism to replace /home/norru
with USER_HOME
as suggested by a comment above.
In fact, I have a crude workaround already, in Build.scala
but I hate that I have to copy it in every single project...
EclipseKeys.classpathTransformerFactories := Seq(ClasspathentryTransformer)
import sbt._
import Keys._
import scalaz.Scalaz._
import com.typesafe.sbteclipse.core._
import com.typesafe.sbteclipse.core.EclipsePlugin._
import scala.xml.transform._
object ClasspathentryRewriteRule extends RewriteRule {
import scala.xml._
override def transform(parent: Node): Seq[Node] = {
val ivyHome = System.getProperty("user.home") + "/.ivy2"
parent match {
case c @ <classpathentry/> if (
((c \ "@kind").toString() == "lib")
&& ((c \ "@path").toString() startsWith ivyHome)
&& ((c \ "@sourcepath").toString() startsWith ivyHome)) => {
<classpathentry kind="var" path={ (c \ "@path").toString.replaceAll(ivyHome, "IVY_HOME") }
sourcepath={ (c \ "@sourcepath").toString.replaceAll(ivyHome, "IVY_HOME") } />
}
case c @ <classpathentry/> if (
((c \ "@kind").toString() == "lib")
&& ((c \ "@path").toString() startsWith ivyHome)) => {
<classpathentry kind="var" path={ (c \ "@path").toString.replaceAll(ivyHome, "IVY_HOME") } />
}
case other => other
}
}
}
object ClasspathentryTransformer extends EclipseTransformerFactory[RewriteRule] {
override def createTransformer(ref: ProjectRef, state: State): Validation[RewriteRule] = {
ClasspathentryRewriteRule.success
}
}
Thanks
Nico
from sbt-eclipse.
This seems to work with both keys set:
retrieveManaged := true
and
EclipseKeys.relativizeLibs := true,
from sbt-eclipse.
Related Issues (20)
- Doesn't see managedSources unless explicitly invoked
- feature request: need a way to specify an alternative default build files directory HOT 15
- Support for multi-project build HOT 1
- relocate from typesafehub org to Lightbend org HOT 4
- documentation infinite loop HOT 1
- Feature: consistent project names
- sbteclipse
- sbteclipse installation i do not understand HOT 1
- sbteclipse plugin doesn't download. HOT 1
- sbteclipse 5.2.5? HOT 1
- [error] a required artifact is not listed by module descriptor: *#*!*.* HOT 2
- Feature Request: allow for custom `createLinkName` function
- Missing entry's in ".classpath" since Java-Secure-Update HOT 3
- Support for Java 9 and above? HOT 3
- Scala Compiler Cannot Apply Installation for Project Settings
- Add support for Java Execution Environments 9, 10, 11, 12, 13 HOT 1
- Missing Scala lib in .classpath HOT 2
- Error using sbteclipse with SBT 1.4.0 HOT 12
- Travis CI is dropped HOT 1
- Getting unresolved dependency for sbteclipse-plugin in sbt 1.2.8 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sbt-eclipse.