mirror of https://github.com/sbt/sbt.git
fix: skip publish on synthetic aggregate root
**Problem** There's been previous attempt like 1878 to skip publishing of the root, but it seems like the behavior has regressed at some point in time. **Solution** This skips publishing on synthetic aggregate root project.
This commit is contained in:
parent
336b752c4f
commit
6491e50449
|
|
@ -10,12 +10,13 @@ package sbt
|
|||
package internal
|
||||
|
||||
import java.io.File
|
||||
import Keys.{ organization, thisProject, autoGeneratedProject }
|
||||
import Keys.{ organization, thisProject, autoGeneratedProject, publish, publishLocal, skip }
|
||||
import Def.Setting
|
||||
// import sbt.ProjectExtra.apply
|
||||
import sbt.io.Hash
|
||||
import sbt.internal.util.{ Attributed, StringAttributeMap }
|
||||
import sbt.internal.inc.{ FileAnalysisStore, ReflectUtilities }
|
||||
import sbt.SlashSyntax0.*
|
||||
import xsbti.{ FileConverter, VirtualFileRef }
|
||||
import xsbti.compile.CompileAnalysis
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ private[sbt] object BuildDef:
|
|||
}
|
||||
|
||||
def defaultAggregated(id: String, aggregate: Seq[ProjectRef]): BuildDef = new BuildDef {
|
||||
override def projectDefinitions(base: File) =
|
||||
override def projectDefinitions(base: File): Seq[Project] =
|
||||
defaultAggregatedProject(id, base, aggregate) :: Nil
|
||||
}
|
||||
|
||||
|
|
@ -55,12 +56,18 @@ private[sbt] object BuildDef:
|
|||
def defaultAggregatedProject(id: String, base: File, agg: Seq[ProjectRef]): Project =
|
||||
defaultProject(id, base).aggregate(agg: _*)
|
||||
|
||||
private[sbt] def generatedRootWithoutIvyPlugin(
|
||||
private[sbt] def generatedRootSkipPublish(
|
||||
id: String,
|
||||
base: File,
|
||||
agg: Seq[ProjectRef]
|
||||
): Project =
|
||||
Project.mkGeneratedRoot(id, base, agg).settings(defaultProjectSettings)
|
||||
Project
|
||||
.mkGeneratedRoot(id, base, agg)
|
||||
.settings(
|
||||
defaultProjectSettings,
|
||||
publish / skip := true,
|
||||
publishLocal / skip := true,
|
||||
)
|
||||
|
||||
private[sbt] def defaultProjectSettings: Seq[Setting[_]] = Seq(
|
||||
// TODO - Can we move this somewhere else? ordering of settings is causing this to get borked.
|
||||
|
|
@ -72,7 +79,7 @@ private[sbt] object BuildDef:
|
|||
case _ => "default"
|
||||
}
|
||||
},
|
||||
autoGeneratedProject := true
|
||||
autoGeneratedProject := true,
|
||||
)
|
||||
|
||||
def analyzed(
|
||||
|
|
|
|||
|
|
@ -1061,7 +1061,7 @@ private[sbt] object Load {
|
|||
val refs = existingIds.map(id => ProjectRef(buildUri, id))
|
||||
if (discovered.isEmpty || java.lang.Boolean.getBoolean("sbt.root.ivyplugin"))
|
||||
BuildDef.defaultAggregatedProject(defaultID, buildBase, refs)
|
||||
else BuildDef.generatedRootWithoutIvyPlugin(defaultID, buildBase, refs)
|
||||
else BuildDef.generatedRootSkipPublish(defaultID, buildBase, refs)
|
||||
}
|
||||
(root, false, Nil, otherProjects)
|
||||
val (finalRoot, projectLevelExtra) =
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
ThisBuild / organization := "com.example"
|
||||
ThisBuild / ivyPaths := IvyPaths((ThisBuild / baseDirectory).value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
|
||||
|
||||
name := "root"
|
||||
|
||||
lazy val core = project
|
||||
.settings(
|
||||
name := "core",
|
||||
// organization := "com.example",
|
||||
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
|
||||
)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
> publishLocal
|
||||
|
||||
$ absent ivy/cache/local/com.example/root_3/0.1.0-SNAPSHOT/poms/root_3.pom
|
||||
Loading…
Reference in New Issue