2011-10-23 02:57:13 +02:00
/* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah , Indrajit Raychaudhuri
*/
package sbt
/* * Options for well-known tasks. */
object Opts {
object compile {
val deprecation = "-deprecation"
def encoding ( enc : String ) = Seq ( "-encoding" , enc )
val explaintypes = "-explaintypes"
val nowarn = "-nowarn"
val optimise = "-optimise"
val unchecked = "-unchecked"
val verbose = "-verbose"
}
object doc {
def generator ( g : String ) = Seq ( "-doc-generator" , g )
def sourceUrl ( u : String ) = Seq ( "-doc-source-url" , u )
def title ( t : String ) = Seq ( "-doc-title" , t )
def version ( v : String ) = Seq ( "-doc-version" , v )
}
2012-03-12 00:15:06 +01:00
object resolver {
import Path._
val sonatypeReleases = Resolver . sonatypeRepo ( "releases" )
val sonatypeSnapshots = Resolver . sonatypeRepo ( "snapshots" )
val sonatypeStaging = new MavenRepository ( "sonatype-staging" , "https://oss.sonatype.org/service/local/staging/deploy/maven2" )
val mavenLocalFile = Resolver . file ( "Local Repository" , userHome / ".m2" / "repository" asFile )
}
2011-10-23 02:57:13 +02:00
}
object DefaultOptions {
import Opts._
import Path._
2012-03-01 12:53:08 +01:00
import BuildPaths. { getGlobalBase , getGlobalSettingsDirectory }
2012-03-01 20:29:06 +01:00
import Project. { Setting , extract }
2012-02-29 19:58:12 +01:00
2011-10-23 02:57:13 +02:00
def javac : Seq [ String ] = compile . encoding ( "UTF-8" )
def scalac : Seq [ String ] = compile . encoding ( "UTF-8" )
2012-02-05 17:05:51 +01:00
def javadoc ( name : String , version : String ) : Seq [ String ] = Seq ( "-doctitle" , "%s %s API" . format ( name , version ) )
2011-10-23 02:57:13 +02:00
def scaladoc ( name : String , version : String ) : Seq [ String ] = doc . title ( name ) ++ doc . version ( version )
2012-02-29 19:58:12 +01:00
2012-03-12 00:15:06 +01:00
def resolvers ( snapshot : Boolean ) : Seq [ Resolver ] = {
if ( snapshot ) Seq ( Classpaths . typesafeSnapshots , resolver . sonatypeSnapshots ) else Nil
}
def pluginResolvers ( plugin : Boolean , snapshot : Boolean ) : Seq [ Resolver ] = {
if ( plugin && snapshot ) Seq ( Classpaths . typesafeSnapshots , Classpaths . sbtPluginSnapshots ) else Nil
}
def addResolvers : Setting [ _ ] = Keys . resolvers <<= Keys . isSnapshot apply resolvers
def addPluginResolvers : Setting [ _ ] = Keys . resolvers <<= ( Keys . sbtPlugin , Keys . isSnapshot ) apply pluginResolvers
2012-03-01 12:53:08 +01:00
@deprecated ( "Use `credentials(State)` instead to make use of configuration path dynamically configured via `Keys.globalSettingsDirectory`; relying on ~/.ivy2 is not recommended anymore." , "0.12.0" )
2012-02-28 18:23:17 +01:00
def credentials : Credentials = Credentials ( userHome / ".ivy2" / ".credentials" )
2012-03-01 20:29:06 +01:00
def credentials ( state : State ) : Credentials = Credentials ( getGlobalSettingsDirectory ( state , getGlobalBase ( state ) ) / ".credentials" )
def addCredentials : Setting [ _ ] = Keys . credentials <+= Keys . state map credentials
def shellPrompt ( version : String ) : State => String = s => "%s:%s:%s> " . format ( s . configuration . provider . id . name , extract ( s ) . currentProject . id , version )
def setupShellPrompt : Setting [ _ ] = Keys . shellPrompt <<= Keys . version apply shellPrompt
2011-10-23 02:57:13 +02:00
}