@@ -4,6 +4,7 @@ import sbt.Keys._
44import sbt ._
55import sbtdynver .DynVerPlugin .autoImport .dynverTagPrefix
66import xerial .sbt .Sonatype .autoImport .{sonatypeProfileName , sonatypeCredentialHost }
7+ import java .net .URI
78
89trait Publish {
910 lazy val ossPublishSettings = Seq (
@@ -18,7 +19,7 @@ trait Publish {
1819 id = " softwaremill" ,
1920 name = " SoftwareMill" ,
2021 email = " info@softwaremill.com" ,
21- url = new URL (" https://softwaremill.com" )
22+ url = URI .create (" https://softwaremill.com" ).toURL( )
2223 )
2324 ),
2425 updateDocs := UpdateVersionInDocs (sLog.value, organization.value, version.value),
@@ -34,26 +35,26 @@ trait Publish {
3435 private val releaseCommand = Command .command(" release" ) { state =>
3536 var s = state
3637 s.log.info(" Current version:" )
37- s = Command .process (" version" , s)
38+ s = processCommandOrThrow (" version" , s)
3839 val version = readNextVersion()
3940
4041 val tagPrefix = Project .extract(s).getOpt(ThisBuild / dynverTagPrefix).getOrElse(" v" )
4142 val tag = tagPrefix + version
4243
43- s = Command .process (s """ set ThisBuild/version := " $version" """ , s)
44+ s = processCommandOrThrow (s """ set ThisBuild/version := " $version" """ , s)
4445
4546 val (s2, files) = Project .extract(s).runTask(updateDocs, s)
4647 s = s2
4748 s = addFilesToGit(s, files)
4849
4950 s.log.info(s " \n Docs updated, git status: \n " )
50- s = Command .process (s " git status " , s)
51+ s = processCommandOrThrow (s " git status " , s)
5152 s.log.info(s " \n " )
5253
53- s = Command .process (s """ git commit -m "Release $version" """ , s)
54+ s = processCommandOrThrow (s """ git commit -m "Release $version" """ , s)
5455
5556 s.log.info(s " Tagging release as: $tag" )
56- s = Command .process (s " git tag $tag" , s)
57+ s = processCommandOrThrow (s " git tag $tag" , s)
5758
5859 s = pushChanges(s)
5960 s
@@ -68,16 +69,19 @@ trait Publish {
6869
6970 private def addFilesToGit (state : State , fs : Seq [File ]): State =
7071 fs.foldLeft(state) { case (s, f) =>
71- Command .process (s " git add ${f.getAbsolutePath}" , s)
72+ processCommandOrThrow (s " git add ${f.getAbsolutePath}" , s)
7273 }
7374
7475 private def pushChanges (state : State ): State =
7576 SimpleReader .readLine(" Push changes? [y/n] " ) match {
7677 case Some (" y" ) =>
77- val state2 = Command .process (s " git push " , state)
78- Command .process (s " git push --tags " , state2)
78+ val state2 = processCommandOrThrow (s " git push " , state)
79+ processCommandOrThrow (s " git push --tags " , state2)
7980 case _ => sys.error(" Aborting, not pushing changes" ); state
8081 }
82+
83+ private def processCommandOrThrow (command : String , state : State ): State =
84+ Command .process(command, state, msg => throw new RuntimeException (msg))
8185}
8286
8387object Publish extends Publish
0 commit comments