Skip to content
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

Drop 0.13 support. Bump sbt version to 1.5.5. Fix deprecation warnings. #91

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ jobs:
strategy:
matrix:
include:
- scala-version: '2.13.6'
sbt-version: '0.13.18'
Comment on lines -15 to -16
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The PR which updated Scala version to 2.13.6 had bad check - although on the LHS we could see that it's testing for scala version 2.13.6, it did tests for 2.10 and that's why they passed. Now I've got errors on CI saying that no project cross builds to 2.13.6. (And I think it's true since sbt is still using 2.12)

- scala-version: '2.12.8'
sbt-version: '1.2.8'
- scala-version: '2.12.15'
sbt-version: '1.5.5'
steps:
- name: Checkout current branch
uses: actions/checkout@v2
Expand Down
15 changes: 7 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
lazy val commonSettings = Seq(
organization in ThisBuild := "com.eed3si9n"
ThisBuild / organization := "com.eed3si9n",
scalaVersion := "2.12.15"
)

lazy val root = (project in file(".")).
enablePlugins(SbtPlugin).
settings(commonSettings: _*).
settings(
sbtPlugin := true,
crossSbtVersions := Vector("0.13.18", "1.2.8"),
name := "sbt-unidoc",
description := "sbt plugin to create a unified API document across projects",
licenses := Seq("Apache License v2" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")),
scalacOptions := Seq("-deprecation", "-unchecked"),
publishArtifact in (Compile, packageBin) := true,
publishArtifact in (Test, packageBin) := false,
publishArtifact in (Compile, packageDoc) := false,
publishArtifact in (Compile, packageSrc) := true,
Compile / packageBin / publishArtifact := true,
Test / packageBin / publishArtifact := false,
Compile / packageDoc / publishArtifact := false,
Compile / packageSrc / publishArtifact := true,
SethTisue marked this conversation as resolved.
Show resolved Hide resolved
publishMavenStyle := false,
bintrayOrganization := Some("sbt"),
bintrayRepository := "sbt-plugin-releases",
scriptedSettings,
scriptedLaunchOpts ++= Seq("-Xmx1024M", "-XX:MaxPermSize=256M", "-Dplugin.version=" + version.value),
scriptedBufferLog := false
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.18
sbt.version=1.5.5
2 changes: 0 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.6")

libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value
38 changes: 0 additions & 38 deletions src/main/scala-sbt-0.13/sbtunidoc/Unidoc.scala

This file was deleted.

47 changes: 21 additions & 26 deletions src/main/scala/sbtunidoc/BaseUnidocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,40 @@ object BaseUnidocPlugin extends AutoPlugin {
import autoImport._

override def projectSettings = Seq(
unidoc in Compile := Seq.empty,
unidoc in Test := Seq.empty
Compile / unidoc := Seq.empty,
Test / unidoc := Seq.empty
)

override def requires = JvmPlugin

def baseUnidocSettings(sc: Configuration): Seq[sbt.Def.Setting[_]] = Seq(
doc := Unidoc(streams.value.cacheDirectory, (compilers in unidoc).value, (sources in unidoc).value, (fullClasspath in unidoc).value,
(scalacOptions in unidoc).value, (javacOptions in unidoc).value, (apiMappings in unidoc).value, (maxErrors in unidoc).value,
(target in unidoc).value, configuration.value, streams.value, (sourcePositionMappers in unidoc).value),
compilers in unidoc := (compilers in sc).value,
sources in unidoc := (unidocAllSources in unidoc).value.flatten.sortBy { _.getAbsolutePath },
scalacOptions in unidoc := (scalacOptions in (sc, doc)).value,
javacOptions in unidoc := (javacOptions in (sc, doc)).value,
fullClasspath in unidoc := (unidocAllClasspaths in unidoc).value.flatten.distinct.sortBy { _.data.getName },
unidocAllClasspaths in unidoc := allClasspathsTask.value,
apiMappings in unidoc := {
val all = (unidocAllAPIMappings in unidoc).value
doc := Unidoc(streams.value.cacheDirectory, (unidoc / compilers).value, (unidoc / sources).value, (unidoc / fullClasspath).value,
(unidoc / scalacOptions).value, (unidoc / javacOptions).value, (unidoc / apiMappings).value, (unidoc / maxErrors).value,
(unidoc / target).value, configuration.value, streams.value, (unidoc / sourcePositionMappers).value, fileConverter.value),
unidoc / compilers := (sc / compilers).value,
unidoc / sources := (unidoc / unidocAllSources).value.flatten.sortBy { _.getAbsolutePath },
unidoc / scalacOptions := (sc / doc / scalacOptions).value,
unidoc / javacOptions := (sc / doc / javacOptions).value,
unidoc / fullClasspath := (unidoc / unidocAllClasspaths).value.flatten.distinct.sortBy { _.data.getName },
unidoc / unidocAllClasspaths := allClasspathsTask.value,
unidoc / apiMappings := {
val all = (unidoc / unidocAllAPIMappings).value
val allList = all map { _.toList }
allList.flatten.distinct.toMap
},
unidocAllAPIMappings in unidoc := allAPIMappingsTask.value,
maxErrors in unidoc := (maxErrors in (sc, doc)).value,
unidocScopeFilter in unidoc := ScopeFilter((unidocProjectFilter in unidoc).value, (unidocConfigurationFilter in unidoc).value),
unidocProjectFilter in unidoc := inAnyProject,
// {
// val exclude = excludedProjects.value
// inAnyProject -- inProjects(buildStructure.value.allProjectRefs filter { p => exclude contains (p.project) }: _*)
// },
// excludedProjects in unidoc := Seq(),
unidocConfigurationFilter in unidoc := inConfigurations(sc)
unidoc / unidocAllAPIMappings := allAPIMappingsTask.value,
unidoc / maxErrors := (sc / doc / maxErrors).value,
unidoc / unidocScopeFilter := ScopeFilter((unidoc / unidocProjectFilter).value, (unidoc / unidocConfigurationFilter).value),
unidoc / unidocProjectFilter := inAnyProject,
unidoc / unidocConfigurationFilter := inConfigurations(sc)
)

lazy val allClasspathsTask = Def.taskDyn {
val f = (unidocScopeFilter in unidoc).value
val f = (unidoc / unidocScopeFilter).value
dependencyClasspath.all(f)
}
lazy val allAPIMappingsTask = Def.taskDyn {
val f = (unidocScopeFilter in unidoc).value
(apiMappings in (Compile, doc)).all(f)
val f = (unidoc / unidocScopeFilter).value
(Compile / doc / apiMappings).all(f)
}
}
10 changes: 5 additions & 5 deletions src/main/scala/sbtunidoc/JavaUnidocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ object JavaUnidocPlugin extends AutoPlugin {
javaUnidocTask(JavaUnidoc, Compile) ++
javaUnidocTask(TestJavaUnidoc, Test) ++
inConfig(TestJavaUnidoc)(Seq(
target in unidoc := target.value / "testjavaunidoc"
unidoc/ target := target.value / "testjavaunidoc"
))

def javaUnidocTask(c: Configuration, sc: Configuration): Seq[sbt.Def.Setting[_]] =
inConfig(c)(Defaults.configSettings ++ baseJavaUnidocTasks(sc)) ++ Seq(
unidoc in sc ++= Seq((doc in c).value)
sc / unidoc ++= Seq((c / doc).value)
)

def baseJavaUnidocTasks(sc: Configuration): Seq[sbt.Def.Setting[_]] = BaseUnidocPlugin.baseUnidocSettings(sc) ++ Seq(
target in unidoc := target.value / "javaunidoc",
unidocAllSources in unidoc := allJavaSourcesTask.value
unidoc / target := target.value / "javaunidoc",
unidoc / unidocAllSources := allJavaSourcesTask.value
)

lazy val javaSources: sbt.Def.Initialize[Task[Seq[File]]] = Def.task {
Expand All @@ -43,7 +43,7 @@ object JavaUnidocPlugin extends AutoPlugin {
}

lazy val allJavaSourcesTask = Def.taskDyn {
val f = (unidocScopeFilter in unidoc).value
val f = (unidoc / unidocScopeFilter).value
javaSources.all(f)
}
}
10 changes: 5 additions & 5 deletions src/main/scala/sbtunidoc/PublishJavadocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ object PublishJavadocPlugin extends AutoPlugin {

def genjavadocExtraTask(c: Configuration, sc: Configuration): Seq[sbt.Def.Setting[_]] =
inConfig(c)(Defaults.configSettings ++ baseGenjavadocExtraTasks(sc)) ++ Seq(
packageDoc in sc := (packageDoc in c).value
sc / packageDoc := (c / packageDoc).value
)

def baseGenjavadocExtraTasks(sc: Configuration): Seq[sbt.Def.Setting[_]] = Seq(
artifactName in packageDoc := { (sv, mod, art) => "" + mod.name + "_" + sv.binary + "-" + mod.revision + "-javadoc.jar" },
packageDoc / artifactName := { (sv, mod, art) => "" + mod.name + "_" + sv.binary + "-" + mod.revision + "-javadoc.jar" },
sources := {
(compile in sc).value
(target.value / "java" ** "*.java").get ++ (sources in sc).value.filter(_.getName.endsWith(".java"))
(sc / compile).value
(target.value / "java" ** "*.java").get ++ (sc / sources).value.filter(_.getName.endsWith(".java"))
},
javacOptions in doc := (javacOptions in (sc, doc)).value
doc / javacOptions := (sc / doc / javacOptions).value
)
}
10 changes: 5 additions & 5 deletions src/main/scala/sbtunidoc/ScalaUnidocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ object ScalaUnidocPlugin extends AutoPlugin {
scalaUnidocTask(ScalaUnidoc, Compile) ++
scalaUnidocTask(TestScalaUnidoc, Test) ++
inConfig(TestScalaUnidoc)(Seq(
target in unidoc := crossTarget.value / "testunidoc"
unidoc / target := crossTarget.value / "testunidoc"
))

def scalaUnidocTask(c: Configuration, sc: Configuration): Seq[sbt.Def.Setting[_]] =
inConfig(c)(Defaults.configSettings ++ baseScalaUnidocTasks(sc)) ++ Seq(
unidoc in sc ++= Seq((doc in c).value)
sc / unidoc ++= Seq((c / doc).value)
)

def baseScalaUnidocTasks(sc: Configuration): Seq[sbt.Def.Setting[_]] = BaseUnidocPlugin.baseUnidocSettings(sc) ++ Seq(
target in unidoc := crossTarget.value / "unidoc",
unidocAllSources in unidoc := allScalaSources.value
unidoc / target := crossTarget.value / "unidoc",
unidoc / unidocAllSources := allScalaSources.value
)

lazy val allScalaSources = Def.taskDyn {
val f = (unidocScopeFilter in unidoc).value
val f = (unidoc / unidocScopeFilter).value
sources.all(f)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package sbtunidoc

import sbt._
import sbt.Keys._
import sbt.internal.inc.{ AnalyzingCompiler, ManagedLoggedReporter }
import sbt.internal.inc.{AnalyzingCompiler, ManagedLoggedReporter}
import sbt.internal.util.Attributed.data
import xsbti.compile.{ Compilers, IncToolOptionsUtil }
import xsbti.Reporter
import xsbti.compile.{Compilers, IncToolOptionsUtil}
import xsbti.{FileConverter, Reporter}

object Unidoc {
import java.io.PrintWriter

// This is straight out of docTaskSettings in Defaults.scala.
def apply(cache: File, cs: Compilers, srcs: Seq[File], cp: Classpath,
sOpts: Seq[String], jOpts: Seq[String], xapis: Map[File, URL], maxErrors: Int,
out: File, config: Configuration, s: TaskStreams, spm: Seq[xsbti.Position => Option[xsbti.Position]]): File = {
out: File, config: Configuration, s: TaskStreams, spm: Seq[xsbti.Position => Option[xsbti.Position]], converter: FileConverter): File = {
val hasScala = srcs.exists(_.name.endsWith(".scala"))
val hasJava = srcs.exists(_.name.endsWith(".java"))
val label = nameForSrc(config.name)
Expand All @@ -31,9 +31,11 @@ object Unidoc {
case (_, true) =>
val javadoc =
sbt.inc.Doc.cachedJavadoc(label, s.cacheStoreFactory sub "java", cs.javaTools)
javadoc.run(srcs.toList,
data(cp).toList,
out,
javadoc.run(
srcs.toList.map(f => converter.toVirtualFile(f.toPath)),
data(cp).toList.map(f => converter.toVirtualFile(f.toPath)),
converter,
out.toPath,
jOpts.toList,
IncToolOptionsUtil.defaultIncToolOptions(),
s.log,
Expand Down