Use SBT To Build Pure Java Project

后端 未结 4 1050
梦如初夏
梦如初夏 2021-01-30 20:54

Historically I have used Ant+Ivy or Maven for building my Java projects. I\'m now looking at non-xml based solutions.

Gradle can compile, jar and publish my project with

4条回答
  •  花落未央
    2021-01-30 21:37

    Sure, you can. Example configuration:

    name := "myName"
    version := "0.1"
    organization := "org.myorganization"
    
    javacOptions in (Compile, compile) ++= Seq("-source", "1.8", "-target", "1.8", "-g:lines")
    
    crossPaths := false // drop off Scala suffix from artifact names.
    autoScalaLibrary := false // exclude scala-library from dependencies
    

    Summing up. I love SBT, but I felt necessary to write the full build with all the tricky parts of using it for java. Note that this setup might be better than a maven one because you'll have nice features such as incremental testing or even incremental runs. Also consider adding sbt-assembly plugin if you have dependencies and want to create fat jars (executables).

提交回复
热议问题