@@ -407,35 +407,29 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
407
407
}
408
408
}
409
409
410
- private def buildFileSet (
411
- build : Build .Successful ,
412
- docBuildOpt : Option [Build .Successful ],
413
- workingDir : os.Path ,
414
- now : Instant ,
415
- isIvy2LocalLike : Boolean ,
416
- isCi : Boolean ,
417
- logger : Logger
418
- ): Either [BuildException , (FileSet , (coursier.core.Module , String ))] = either {
419
-
420
- logger.debug(s " Preparing project ${build.project.projectName}" )
421
-
422
- val publishOptions = build.options.notForBloopOptions.publishOptions
410
+ private def orgNameVersion (
411
+ publishOptions : scala.build.options.PublishOptions ,
412
+ workspace : os.Path ,
413
+ logger : Logger ,
414
+ scalaArtifactsOpt : Option [ScalaArtifacts ],
415
+ isCi : Boolean
416
+ ): Either [BuildException , (String , String , String )] = {
423
417
424
- lazy val orgNameOpt = GitRepo .maybeGhRepoOrgName(build.inputs. workspace, logger)
418
+ lazy val orgNameOpt = GitRepo .maybeGhRepoOrgName(workspace, logger)
425
419
426
- val org = publishOptions.organization match {
427
- case Some (org0) => org0.value
428
- case None => value( defaultOrganization(orgNameOpt.map(_._1), logger) )
420
+ val maybeOrg = publishOptions.organization match {
421
+ case Some (org0) => Right ( org0.value)
422
+ case None => defaultOrganization(orgNameOpt.map(_._1), logger)
429
423
}
430
424
431
425
val moduleName = publishOptions.moduleName match {
432
426
case Some (name0) => name0.value
433
427
case None =>
434
428
val name = publishOptions.name match {
435
429
case Some (name0) => name0.value
436
- case None => defaultName(build.inputs. workspace, logger)
430
+ case None => defaultName(workspace, logger)
437
431
}
438
- build.artifacts.scalaOpt .map(_.params) match {
432
+ scalaArtifactsOpt .map(_.params) match {
439
433
case Some (scalaParams) =>
440
434
val pf = publishOptions.scalaPlatformSuffix.getOrElse {
441
435
scalaParams.platform.fold(" " )(" _" + _)
@@ -450,26 +444,57 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
450
444
}
451
445
}
452
446
453
- val ver = publishOptions.version match {
454
- case Some (ver0) => ver0.value
447
+ val maybeVer = publishOptions.version match {
448
+ case Some (ver0) => Right ( ver0.value)
455
449
case None =>
456
450
val computeVer = publishOptions.contextual(isCi).computeVersion.orElse {
457
- def isGitRepo = GitRepo .gitRepoOpt(build.inputs. workspace).isDefined
451
+ def isGitRepo = GitRepo .gitRepoOpt(workspace).isDefined
458
452
val default = defaultComputeVersion(! isCi && isGitRepo)
459
453
if (default.isDefined)
460
454
logger.message(
461
455
s " Using directive ${defaultVersionError.directiveName} not set, assuming git:tag as publish.computeVersion "
462
456
)
463
457
default
464
458
}
465
- value {
466
- computeVer match {
467
- case Some (cv) => cv.get(build.inputs.workspace)
468
- case None => defaultVersion
469
- }
459
+ computeVer match {
460
+ case Some (cv) => cv.get(workspace)
461
+ case None => defaultVersion
470
462
}
471
463
}
472
464
465
+ (maybeOrg, maybeVer)
466
+ .traverseN
467
+ .left.map(CompositeBuildException (_))
468
+ .map {
469
+ case (org, ver) =>
470
+ (org, moduleName, ver)
471
+ }
472
+ }
473
+
474
+ private def buildFileSet (
475
+ build : Build .Successful ,
476
+ docBuildOpt : Option [Build .Successful ],
477
+ workingDir : os.Path ,
478
+ now : Instant ,
479
+ isIvy2LocalLike : Boolean ,
480
+ isCi : Boolean ,
481
+ logger : Logger
482
+ ): Either [BuildException , (FileSet , (coursier.core.Module , String ))] = either {
483
+
484
+ logger.debug(s " Preparing project ${build.project.projectName}" )
485
+
486
+ val publishOptions = build.options.notForBloopOptions.publishOptions
487
+
488
+ val (org, moduleName, ver) = value {
489
+ orgNameVersion(
490
+ publishOptions,
491
+ build.inputs.workspace,
492
+ logger,
493
+ build.artifacts.scalaOpt,
494
+ isCi
495
+ )
496
+ }
497
+
473
498
logger.message(s " Publishing $org: $moduleName: $ver" )
474
499
475
500
val mainJar = {
0 commit comments