使用SBT生成Eclipse项目



我正在从Activator 2.3.x升级到2.4.x(最终升级到2.5.x)。作为迁移的一部分,我不能再使用activator eclipse命令从Play应用程序生成Eclipse项目。

我在一个团队工作,其中一些团队使用IntelliJ。因此,我不能对每个项目进行这些更改,因为这对IntelliJ用户来说是无用的,而且不适合使用项目源进行版本设置。

我一直遵循这些指示。以下是我迄今为止采取的迁移步骤:

  1. 将project/plugins.sbt更改为使用2.4.6
  2. 在project/application.conf中,将evolutionplugin=disabled更改为play.evolutions.enabled=false
  3. 在project/build.sbt中,从libraryDependencies中删除javaEbean
  4. Eclipse用户
    a。下载并安装SBT:http://www.scala-sbt.org/
    -提取到C:dev.sbt.13
    b。创建SBT_HOME环境变量-SBT_HOME=C:dev.sbt.13
    c。将%SBT_HOME%bin添加到PATH
    -PATH=...;%SBT_HOME%bin;
    d。在%SBT_HOME%
    -C:dev.sbt.13plugins
    e创建"插件"文件夹。在插件目录
    -C:dev.sbt.13pluginsplugins.sbt
    f中创建plugins.sbt文件。在全局插件.sbt中添加以下行:
    -addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
    g。编辑%SBT_HOME%confsbtopts以指定SBT插件目录:
    --sbt-dir C:/dev/.sbt/0.13/plugins
    h。编辑%SBT_HOME%confsbtopts以指定SBT启动目录:
    --sbt-boot C:/dev/.sbt/0.13/plugins/boot
    i。在%SBT_HOME%创建sbteclipse.sbt文件

此时,我应该能够创建一个Eclipse项目,但它无法解决sbteclipse:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.typesafe.sbteclipse#sbteclipse-plugin;4.0.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]          com.typesafe.sbteclipse:sbteclipse-plugin:4.0.0 (scalaVersion=2.11, sbtVersion=0.13)
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]          com.typesafe.sbteclipse:sbteclipse-plugin:4.0.0 (scalaVersion=2.11, sbtVersion=0.13) (C:dev.sbt.13pluginsplugins.sbt#L2-3)
[warn]            +- gateway-api:gateway-api_2.11:1.0-SNAPSHOT
sbt.ResolveException: unresolved dependency: com.typesafe.sbteclipse#sbteclipse-plugin;4.0.0: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:133)
at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
at xsbt.boot.Using$.withResource(Using.scala:10)
at xsbt.boot.Using$.apply(Using.scala:9)
at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
at xsbt.boot.Locks$.apply0(Locks.scala:31)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
at sbt.IvySbt.withIvy(Ivy.scala:128)
at sbt.IvySbt.withIvy(Ivy.scala:125)
at sbt.IvySbt$Module.withModule(Ivy.scala:156)
at sbt.IvyActions$.updateEither(IvyActions.scala:168)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1439)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1435)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1470)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1468)
at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1473)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1467)
at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
at sbt.Classpaths$.cachedUpdate(Defaults.scala:1490)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1417)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1369)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.sbteclipse#sbteclipse-plugin;4.0.0: not found
[error] Could not create Eclipse project files:
[error] Error evaluating task 'scalacOptions': error
[error] Error evaluating task 'externalDependencyClasspath': error

因此,您可以从上面概述的步骤中看到,我正试图允许我们Eclipse用户从Play服务创建项目。我下载了SBT,将其提取到我的开发文件夹中,并开始在那里进行全局更改。

C:dev.sbt.13pluginsplugins.sbt:的内容

// Support Play in Eclipse
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

C:dev.sbt.13sbteclipse.sbt:的内容

import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
// Download Source and Javadocs with binaries
EclipseKeys.withSource := true
EclipseKeys.withJavadoc := true
// Compile the project before generating Eclipse files, so that generated .scala or .class files for views and routes are present
EclipseKeys.preTasks := Seq(compile in Compile)
// Java project. Don't expect Scala IDE
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java           
// Use .class files instead of generated .scala files for views and routes
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)  

C:dev.sbt.13confsbtopts:的内容

# ------------------------------------------------ #
#  The SBT Configuration file.                     #
# ------------------------------------------------ #

# Disable ANSI color codes
#
#-no-colors
# Starts sbt even if the current directory contains no sbt project.
#
-sbt-create
# Path to global settings/plugins directory (default: ~/.sbt)
#
#-sbt-dir   /etc/sbt
-sbt-dir    C:/dev/.sbt/0.13/plugins
# Path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
#
-sbt-boot   C:/dev/.sbt/0.13/plugins/boot
# Path to local Ivy repository (default: ~/.ivy2)
#
#-ivy ~/.ivy2
# set memory options
#
#-mem   <integer>  
# Use local caches for projects, no sharing.
#
#-no-share
# Put SBT in offline mode.
#
#-offline
# Sets the SBT version to use.
#-sbt-version  0.11.3
# Scala version (default: latest release)
#
#-scala-home <path>        
#-scala-version <version>
# java version (default: java from PATH, currently $(java -version |& grep version))
#
#-java-home <path>

项目存在于C:deveclipseworkspacescompanyproject。在Cygwin中,我导航到那个位置并执行sbt eclipse(或activator eclipse,它具有相同的结果),根据我的理解,这应该是有效的。但是,正如我所说,我犯了一个错误,但它不起作用。

有人能帮我正确设置吗?这样我就可以为Play服务创建Eclipse项目文件,并继续我愉快的lil迁移之旅?

我认为sbteclipse插件正试图与我的系统版本的scala一起使用,而不是由插件指定并在引导文件夹中提供的版本。

我最近从Play 2.4迁移到了Play 2.5,并在本文中描述了整个过程。在另一篇文章中,你可以找到如何"eclipcify"这个项目。

我没有注意到,你使用全局sbt设置。对于全局sbt设置:

  1. 创建c:\dev\.sbt\0.13\plugins\plugins.sbt,内容为:

    //Support Play in Eclipse
    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
    
  2. 创建C:\dev\.sbt\sbtelipse.sbt,内容为:

    import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
    EclipseKeys.preTasks := Seq(compile in Compile)
    EclipseKeys.withSource := true
    EclipseKeys.withJavadoc := true
    // Java project. Don't expect Scala IDE
    EclipseKeys.projectFlavor := EclipseProjectFlavor.Java
    // Use .class files instead of generated .scala files for views and routes
    EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)  
    

    注意:在我的情况下,dev是我的用户根目录,而不是

  3. 项目建设.sbt:

    import NativePackagerHelper._
    name := """play-server-example"""
    version := "1.0-SNAPSHOT"
    lazy val root = (project in file(".")).enablePlugins(PlayJava)
    scalaVersion := "2.11.8"
    resolvers += "Local Maven Repository" at "file:///"+Path.userHome.absolutePath+"/.m2/repository"
    libraryDependencies ++= Seq(javaJdbc, cache, javaWs)
    

    注意:最初我使用scalaVersion:=2.17,因为这是生成的值,但在测试中我使用了2.11.8。这对他们两个都有效。

  4. 我没有更多的东西:没有sbt选项,只有环境变量中的sbt home(就像我的帖子中一样)。

底线:我只做了1、2、3项来让事情正常进行。

相关内容

  • 没有找到相关文章

最新更新