package gs; import sbt._ object Gs { /** * Standard compiler options used by GS projects. */ val CompilerOptions: Seq[String] = Seq( "-encoding", "utf8", // Set source file character encoding. "-deprecation", // Emit warning and location for usages of deprecated APIs. "-feature", // Emit warning and location for usages of features that should be imported explicitly. "-explain", // Explain errors in more detail. "-unchecked", // Enable additional warnings where generated code depends on assumptions. "-explain-types", // Explain type errors in more detail. "-Xfatal-warnings", // Fail the compilation if there are any warnings. "-language:strictEquality", // Enable multiversal equality (require CanEqual) "-Wunused:implicits", // Warn if an implicit parameter is unused. "-Wunused:explicits", // Warn if an explicit parameter is unused. "-Wunused:imports", // Warn if an import selector is not referenced. "-Wunused:locals", // Warn if a local definition is unused. "-Wunused:privates", // Warn if a private member is unused. "-Wsafe-init" // Enable the safe initialization check. ) /** * Host of the GS Git server. */ val GitHost: String = "git.garrity.co" /** * Host of the Maven server. */ val MavenHost: String = "maven.garrity.co" /** * Realm of the Maven server. */ val MavenRealm: String = "Reposilite" /** * Organization name used to organize projects in Git. */ val GitOrganization: String = "garrity-software" /** * Human readable organization name. */ val OrganizationName: String = "Garrity Software" /** * Maven Group ID for GS projects. */ val GroupId: String = "gs" /** * Calculate the Git repository for a project. * * @param projectName The project name. * @return The HTTPS Git repository URL. */ def gitRepo(projectName: String): String = s"https://$GitHost/$GitOrganization/$projectName" /** * Calculate the Git SSH target for a project. * * @param projectName The project name. * @return The SSH target. */ def gitSsh(projectName: String): String = s"git@$GitHost:$GitOrganization/${projectName}.git" object Environment { val MavenUser: String = "GS_MAVEN_USER" val MavenToken: String = "GS_MAVEN_TOKEN" } /** * Prefers to load credentials from file, if a file is available. Otherwise * mandates that the following environment variables exist: * * - `GS_MAVEN_USER` * - `GS_MAVEN_TOKEN` * * @return The selected credentials for GS Maven. */ def selectCredentials(): Credentials = if ((Path.userHome / ".sbt" / ".credentials").exists()) Credentials(Path.userHome / ".sbt" / ".credentials") else Credentials.apply( realm =Gs.MavenRealm, host = Gs.MavenHost, userName = sys.env .get(Gs.Environment.MavenUser) .getOrElse( throw new RuntimeException( s"You must either provide ~/.sbt/.credentials or specify the ${Gs.Environment.MavenUser} environment variable." ) ), passwd = sys.env .get(Gs.Environment.MavenToken) .getOrElse( throw new RuntimeException( s"You must either provide ~/.sbt/.credentials or specify the ${Gs.Environment.MavenToken} environment variable." ) ) ) }