diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 67c006f5..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: thesamet diff --git a/.github/actions/scala_restore_cache/action.yml b/.github/actions/scala_restore_cache/action.yml new file mode 100644 index 00000000..34beb3e6 --- /dev/null +++ b/.github/actions/scala_restore_cache/action.yml @@ -0,0 +1,50 @@ +name: restore-sbt-cache +description: 'cache sbt deps and compiled classes' +author: 'Dmitry Muzyka' +inputs: + clean_build: + description: 'build all' + required: false + default: "false" +runs: + using: 'composite' + steps: + - name: Make cache key files + shell: bash + run: | + echo "${LAST_COMPLETED_JOB_SHA1}" > last-completed-job.sha1 + echo "${GITHUB_SHA}" > current.sha1 + echo "${LATEST_CACHE_SHA1}" > latest-maybe-failed.sha1 + date +%Y-%m > current_month + + - name: Restore compilation cache + if: ${{ inputs.clean_build != 'true' }} + uses: actions/cache/restore@v3 + with: + path: | + build_cache + key: v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('current.sha1') }} + restore-keys: | + v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('current.sha1') }} + v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('latest-maybe-failed.sha1') }} + v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('last-completed-job.sha1') }} + v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}- + + - name: Apply compilation cache + if: ${{ inputs.clean_build != 'true' }} + shell: bash + run: | + RUNNER_TRACKING_ID="" && tar -xf build_cache/targets.tar 2>/dev/null & + + - name: cleanup sbt cache once per month + shell: bash + run: | + mkdir -p ~/.cache + test -f ~/.cache/.timecreated || touch ~/.cache/.timecreated + if test "$(find ~/.cache/.timecreated -mtime +30)"; then + echo "run cleanup" + find ~/.cache ~/.ivy2 -type f -mtime +30 -delete + find ~/.cache ~/.ivy2 -type d -empty -delete + mkdir -p ~/.cache + touch ~/.cache/.timecreated + fi diff --git a/.github/actions/scala_save_cache/action.yml b/.github/actions/scala_save_cache/action.yml new file mode 100644 index 00000000..388df484 --- /dev/null +++ b/.github/actions/scala_save_cache/action.yml @@ -0,0 +1,44 @@ +name: save-sbt-cache +description: 'cache sbt deps and compiled classes' +author: 'Dmitry Muzyka' +inputs: + clean_build: + description: 'build all' + required: false + default: "false" +runs: + using: 'composite' + steps: + - name: Build cache directory + shell: bash + run: | + targets=$(git clean -ndx | cut -c14- | grep /$ | grep -E -v '(build_cache|persist|test_results)') + tar -cf build_cache/targets.tar --exclude=*/target/test-reports/*.xml --exclude=*.log --exclude=*/target/scoverage-report --exclude=*/target/coverage-report --exclude=project/target/active.json $targets || : + + - name: Make cache key file + shell: bash + run: | + echo "${GITHUB_SHA}" > current.sha1 + date +%Y-%m > current_month + + - name: check if compilation cache exists + id: check-compilation-cache + uses: actions/cache/restore@v3 + with: + path: | + build_cache + key: v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('current.sha1') }} + lookup-only: 'true' + + - name: Save compilation cache + if: steps.check-compilation-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: | + build_cache + key: v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('current.sha1') }} + + - name: Clean up + shell: bash + run: rm -rf build_cache current.sha1 + # / save sbt cache diff --git a/.github/actions/set_vars/action.yml b/.github/actions/set_vars/action.yml new file mode 100644 index 00000000..610e2244 --- /dev/null +++ b/.github/actions/set_vars/action.yml @@ -0,0 +1,57 @@ +name: set-ci-vars +description: 'set ci vars.' +author: 'Dmitry Muzyka' +inputs: + clean_build: + description: 'build all' + required: false + default: "false" +runs: + using: 'composite' + steps: + - name: "set git config" + shell: bash + run: | + git config --global --add safe.directory "$(pwd)" + git fetch origin master + git describe --tags --abbrev=0 --first-parent + + # set vars + - name: set branch + shell: bash + run: | + branch="$(echo -n ${{ github.event.ref }} | sed 's#refs/heads/##g; s#/#-#g' | tr '[:upper:]' '[:lower:]')" + echo "branch=\"${branch}\"" >> $GITHUB_ENV + + - name: set new version + shell: bash + run: | + if [[ ${{env.branch}} == "master" ]]; then + version="$(date +'%Y.%m.%d')-${{github.run_number}}" + else + version="$(date +'%Y.%m.%d')-${branch}-${{github.run_number}}" + fi + version=$(echo $version | sed 's/"//g') + echo "version=$version" + echo "version=$version" >> $GITHUB_ENV + + - name: Set LAST_COMPLETED_JOB_SHA1 + shell: bash + run: | + if [[ '${{ inputs.clean_build }}' == 'true' ]]; then + echo "clean build, will bundle & test all" + echo "LAST_COMPLETED_JOB_SHA1=None" >> $GITHUB_ENV + else + .github/helpers/set-last-completed-job-sha1.sh + fi + + - name: print debug info + shell: bash + run: | + echo "previous successful build sha: ${LAST_COMPLETED_JOB_SHA1}" + echo "previous successful version: $(git tag --points-at ${LAST_COMPLETED_JOB_SHA1})" + echo "latest cache sha: ${LATEST_CACHE_SHA1}" + echo "branch: ${branch}" + echo "version: ${version}" + + # /set vars diff --git a/.github/helpers/set-last-completed-job-sha1.sh b/.github/helpers/set-last-completed-job-sha1.sh new file mode 100755 index 00000000..1a01c78d --- /dev/null +++ b/.github/helpers/set-last-completed-job-sha1.sh @@ -0,0 +1,70 @@ +#!/bin/bash +set -exo pipefail + +### find previous sucessfull tag +# shellcheck disable=SC2154 +if [[ ${branch} == "master" ]]; then + prev_build=$(git describe --tags --abbrev=0 --first-parent --exclude='????.??.??-*-*') +else + prev_build=$(git describe --tags --abbrev=0 --first-parent) +fi +# if we have multiple tags on same commit, pick latest +prev_build=$(git tag --points-at "${prev_build}" | sort | tail -n 1) +git_prev_build_sha=$(git rev-list -n1 "${prev_build}") + +function get_diff_count() { + changed=$(git diff "${1}" --shortstat -- | awk '{print $1}') + if [[ -z $changed ]]; then + changed=0 + fi + echo -n $changed +} +LAST_COMPLETED_JOB_SHA1=${git_prev_build_sha} + + +# this needed as we have tag only healthy builds. And probably don't want to compare with unhealthy build +master_tag=$(git describe --tags --abbrev=0 --first-parent --exclude='????.??.??-*-*' origin/master) +master_sha=$(git rev-list -n1 "${master_tag}") +changes_master=$(get_diff_count "${master_sha}") + +changes_git_tag=$(get_diff_count "${git_prev_build_sha}") + +changes_current_candidate=$(get_diff_count "${LAST_COMPLETED_JOB_SHA1}") + +if [[ ${changes_current_candidate} -gt ${changes_master} ]]; then + echo "as previuos will choose version from master ${master_tag}" + LAST_COMPLETED_JOB_SHA1=${master_sha} + changes_current_candidate=$(get_diff_count "${LAST_COMPLETED_JOB_SHA1}") +elif [[ ${changes_current_candidate} -gt ${changes_git_tag} ]]; then + echo "as previuos will choose version from git tag ${prev_build}" + LAST_COMPLETED_JOB_SHA1=${git_prev_build_sha} + changes_current_candidate=$(get_diff_count "${LAST_COMPLETED_JOB_SHA1}") +fi +echo "LAST_COMPLETED_JOB_SHA1=${LAST_COMPLETED_JOB_SHA1}" >> $GITHUB_ENV + + +LATEST_CACHE_SHA1=${LAST_COMPLETED_JOB_SHA1} + + +set +xo pipefail +retrive_tag_num=30 +last_builds=$(git tag -l --sort='-authordate' | head -n "${retrive_tag_num}" | uniq) +set -o pipefail +last_builds_array=($last_builds) +tmp_dir='/tmp/' +# changes_current_candidate +(get_diff_count "${LATEST_CACHE_SHA1}"; echo -n " ${LATEST_CACHE_SHA1}") > "$tmp_dir/current.diff" & +# git tags +for i in $(seq 0 "$((retrive_tag_num-1))"); do + (get_diff_count "${last_builds_array[$i]}"; echo " ${last_builds_array[$i]}") > "$tmp_dir/$i.diff" & +done +wait +cache_candidate=$(cat "$tmp_dir"/*.diff | sort -n | head -n 1) +tag_with_min_changes=$(echo "$cache_candidate" | awk '{print $2}') +min_changes=$(echo "$cache_candidate" | awk '{print $1}') + +echo "as previous will choose version from commit ${tag_with_min_changes} with ${min_changes} changes" +LATEST_CACHE_SHA1=$(git rev-list -n1 "${tag_with_min_changes}") +changes_current_candidate=$(get_diff_count "${LATEST_CACHE_SHA1}") + +echo "LATEST_CACHE_SHA1=${LATEST_CACHE_SHA1}" >> $GITHUB_ENV diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3195140f..0e4802e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,78 +1,77 @@ -name: CI - -on: [push, pull_request] +name: ci +on: + push: + branches: + - '**' + workflow_dispatch: + inputs: + clean_build: + description: 'build all' + required: false + default: false +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref_name != 'master' }} jobs: - build: - runs-on: ${{matrix.os}} - strategy: - matrix: - os: ["ubuntu-latest", "macos-latest", "windows-latest"] - - steps: - - uses: actions/checkout@v4 - - uses: olafurpg/setup-scala@v14 - with: - java-version: 8 - - name: Mount caches - uses: actions/cache@v2 - with: - path: | - ~/.sbt - ~/.ivy2/cache - ~/.cache/coursier - key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }} - - name: Remove native tests (Windows only) - if: ${{ runner.os == 'Windows' }} - run: | - rm -rf examples/scalapb-crossproject - shell: bash - - name: Compile and test - run: | - sbt test - cd examples - for d in */ ; do cd "$d" && sbt test && cd ../ ; done - shell: bash - - name: Format check - if: ${{ runner.os == 'Linux' }} - run: | - sbt scalafmtCheck test:scalafmtCheck scalafmtSbtCheck - scripted: - runs-on: ${{matrix.os}} - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest", "macos-latest", "windows-latest"] - scripted-sbt: ["1.2.8", "1.3.13", "project"] - - steps: - - uses: actions/checkout@v4 - - uses: olafurpg/setup-scala@v14 - with: - java-version: 11 - - name: Mount caches - uses: actions/cache@v2 - with: - path: | - ~/.sbt - ~/.ivy2/cache - ~/.cache/coursier - key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }} - - name: Compile and run scripted tests with older version - if: ${{ matrix.scripted-sbt != 'project' }} - env: - SCRIPTED_SBT: ${{ matrix.scripted-sbt }} - run: | - sbt "set scriptedSbt := \"$SCRIPTED_SBT\"" scripted - shell: bash - - name: Compile and run scripted tests with project version - if: ${{ matrix.scripted-sbt == 'project' }} - run: | - sbt "set scriptedSbt := sbtVersion.value" scripted - shell: bash - # Single final job for mergify. - ci-passed: + test: runs-on: ubuntu-latest - needs: [build, scripted] + timeout-minutes: 25 + env: + # define Java options for both official sbt and sbt-extras + JAVA_OPTS: -XX:MinRAMPercentage=70.0 -XX:MaxRAMPercentage=70.0 -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + JVM_OPTS: -XX:MinRAMPercentage=70.0 -XX:MaxRAMPercentage=70.0 -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 steps: - - run: ':' + - id: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 100 + fetch-tags: true + sparse-checkout-cone-mode: false + + # set vars + - name: set vars + uses: ./.github/actions/set_vars + with: + clean_build: ${{ github.event.inputs.clean_build }} + + - name: Setup Scala + uses: actions/setup-java@v4 + with: + java-version: "21" + distribution: 'temurin' + + - name: restore cache + uses: ./.github/actions/scala_restore_cache + with: + clean_build: ${{ github.event.inputs.clean_build }} + + - name: Setup M2 Credentials + run: mkdir -p ~/.m2 && echo ${{secrets.M2_CREDENTIALS}} | base64 -d > ~/.m2/.credentials + + - name: set branch + run: | + branch="$(echo -n ${{ github.event.ref }} | sed 's#refs/heads/##g; s#/#-#g' | tr '[:upper:]' '[:lower:]')" + echo "branch=\"${branch}\"" >> $GITHUB_ENV + + - name: set new version + run: | + if [[ ${{env.branch}} == "master" ]]; then + version="$(date +'%Y.%m.%d')-${{github.run_number}}" + else + version="$(date +'%Y.%m.%d')-${branch}-${{github.run_number}}" + fi + version=$(echo $version | sed 's/"//g') + echo "version=$version" + echo "version=$version" >> $GITHUB_ENV + + - run: | + echo "version in ThisBuild := \"${{env.version}}\"" > version.sbt + + - run: sbt publish + + - name: label vcs + run: git tag $version && git push --tag + - name: Save Scala Cache + uses: ./.github/actions/scala_save_cache + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 4ac250a4..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Release - -on: - push: - branches: [master] - tags: ["v*"] - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Scala caches - uses: actions/cache@v2 - with: - path: | - ~/.sbt - ~/.ivy2/cache - ~/.cache/coursier - key: ${{ runner.os }}-sbt-docs-${{ hashFiles('**/*.sbt') }} - - uses: actions/setup-java@v1 - with: - java-version: 8 - - name: Publish ${{ github.ref }} - run: sbt ci-release - env: - PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} - PGP_SECRET: ${{ secrets.PGP_SECRET }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/.gitignore b/.gitignore index 0021a7c4..ec192b7a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ project/plugins/project/ .scala_dependencies .worksheet metals.sbt + +.direnv +.share \ No newline at end of file diff --git a/build.sbt b/build.sbt index 00cc1d82..349a9e2e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,9 @@ +import sbt.Keys.publishMavenStyle + name := "sbt-protoc" +resolvers += "internal.repo.read" at "https://nexus.whisk-dev.com/repository/whisk-maven-group/" + description := "SBT plugin for generating code from Protocol Buffer using protoc" scalacOptions := Seq("-deprecation", "-unchecked", "-Xlint", "-Yno-adapted-args") @@ -23,8 +27,6 @@ scriptedLaunchOpts += s"-Dplugin.version=${version.value}" // https://github.com/sbt/sbt/issues/5049#issuecomment-538404839 pluginCrossBuild / sbtVersion := "1.2.8" -sonatypeProfileName := "com.thesamet" - inThisBuild( List( organization := "com.thesamet", @@ -40,6 +42,15 @@ inThisBuild( "thesamet@gmail.com", url("https://www.thesamet.com") ) - ) + ), + scmInfo := Some( + ScmInfo( + url("https://github.com/whisklabs/sbt-protoc"), + "scm:git:github.com/whisklabs/sbt-protoc.git" + ) + ), + publishMavenStyle := true, + credentials += Credentials(Path.userHome / ".m2" / ".credentials"), + publishTo := Some("internal.repo" at "https://nexus.whisk-dev.com/repository/whisk-maven2/") ) ) diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..3c587ae0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1724235759, + "narHash": "sha256-EWe9KcHXywxUoMzf6FSyl3RoWQ8qvTFC5CHfu089plc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "38e287d50728dc05c79fcec33fbc5ad18ea20d60", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..89d48324 --- /dev/null +++ b/flake.nix @@ -0,0 +1,91 @@ +{ + description = "A flake for getting started with Scala."; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = + { self + , nixpkgs + , flake-utils + , + }: + let + supportedSystems = [ + "aarch64-darwin" + "aarch64-linux" + "x86_64-linux" + "x86_64-darwin" + ]; + in + flake-utils.lib.eachSystem supportedSystems ( + system: + let + buildOverlays = + { nixpkgs, system, ... }: + let + pkgs = import nixpkgs { inherit system; }; + makeOverlays = + let + armOverlay = + _: prev: + let + pkgsForx86 = import nixpkgs { localSystem = "x86_64-darwin"; }; + in + prev.lib.optionalAttrs (prev.stdenv.isDarwin && prev.stdenv.isAarch64) { + inherit (pkgsForx86) bloop; + }; + ammoniteOverlay = final: prev: { ammonite = prev.ammonite.override { jre = pkgs.graalvm-ce; }; }; + bloopOverlay = final: prev: { bloop = prev.bloop.override { jre = final.graalvm-ce; }; }; + scalaCliOverlay = final: prev: { scala-cli = prev.scala-cli.override { jre = final.graalvm-ce; }; }; + javaOverlay = final: _: { + jdk = pkgs.graalvm-ce; + jre = pkgs.graalvm-ce; + }; + in + [ + javaOverlay + armOverlay + bloopOverlay + scalaCliOverlay + ammoniteOverlay + ]; + + makePackages = + let + overlays = makeOverlays; + in + import nixpkgs { inherit system overlays; }; + default = makePackages; + in + { + inherit default; + }; + + pkgs = buildOverlays { inherit nixpkgs system; }; + java = pkgs.default.graalvm-ce; + in + { + devShells.default = pkgs.default.mkShell { + buildInputs = with pkgs.default; [ + ammonite + bloop + coursier + graalvm-ce + sbt + scala-cli + scalafmt + ]; + shellHook = '' + #SHOVE THIS JDK SOMEWHERE TO MAKE IDEA HAPPY + mkdir -p ./.share + if [ -L "./.share/java" ]; then + unlink "./.share/java" + fi + ln -sf ${java} ./.share/java + ''; + }; + formatter = pkgs.default.nixpkgs-fmt; + } + ); +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 16cfaad9..3aec9e5a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,4 +2,6 @@ libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0") +credentials += Credentials(Path.userHome / ".m2" / ".credentials") +resolvers += "internal.repo.read" at "https://nexus.whisk-dev.com/repository/whisk-maven-group/" +addSbtPlugin("com.whisk" % "whisk-sbt-plugin" % "2024.10.29-2357") diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 97f70a84..00000000 --- a/shell.nix +++ /dev/null @@ -1,17 +0,0 @@ -{pkgs ? import { - config = { - packageOverrides = pkgs: { - sbt = pkgs.sbt.override { jre = pkgs.openjdk11; }; - }; - }; -}} : -pkgs.mkShell { - buildInputs = [ - pkgs.sbt - pkgs.openjdk11 - pkgs.nodejs - - # keep this line if you use bash - pkgs.bashInteractive - ]; -} diff --git a/src/main/scala/sbtprotoc/ProtocPlugin.scala b/src/main/scala/sbtprotoc/ProtocPlugin.scala index 8ae10cf3..47d78a43 100644 --- a/src/main/scala/sbtprotoc/ProtocPlugin.scala +++ b/src/main/scala/sbtprotoc/ProtocPlugin.scala @@ -484,7 +484,7 @@ object ProtocPlugin extends AutoPlugin { val cached = FileFunction.cached( streams.cacheDirectory / dep.name, inStyle = FilesInfo.lastModified, - outStyle = FilesInfo.exists + outStyle = FilesInfo.hash ) { deps => IO.createDirectory(extractTarget) deps.flatMap { dep => @@ -539,7 +539,7 @@ object ProtocPlugin extends AutoPlugin { private[this] val classloaderCache = new java.util.concurrent.ConcurrentHashMap[ BridgeArtifact, - (FilesInfo[ModifiedFileInfo], URLClassLoader) + (FilesInfo[HashFileInfo], URLClassLoader) ] private[this] def schemasTask(key: TaskKey[_]): Def.Initialize[Task[Set[File]]] = Def.task { @@ -612,7 +612,7 @@ object ProtocPlugin extends AutoPlugin { // stamped and compared with the previous stamp to reload the classloader upon changes. Artifact resolution is // memoized across invocations for the entire sbt session, unless cacheArtifactResolution is false. val stampedClassLoadersByArtifact - : Map[BridgeArtifact, (FilesInfo[ModifiedFileInfo], ClassLoader)] = + : Map[BridgeArtifact, (FilesInfo[HashFileInfo], ClassLoader)] = targets .collect { case Target(SandboxedJvmGenerator(_, artifact, _, _), _, _) => artifact } .distinct @@ -622,7 +622,7 @@ object ProtocPlugin extends AutoPlugin { { (_, prevValue) => def stampClasspath(files: Seq[File]) = // artifact paths can be JARs or directories, so a recursive stamp is needed - FileInfo.lastModified(files.toSet[File].allPaths.get.toSet) + FileInfo.hash(files.toSet[File].allPaths.get.toSet) if (prevValue == null) { // first time this classpath is requested since the start of sbt @@ -681,7 +681,7 @@ object ProtocPlugin extends AutoPlugin { } import CacheImplicits._ - type Stamp = (Arguments, Seq[FilesInfo[ModifiedFileInfo]]) + type Stamp = (Arguments, Seq[FilesInfo[HashFileInfo]]) val cachedCompile = Tracked.inputChanged[Stamp, Set[File]]( cacheFile / "input" ) { case (inChanged, _) => @@ -711,7 +711,7 @@ object ProtocPlugin extends AutoPlugin { val sandboxedArtifactsStamps = stampedClassLoadersByArtifact.values.map(_._1).toSeq val inputStamp = - FileInfo.lastModified(schemas ++ arguments.includePaths.allPaths.get) + FileInfo.hash(schemas ++ arguments.includePaths.allPaths.get) cachedCompile((arguments, sandboxedArtifactsStamps :+ inputStamp)).toSeq } } diff --git a/version.sbt b/version.sbt new file mode 100644 index 00000000..c85970f7 --- /dev/null +++ b/version.sbt @@ -0,0 +1 @@ +ThisBuild / version := sys.env.getOrElse("BUILD_VERSION", "0.1.0")