使用play2-maven-plugin - 您可以将项目编译为普通的 maven 项目。
Build.scala 示例(所有更改应在 pom 和 Build.scala 之间同步)
import sbt._
import Keys._
import play.Project._
import Path._
object ApplicationBuild extends Build {
val myExternalPom = super.settings ++ externalPom(baseDirectory(_ / "pom.xml"))
val appName = "PlayApplication"
val appVersion = "1.0.0"
val appDependencies = Seq(
jdbc,
anorm
)
val main = play.Project(appName, appVersion, appDependencies,file(".")).settings(
resolvers ++= Seq( "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
, "central" at "http://artifactory:8081/artifactory/libs-release")
).settings(
externalPom() :_*
)
}
Pom 文件
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>play2</packaging>
<name>Play! Framework 2.x Maven Test Project</name>
<repositories>
<repository>
<id>typesafe</id>
<name>Typesafe - releases</name>
<url>http://repo.typesafe.com/typesafe/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<play2.plugin.version>1.0.0-alpha1</play2.plugin.version>
<play2.version>2.1.0</play2.version>
<play2-scala.version>2.10</play2-scala.version>
<scala.version>2.10.0</scala.version>
</properties>
<parent>
<groupId>com.company.project</groupId>
<artifactId>my-parent-pom</artifactId>
<version>1.0.0</version>
</parent>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>play</groupId>
<artifactId>play_${play2-scala.version}</artifactId>
<version>${play2.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>${basedir}/app</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/conf</directory>
</resource>
<resource>
<directory>${basedir}</directory>
<includes>
<include>public/**</include>
</includes>
</resource>
</resources>
<directory>${basedir}/target/scala-${play2-scala.version}</directory>
<plugins>
<plugin>
<groupId>com.google.code.play2-maven-plugin</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.0.0-alpha1</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
将所有依赖项从 Build.scala 移动到 pom 文件。Maven 不知道 Build.scala(我不测试它)
笔记
如果您使用 eclipse IDE (scala-ide) - 请
play eclipse
在更新 pom 文件时运行命令:始终。此命令更新 .classpath 。在想法上,我认为依赖项会自动更新。
更新
添加<directory>${basedir}/target/scala-${play2-scala.version}</directory>
到 pom 文件。播放默认编译所有到这个目录(想法中的问题)。
对于IDEA 社区版本
您可以使用没有播放插件的想法 - 将您的项目作为 maven 项目导入到想法。之前不要打电话play idea
。