-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from jonas/release
Configure publishing of the sbt plugin and tools library
- Loading branch information
Showing
9 changed files
with
218 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,10 @@ val Versions = new { | |
|
||
inThisBuild( | ||
Def.settings( | ||
organization := "org.scalanative.bindgen", | ||
version := "0.2-SNAPSHOT", | ||
organization := "org.scala-native.bindgen", | ||
licenses := Seq( | ||
"BSD 3-Clause" -> url("https://www.scala-lang.org/license/")), | ||
homepage := Some(url("https://kornilova-l.github.io/scala-native-bindgen")), | ||
scalacOptions ++= Seq( | ||
"-deprecation", | ||
"-unchecked", | ||
|
@@ -24,7 +26,20 @@ inThisBuild( | |
scmInfo := Some( | ||
ScmInfo(url("https://github.com/kornilova-l/scala-native-bindgen"), | ||
"scm:git:[email protected]:kornilova-l/scala-native-bindgen.git")), | ||
git.remoteRepo := scmInfo.value.get.connection.replace("scm:git:", "") | ||
developers := List( | ||
Developer( | ||
id = "kornilova-l", | ||
name = "Liudmila Kornilova", | ||
email = "[email protected]", | ||
url = url("https://github.com/kornilova-l") | ||
), | ||
Developer( | ||
id = "jonas", | ||
name = "Jonas Fonseca", | ||
email = "[email protected]", | ||
url = url("https://github.com/jonas") | ||
) | ||
) | ||
)) | ||
|
||
val root = project("scala-native-bindgen") | ||
|
@@ -36,12 +51,33 @@ val root = project("scala-native-bindgen") | |
sbtPlugin, | ||
docs | ||
) | ||
.enablePlugins(ReleasePlugin) | ||
.settings( | ||
publish / skip := true, | ||
releaseCrossBuild := false, | ||
releaseVersionFile := target.value / "unused-version.sbt", | ||
releaseProcess := { | ||
import ReleaseTransformations._ | ||
Seq[ReleaseStep]( | ||
checkSnapshotDependencies, | ||
setReleaseVersions(version.value), | ||
runClean, | ||
releaseStepCommandAndRemaining("verify"), | ||
setReleaseVersion, | ||
tagRelease, | ||
releaseStepCommandAndRemaining("^publish"), | ||
pushChanges, | ||
releaseStepTask(docs / ghpagesPushSite) | ||
) | ||
} | ||
) | ||
|
||
lazy val tests = project("tests") | ||
.dependsOn(tools) | ||
.settings( | ||
fork in Test := true, | ||
javaOptions in Test += { | ||
publish / skip := true, | ||
Test / fork := true, | ||
Test / javaOptions += { | ||
val rootDir = (ThisBuild / baseDirectory).value | ||
s"-Dbindgen.path=$rootDir/bindgen/target/scala-native-bindgen" | ||
}, | ||
|
@@ -57,6 +93,7 @@ lazy val samples = project("samples") | |
.in(file("tests/samples")) | ||
.enablePlugins(ScalaNativePlugin) | ||
.settings( | ||
publish / skip := true, | ||
scalaVersion := Versions.scala211, | ||
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.6.3" % "test", | ||
testFrameworks += new TestFramework("utest.runner.Framework"), | ||
|
@@ -108,20 +145,30 @@ lazy val tools = project("tools") | |
|
||
lazy val sbtPlugin = project("sbt-scala-native-bindgen", ScriptedPlugin) | ||
.dependsOn(tools) | ||
.enablePlugins(BuildInfoPlugin) | ||
.settings( | ||
Keys.sbtPlugin := true, | ||
scriptedLaunchOpts += s"-Dplugin.version=${version.value}", | ||
scriptedLaunchOpts += { | ||
val rootDir = (ThisBuild / baseDirectory).value | ||
s"-Dbindgen.path=$rootDir/bindgen/target/scala-native-bindgen" | ||
}, | ||
buildInfoPackage := "org.scalanative.bindgen.sbt", | ||
buildInfoKeys := Seq[BuildInfoKey]( | ||
version, | ||
organization, | ||
BuildInfoKey.map(scmInfo) { | ||
case (k, v) => "projectUrl" -> v.get.browseUrl | ||
} | ||
), | ||
publishLocal := publishLocal.dependsOn(tools / publishLocal).value | ||
) | ||
|
||
lazy val docs = project("docs") | ||
.enablePlugins(GhpagesPlugin, ParadoxSitePlugin, ParadoxMaterialThemePlugin) | ||
.settings( | ||
paradoxProperties in Paradox ++= Map( | ||
publish / skip := true, | ||
Paradox / paradoxProperties ++= Map( | ||
"github.base_url" -> scmInfo.value.get.browseUrl.toString | ||
), | ||
ParadoxMaterialThemePlugin.paradoxMaterialThemeSettings(Paradox), | ||
|
@@ -134,15 +181,31 @@ lazy val docs = project("docs") | |
|
||
def project(name: String, plugged: AutoPlugin*) = { | ||
val unplugged = Seq(ScriptedPlugin).filterNot(plugged.toSet) | ||
|
||
Project(id = name, base = file(name)) | ||
.disablePlugins(unplugged: _*) | ||
.enablePlugins(GitPlugin) | ||
.enablePlugins(GitVersioning) | ||
.settings( | ||
versionWithGit, | ||
git.useGitDescribe := true, | ||
git.remoteRepo := scmInfo.value.get.connection.replace("scm:git:", ""), | ||
crossSbtVersions := List(Versions.sbt013, Versions.sbt1), | ||
scalaVersion := { | ||
(pluginCrossBuild / sbtBinaryVersion).value match { | ||
case "0.13" => Versions.scala210 | ||
case _ => Versions.scala212 | ||
} | ||
} | ||
}, | ||
bintrayOrganization := Some("scala-native-bindgen"), | ||
bintrayRepository := { | ||
if (Keys.sbtPlugin.value) "sbt-plugins" | ||
else "maven" | ||
}, | ||
publishMavenStyle := Keys.sbtPlugin.value == false, | ||
Test / publishArtifact := false | ||
) | ||
} | ||
|
||
lazy val setReleaseVersions: String => State => State = | ||
v => _.put(ReleaseKeys.versions, (v, v)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Using the sbt plugin | ||
|
||
To add the sbt plugin to your project add the following lines in `project/plugins.sbt`: | ||
|
||
@@@ vars | ||
```sbt | ||
addSbtPlugin("org.scala-native.bindgen" % "sbt-scala-native-bindgen" % "$project.version$") | ||
|
||
resolvers += Resolver.bintrayIvyRepo("scala-native-bindgen", "sbt-plugin") | ||
resolvers += Resolver.bintrayRepo("scala-native-bindgen", "maven") | ||
``` | ||
@@@ | ||
|
||
Next configure the plugin using the settings scoped to either `Compile` or `Test`: | ||
|
||
|---------------------------|-------------------| | ||
|`nativeBindgenHeader` | The C header file to read. | ||
|`nativeBindgenPackage` | Package of the enclosing object. No package by default. | ||
|`name in nativeBindgen` | Name of the enclosing object. | ||
|`nativeBindgenLink` | Name of library to be linked. | ||
|
||
@@@ note | ||
|
||
By default the `scala-native-bindgen` executable is downloaded automatically for supported platforms. Set `version in nativeBindgen` (unscoped) to configure the version of the `scala-native-bindgen` to use if you want a version different from the version of the sbt plugin. | ||
|
||
In case your platform is not supported, you must compile `scala-native-bindgen` yourself and configure the path to the executable using `nativeBindgenPath`, e.g.: | ||
|
||
```sbt | ||
nativeBindgenPath := file("/path/to/scala-native-bindgen") | ||
``` | ||
|
||
@@@ | ||
|
||
Example settings: | ||
|
||
```sbt | ||
enablePlugins(ScalaNativeBindgenPlugin) | ||
inConfig(Compile)( | ||
Def.settings( | ||
nativeBindgenHeader := (resourceDirectory in Compile).value / "header.h", | ||
nativeBindgenPackage := Some("org.example.mylib"), | ||
nativeBindgenLink := Some("mylib"), // Will pass `-lmylib` to the linker | ||
nativeBindgenExclude := Some("__"), | ||
name in nativeBindgen := "MyLib" | ||
)) | ||
``` | ||
|
||
Running `nativeBindgen` will generate a file named `target/scala-2.x/src_managed/main/sbt-scala-native-bindgen//ScalaNativeBindgen.scala` containing something along the following lines: | ||
|
||
```scala | ||
package org.example.mylib | ||
|
||
import scala.scalanative._ | ||
import scala.scalanative.native._ | ||
|
||
@native.link("mylib") | ||
@native.extern | ||
object MyLib { | ||
// ... left out for brevity ... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.8") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2") | ||
addSbtPlugin("io.github.jonas" % "sbt-paradox-material-theme" % "0.4.0") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2") | ||
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.8") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2") | ||
addSbtPlugin("io.github.jonas" % "sbt-paradox-material-theme" % "0.4.0") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") | ||
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.9") | ||
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4") | ||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") | ||
|
||
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
sbt-scala-native-bindgen/src/sbt-test/bindgen/generate/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
sbt-scala-native-bindgen/src/sbt-test/bindgen/generate/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
addSbtPlugin( | ||
"org.scalanative.bindgen" % "sbt-scala-native-bindgen" % sys.props( | ||
"org.scala-native.bindgen" % "sbt-scala-native-bindgen" % sys.props( | ||
"plugin.version")) |
Oops, something went wrong.