Skip to content

totally disable publishing of non-core subprojects #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

SethTisue
Copy link
Member

a with-extreme-prejudice followup to b21b276

using code borrowed from scala/scala repo

@SethTisue
Copy link
Member Author

this should avoid all the

java.lang.RuntimeException: Repository for publishing is not specified.
	at scala.sys.package$.error(package.scala:27)
	at sbt.Classpaths$$anonfun$getPublishTo$1.apply(Defaults.scala:1583)
	at sbt.Classpaths$$anonfun$getPublishTo$1.apply(Defaults.scala:1583)

stuff at e.g. https://travis-ci.org/scala/scala-parallel-collections/builds/213142948

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Here's what I've built up over time, in a similar vein:

    val noDocs    = Def.settings(sources in (Compile, doc) := Nil, publishArtifact in (Compile, packageDoc) := false)
    val noSources = Def.settings(publishArtifact in (Compile, packageSrc) := false)
    val noPackage = Def.settings(Keys.`package` := file(""), packageBin := file(""), packagedArtifacts := Map())
    val noPublish = Def.settings(
      makePom         := file(""),
      deliver         := file(""),
      deliverLocal    := file(""),
      publish         := {},
      publishLocal    := {},
      publishM2       := {},
      publishArtifact := false,
      publishTo       := Some(Resolver.file("devnull", file("/dev/null")))
    )
    val noArtifacts = Def.settings(noPackage, noPublish)

build.sbt Outdated

lazy val root = (project in file("."))
.settings(disablePublishing)
.aggregate(core, junit, scalacheck, testmacros)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor/pro-tip: You can avoid having to enumerate these, as well as maintain the enumeration, by just specifying the settings at the root level:

disablePublishing

build.sbt Outdated
@@ -29,21 +40,20 @@ lazy val core = project.in(file("core")).settings(scalaModuleSettings).settings(
)
)

lazy val junit = project.in(file("junit")).settings(
lazy val junit = project.in(file("junit")).settings(disablePublishing).settings(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor/pro-tip: No need to jump in and out of .settings.

TL;DR: you could define this as

project.in(file("junit")).settings(
  disablePublishing,
  libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",

Long-winded explanation:

Individual settings (type Setting[_]) and seq of settings (type Seq[Setting[_]]) are both SettingDefinitions (the former by definition, the latter via implicit lift), and .settings is defined to take a varargs of SettingDefinition, so they can be defined next to each other.

For convenience there is also a Def.settings(ss: SettingsDefinition*): Seq[Setting[_]]

@SethTisue SethTisue force-pushed the disable-unwanted-publishing-with-extreme-prejudice branch from b52839e to 821af90 Compare March 20, 2017 22:01
a with-extreme-prejudice followup to b21b276
@SethTisue SethTisue force-pushed the disable-unwanted-publishing-with-extreme-prejudice branch from 821af90 to e38e892 Compare March 20, 2017 22:02
@SethTisue
Copy link
Member Author

rebased, and applied Dale's suggested minor changes (thanks Dale)

@SethTisue SethTisue merged commit 9239dcd into scala:master Mar 20, 2017
@SethTisue SethTisue deleted the disable-unwanted-publishing-with-extreme-prejudice branch March 20, 2017 22:29
@szeiger
Copy link
Contributor

szeiger commented Mar 21, 2017

It would be great if sbt had support for this out of the box. Disabling publishing of a subproject is rather common and not at all well supported at the moment.

@dwijnand
Copy link
Member

I agree. Between sbt, sbt-bintray, sbt-sonatype there's a lot of work to do just in this niche.

@SethTisue
Copy link
Member Author

SethTisue commented Mar 22, 2017

not to mention sbt-pgp, which is actually where these particular exceptions were coming from (and are hopefully finally fixed by #20)

@SethTisue
Copy link
Member Author

I closed and released the staging repo in the Sonatype web UI. I'll come back here once the artifacts are on Maven Central and I've done a bit of testing.

@SethTisue
Copy link
Member Author

> update
[info] Updating {file:/Users/tisue/tmp/2.13-latest-nightly/}root-2-13-latest-nightly...
[info] Resolving jline#jline;2.14.3 ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/modules/scala-parallel-collections_2.13.0-pre-e2a2cba/0.1.1/scala-parallel-collections_2.13.0-pre-e2a2cba-0.1.1.jar ...
[info] 	[SUCCESSFUL ] org.scala-lang.modules#scala-parallel-collections_2.13.0-pre-e2a2cba;0.1.1!scala-parallel-collections_2.13.0-pre-e2a2cba.jar(bundle) (372ms)
[info] Done updating.
[success] Total time: 2 s, completed Mar 21, 2017 5:41:28 PM
> console
[info] Starting scala interpreter...
[info] 
Welcome to Scala 2.13.0-pre-e2a2cba (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
Type in expressions for evaluation. Or try :help.

scala> def foo = List(1).par.map(_ + 1).seq
<console>:11: error: value par is not a member of List[Int]
       def foo = List(1).par.map(_ + 1).seq
                         ^

scala> import scala.collection.parallel.CollectionConverters._
import scala.collection.parallel.CollectionConverters._

scala> def foo = List(1).par.map(_ + 1).seq
foo: scala.collection.immutable.Seq[Int]

scala> foo
res0: scala.collection.immutable.Seq[Int] = Vector(2)

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants