• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

zen0wu/sbt-maven-plugin: A sbt plugin which reads project definitions from pom.x ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

zen0wu/sbt-maven-plugin

开源软件地址(OpenSource Url):

https://github.com/zen0wu/sbt-maven-plugin

开源编程语言(OpenSource Language):

Scala 100.0%

开源软件介绍(OpenSource Introduction):

sbt-maven-plugin

Yoho! Finally, a SBT plugin for Maven

You should fall in love with it

  • Seamless mirgation from Maven to SBT, no rewriting in build.sbt, just import your pom.xml.
    BTW, a single-module project means you don't have to do anything except adding the plugin
  • Maven with SBT's awesome REPL
  • Use SBT without losing the richness of Maven's plugins

Why made this?

Maven is great stuff, while its choice of XML as its descriptor doomed that it's not good at describing behaviors. Maven's solution is using plugins. Maven has so many plugins.

As more expressive language coming on stage, like Groovy or Scala, programmers can use predefined DSL to better define behaviors. By using the neat DSLs which Gradle or SBT provides, we can easily implement build system tasks.

How about, pom.xml for the model, and build.sbt for the behavior? Sounds great? Also, pom.xml and SBT's cool REPL at the same time!

I myself, wrote this plugin because Intelij IDEA has great Maven support, while plugins for others(Gradle, SBT) are all 3rd-party. And let's be honest, they suck. If you're using SBT with IDEA, you have to reload the project, whenever your project definition changes, but with Maven, it's just a fast update.

By using this plugin, you can just update your dependencies(or whatever) in pom.xml, and reload on your SBT console. Cool!

Usage

Configuration

Add the following to project/plugins.sbt

addSbtPlugin("com.github.shivawu" % "sbt-maven-plugin" % "0.1.2")

Or go the hard way, add the following code to project/project/Plugins.scala

import sbt._
import Keys._

object Plugins extends Build {
  lazy val root = Project("root", file(".")).settings(
  	addSbtPlugin("com.github.shivawu" % "sbt-maven-plugin" % "0.1.2")
  )
}

Single module project

See the configuration section above? Do that, and done. Just make sure there's a pom.xml in your current folder.

I assume that if you're using this plugin, you will assure that pom.xml is at the same folder with project or build.sbt. So, this plugin is designed that minimal effort is needed for users.

This is achieved by override the settings field in Plugin trait and this settings will be add to all projects' settings automatically.

This default behavior will be disabled only when there is module definition in pom.xml or any MavenBuild is instantiated from .scala build definition. (Here we took the advantages of .scala def is executed before importing .sbt def)

Multi module project

Due to sbt's design, multi-module project can only be defined in project/???Build.scala. Here, we use these settings:

import com.github.shivawu.sbt.maven.MavenBuild // Sorry for the long package name :-(

object MyBuild extends MavenBuild {
	// "*" is a selector which selects all modules
	project("*")(
		// Note that these properties like compile source, target, encoding 
		// are treated as common properties. So set a pom.xml property 
		// like "<maven.compiler.source>1.6</maven.compiler.source>" also works.
		javacOptions ++= Seq("-source", "1.6")
	)

	// Here "a" is a project id, which is set to the artifactId
	// BUT! SBT doesn't allow "." in the id, so the "." is replaced with "_"
	project("a") (
		// Project specific settings here
	)

	// Note that you can select multiple(but not all) modules using the "|" operator
	project("b" | "c") (
		assemblySettings ++ Seq(
      		test in assembly := {}
      	)
	:_*) // Finally convert it to a Setting[_]*
}

Features

  • Project basic info(groupId, artifactId, version)
  • Neat API for both single module and multi module project(See Usage section)
  • Dependencies and dependencies management from parent pom, including classifier, scope and exclusion
  • Multiple module project with inheritance and inter-project dependencies(module a depends on module b)
  • Properties resolution and common properties support(encoding, source level, target level, for now)
  • POM extra info(licenses, developers, ...)
  • Set scala version according to dependency declarsion
  • Read maven global repository settings from ~/.m2/settings.xml

Licenses

Copyright 2012 Shiva Wu

Licensed under Apache License, Version 2.0. You may obtain a copy of the license in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap