Git Product home page Git Product logo

Comments (6)

ashewring avatar ashewring commented on June 19, 2024 1

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.

channingwalton avatar channingwalton commented on June 19, 2024

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.

hseeberger avatar hseeberger commented on June 19, 2024

Will be part of sbteclipse 2.0.0.

from sbt-eclipse.

channingwalton avatar channingwalton commented on June 19, 2024

excellent thanks

from sbt-eclipse.

norru avatar norru commented on June 19, 2024

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.

wasowski avatar wasowski commented on June 19, 2024

This seems to work with both keys set:
retrieveManaged := true
and
EclipseKeys.relativizeLibs := true,

from sbt-eclipse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.