Skip to content

Commit

Permalink
Support for mill API 0.9.3, introduce mill platform suffix in artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou committed Dec 1, 2020
1 parent 6eae422 commit 5a258c6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ on: [push, pull_request]

env:
PUBLISH_OS: ubuntu-latest
PUBLISH_JAVA_VERSION: 1.8
PUBLISH_JAVA_VERSION: 8
PUBLISH_BRANCH: refs/heads/main

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
java-version: [1.8, 11]
java-version: [8, 11]

runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'windows-latest' }}
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Publish to Maven Central
if: matrix.os == env.PUBLISH_OS && matrix.java-version == env.PUBLISH_JAVA_VERSION && github.ref == env.PUBLISH_BRANCH && github.event_name == 'push'
run: ./millw -i mill.scalalib.PublishModule/publishAll --sonatypeCreds "${{ secrets.SONATYPE_CREDS }}" --gpgArgs "--passphrase=${{ secrets.GPG_SECRET_KEY_PASS}},--batch,--yes,-a,-b,--pinentry-mode,loopback" --publishArtifacts __.publishArtifacts --readTimeout 600000 --release true --signed true
run: ./millw -i mill.scalalib.PublishModule/publishAll --sonatypeCreds "${{ secrets.SONATYPE_CREDS }}" --gpgArgs "--passphrase=${{ secrets.GPG_SECRET_KEY_PASS}},--batch,--yes,-a,-b,--pinentry-mode,loopback" --publishArtifacts __.publishArtifacts --readTimeout 600000 --awaitTimeout 600000 --release true --signed true

- run: ./millw -i -j 0 __.scoverage.xmlReport
if: matrix.os != 'windows-latest'
Expand Down
21 changes: 20 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
= mill-vcs-version - Derive a version from Version Control
:version: 0.0.1
:mill-platform: 0.9
:project-home: https://github.com/lefou/mill-vcs-version
:toc:
:toc-placement: preamble
Expand All @@ -24,7 +25,7 @@ import mill.scalalib._
import mill.define._
// Load the plugin from Maven Central via ivy/coursier
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version:{version}`
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version_mill{mill-platform}:{version}`
import de.tobiasroeser.mill.vcs.version.VcsVersion
object main extends JavaModule with PublishModule {
Expand Down Expand Up @@ -63,6 +64,19 @@ When used with its defaults, the outcome is identical to the version scheme used
You can download binary releases from
https://search.maven.org/artifact/de.tototec/de.tobiasroeser.mill.vcs.version_2.13[Maven Central].


Please make sure to use the correct _mill platform suffix_ matching your used mill version.

.Mill Platform suffix
[options="header"]
|===
| mill version | mill platform | suffix | example
| 0.9.3 - | 0.9 | `_mill0.9` | ```$ivy.`de.tototec::de.tobiasroeser.mill.vcs.version_mill0.9:{version}````
| 0.7.0 - 0.8.0 | 0.7 | `_mill0.7` | ```$ivy.`de.tototec::de.tobiasroeser.mill.vcs.version_mill0.7:{version}````
| 0.6.0 - 0.6.3 | 0.6 | `_mill0.6` | ```$ivy.`de.tototec::de.tobiasroeser.mill.vcs.version_mill0.6:{version}````
|===


== License

This project is published under the https://www.apache.org/licenses/LICENSE-2.0[Apache License, Version 2.0].
Expand Down Expand Up @@ -91,6 +105,11 @@ Contributing::

== Releases / Changelog

=== mill-vsc-version main HEAD

* Support for mill API 0.9.3
* Introduce a new artifact name suffix (`_mill0.9` for mil 0.9.3) to support multiple mill API versions.

=== mill-vsc-version 0.0.1 - 2020-06-22

* Initial Release, intended for internal/test usage
39 changes: 23 additions & 16 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// mill plugins
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version:0.0.1`
import $ivy.`de.tototec::de.tobiasroeser.mill.integrationtest:0.3.3`
import $ivy.`de.tototec::de.tobiasroeser.mill.integrationtest_mill0.7:0.4.0`
import $ivy.`com.lihaoyi::mill-contrib-scoverage:$MILL_VERSION`

import mill._
Expand All @@ -17,8 +17,10 @@ import scala.collection.immutable.ListMap
val baseDir = build.millSourcePath

trait Deps {
def millVersion = "0.7.0" // scala-steward:off
def scalaVersion = "2.13.2"
def millPlatform = "0.9"
def millVersion = "0.9.3" // scala-steward:off
def scalaVersion = "2.13.4"
def testWithMill = Seq("0.9.3")

val millMain = ivy"com.lihaoyi::mill-main:${millVersion}"
val millMainApi = ivy"com.lihaoyi::mill-main-api:${millVersion}"
Expand All @@ -28,24 +30,29 @@ trait Deps {
val slf4j = ivy"org.slf4j:slf4j-api:1.7.25"
}

object Deps_0_7 extends Deps
object Deps_0_9 extends Deps
object Deps_0_7 extends Deps {
override def millPlatform = "0.7"
override def millVersion = "0.7.0" // scala-steward:off
override def scalaVersion = "2.13.2"
override def testWithMill = Seq("0.8.0", "0.7.4", "0.7.3", "0.7.2", "0.7.1", "0.7.0")
}
object Deps_0_6 extends Deps {
override def millPlatform = "0.6"
override def millVersion = "0.6.0" // scala-steward:off
override def scalaVersion = "2.12.10"
override def testWithMill = Seq("0.6.3", "0.6.2", "0.6.1", "0.6.0")
}


val millApiVersions: Map[String, Deps] = ListMap("0.7" -> Deps_0_7, "0.6" -> Deps_0_6)

val millItestVersions = Seq(
"0.7.3", "0.7.2", "0.7.1", "0.7.0",
"0.6.3", "0.6.2", "0.6.1", "0.6.0"
)
val crossDeps = Seq(Deps_0_9, Deps_0_7, Deps_0_6)
val millApiVersions = crossDeps.map(x => x.millPlatform -> x)
val millItestVersions = crossDeps.flatMap(x => x.testWithMill.map(_ -> x))

trait BaseModule extends CrossScalaModule with PublishModule with ScoverageModule {
def millApiVersion: String
def deps: Deps = millApiVersions(millApiVersion)
def deps: Deps = millApiVersions.toMap.apply(millApiVersion)
def crossScalaVersion = deps.scalaVersion
override def artifactSuffix: T[String] = s"_mill${deps.millPlatform}_${artifactScalaVersion()}"

override def ivyDeps = T {
Agg(ivy"${scalaOrganization()}:scala-library:${scalaVersion()}")
Expand Down Expand Up @@ -73,12 +80,12 @@ trait BaseModule extends CrossScalaModule with PublishModule with ScoverageModul

}

object core extends Cross[CoreCross](millApiVersions.keysIterator.toSeq: _*)
object core extends Cross[CoreCross](millApiVersions.map(_._1): _*)
class CoreCross(override val millApiVersion: String) extends BaseModule {

override def artifactName = "de.tobiasroeser.mill.vcs.version"

override def skipIdea: Boolean = millApiVersion != millApiVersions.head._1
override def skipIdea: Boolean = deps != crossDeps.head

override def compileIvyDeps = Agg(
deps.millMain,
Expand All @@ -91,9 +98,9 @@ class CoreCross(override val millApiVersion: String) extends BaseModule {
}
}

object itest extends Cross[ItestCross](millItestVersions: _*)
object itest extends Cross[ItestCross](millItestVersions.map(_._1): _*)
class ItestCross(millItestVersion: String) extends MillIntegrationTestModule {
val millApiVersion = millItestVersion.split("[.]").take(2).mkString(".")
val millApiVersion = millItestVersions.toMap.apply(millItestVersion).millPlatform
override def millSourcePath: Path = super.millSourcePath / os.up
override def millTestVersion = millItestVersion
override def pluginsUnderTest = Seq(core(millApiVersion))
Expand Down

0 comments on commit 5a258c6

Please sign in to comment.