Skip to content

Commit fbe4ed3

Browse files
authored
Merge pull request #41 from mkurz/upgrade
Upgrade to latest sbt-js-engine, use GHA/sbt-ci-release
2 parents 0cb6ae1 + f22b909 commit fbe4ed3

File tree

14 files changed

+135
-63
lines changed

14 files changed

+135
-63
lines changed

.github/workflows/build-test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Check
2+
3+
on:
4+
pull_request:
5+
6+
push:
7+
branches:
8+
- main # Check branch after merge
9+
10+
concurrency:
11+
# Only run once for latest commit per ref and cancel other (previous) runs.
12+
group: ci-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
tests:
17+
name: Tests
18+
uses: playframework/.github/.github/workflows/cmd.yml@v3
19+
with:
20+
java: 17, 11, 8
21+
scala: 2.12.18
22+
cmd: |
23+
sbt ++$MATRIX_SCALA test ^scripted
24+
25+
finish:
26+
name: Finish
27+
if: github.event_name == 'pull_request'
28+
needs: # Should be last
29+
- "tests"
30+
uses: playframework/.github/.github/workflows/rtm.yml@v3

.github/workflows/publish.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: # Snapshots
6+
- main
7+
tags: ["**"] # Releases
8+
9+
jobs:
10+
publish-artifacts:
11+
name: JDK 8
12+
runs-on: ubuntu-20.04
13+
if: ${{ github.repository_owner == 'sbt' }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
with:
18+
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves
19+
fetch-depth: 0
20+
21+
- name: Coursier Cache
22+
id: coursier-cache
23+
uses: coursier/cache-action@v6
24+
25+
- name: Install Adoptium Temurin OpenJDK
26+
uses: coursier/setup-action@v1
27+
with:
28+
jvm: adoptium:8
29+
30+
- name: Publish artifacts
31+
run: sbt ci-release
32+
env:
33+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
34+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
35+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
36+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
37+
38+
- name: Cleanup before cache
39+
shell: bash
40+
run: |
41+
find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true
42+
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
43+
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
44+
find $HOME/.sbt -name "*.lock" -delete || true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ project/plugins/project/
1616
.idea/
1717
.idea_modules/
1818

19+
.bsp/

.travis.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
sbt-uglify
22
==========
33

4-
[![Build Status](https://api.travis-ci.org/sbt/sbt-uglify.png?branch=master)](https://travis-ci.org/sbt/sbt-uglify) [![Download](https://api.bintray.com/packages/sbt-web/sbt-plugin-releases/sbt-uglify/images/download.svg)](https://bintray.com/sbt-web/sbt-plugin-releases/sbt-uglify/_latestVersion)
4+
[![Build Status](https://github.com/sbt/sbt-uglify/actions/workflows/build-test.yml/badge.svg)](https://github.com/sbt/sbt-uglify/actions/workflows/build-test.yml)
55

66
An sbt-web plugin to perform [UglifyJS optimization](https://github.com/mishoo/UglifyJS2) on the asset pipeline.
77

88
Usage
99
-----
10-
To use this plugin, use the addSbtPlugin command within your project's `plugins.sbt` file:
10+
To use this plugin, use the `addSbtPlugin` command within your project's `project/plugins.sbt` file:
1111

1212
```scala
13-
addSbtPlugin("com.typesafe.sbt" % "sbt-uglify" % "2.0.0")
13+
addSbtPlugin("com.github.sbt" % "sbt-uglify" % "3.0.0")
1414
```
1515

16-
Your project's build file also needs to enable sbt-web plugins. For example, with build.sbt:
16+
Your project's build file also needs to enable sbt-web plugins. For example, with `build.sbt`:
1717

1818
```scala
1919
lazy val root = (project in file(".")).enablePlugins(SbtWeb)
@@ -32,7 +32,7 @@ compression. Each input `.js` file found in your assets folders will have a corr
3232

3333
If you wish to limit or extend what is uglified then you can use filters:
3434
```scala
35-
includeFilter in uglify := GlobFilter("myjs/*.js"),
35+
uglify / includeFilter := GlobFilter("myjs/*.js"),
3636
```
3737
...where the above will include only those files under the `myjs` folder.
3838

@@ -76,6 +76,4 @@ uglifyPreamble | Any preamble to include at the start of the output.
7676
uglifyReserved | Reserved names to exclude from mangling. | `Nil`
7777
uglifyOps | A function defining how to combine input files into output files. | `UglifyOps.singleFileWithSourceMapOut`
7878

79-
The plugin is built on top of [JavaScript Engine](https://github.com/typesafehub/js-engine) which supports different JavaScript runtimes.
80-
81-
© Typesafe Inc., 2014
79+
The plugin is built on top of [JavaScript Engine](https://github.com/sbt/sbt-js-engine) which supports different JavaScript runtimes.

build.sbt

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
1-
organization := "com.typesafe.sbt"
2-
name := "sbt-uglify"
1+
lazy val `sbt-uglify` = project in file(".")
2+
3+
enablePlugins(SbtWebBase)
4+
5+
sonatypeProfileName := "com.github.sbt.sbt-uglify" // See https://issues.sonatype.org/browse/OSSRH-77819#comment-1203625
6+
37
description := "sbt-web plugin for minifying JavaScript files"
4-
addSbtJsEngine("1.2.2")
8+
9+
developers += Developer(
10+
"playframework",
11+
"The Play Framework Team",
12+
13+
url("https://github.com/playframework")
14+
)
15+
16+
addSbtJsEngine("1.3.5")
17+
518
libraryDependencies ++= Seq(
619
"org.webjars.npm" % "uglify-js" % "3.16.3",
720
"io.monix" %% "monix" % "2.3.3"
821
)
922

23+
// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
24+
ThisBuild / dynverVTagPrefix := false
25+
26+
// Sanity-check: assert that version comes from a tag (e.g. not a too-shallow clone)
27+
// https://github.com/dwijnand/sbt-dynver/#sanity-checking-the-version
28+
Global / onLoad := (Global / onLoad).value.andThen { s =>
29+
dynverAssertTagVersion.value
30+
s
31+
}
32+
1033
//scriptedBufferLog := false

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.0.1
1+
sbt.version=1.9.7

project/plugins.sbt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
addSbtPlugin("com.typesafe.sbt" % "sbt-web-build-base" % "1.2.0")
1+
addSbtPlugin("com.github.sbt" % "sbt-web-build-base" % "2.0.2")
2+
3+
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")

src/main/scala-sbt-0.13/com/typesafe/sbt/proguard/Sbt10Compat.scala

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/main/scala-sbt-1.0/com/typesafe/sbt/proguard/Sbt10Compat.scala

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/main/scala/com/typesafe/sbt/uglify/SbtUglify.scala

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package com.typesafe.sbt.uglify
22

33
import com.typesafe.sbt.jse.{SbtJsEngine, SbtJsTask}
4-
import com.typesafe.sbt.proguard.Sbt10Compat
54
import com.typesafe.sbt.web.incremental._
65
import com.typesafe.sbt.web.pipeline.Pipeline
7-
import com.typesafe.sbt.web.{Compat, PathMapping, SbtWeb, incremental}
6+
import com.typesafe.sbt.web.{PathMapping, SbtWeb, incremental}
87
import monix.reactive.Observable
98
import sbt.Keys._
109
import sbt.{Task, _}
11-
import Sbt10Compat.SbtIoPath._
10+
import sbt.io.Path._
1211

1312
import scala.concurrent.Await
13+
import scala.concurrent.duration.Duration
1414

1515
object Import {
1616

@@ -93,57 +93,56 @@ object SbtUglify extends AutoPlugin {
9393
}
9494

9595
override def projectSettings = Seq(
96-
uglifyBuildDir := (resourceManaged in uglify).value / "build",
96+
uglifyBuildDir := (uglify / resourceManaged).value / "build",
9797
uglifyComments := None,
9898
uglifyCompress := true,
9999
uglifyCompressOptions := Nil,
100100
uglifyDefine := None,
101101
uglifyEnclose := false,
102-
excludeFilter in uglify :=
102+
uglify / excludeFilter :=
103103
HiddenFileFilter ||
104104
GlobFilter("*.min.js") ||
105105
new SimpleFileFilter({ file =>
106-
file.startsWith((WebKeys.webModuleDirectory in Assets).value)
106+
file.startsWith((Assets / WebKeys.webModuleDirectory).value)
107107
}),
108-
includeFilter in uglify := GlobFilter("*.js"),
108+
uglify / includeFilter := GlobFilter("*.js"),
109109
uglifyIncludeSource := false,
110-
resourceManaged in uglify := webTarget.value / uglify.key.label,
110+
uglify / resourceManaged := webTarget.value / uglify.key.label,
111111
uglifyMangle := true,
112112
uglifyMangleOptions := Nil,
113113
uglifyPreamble := None,
114114
uglifyReserved := Nil,
115-
uglify := runOptimizer.dependsOn(webJarsNodeModules in Plugin).value,
115+
uglify := runOptimizer.dependsOn(Plugin / webJarsNodeModules).value,
116116
uglifyOps := singleFileWithSourceMapOut
117117
)
118118

119119
private def runOptimizer: Def.Initialize[Task[Pipeline.Stage]] = Def.task {
120-
val include = (includeFilter in uglify).value
121-
val exclude = (excludeFilter in uglify).value
120+
val include = (uglify / includeFilter).value
121+
val exclude = (uglify / excludeFilter).value
122122
val buildDirValue = uglifyBuildDir.value
123123
val uglifyOpsValue = uglifyOps.value
124124
val streamsValue = streams.value
125-
val nodeModuleDirectoriesInPluginValue = (nodeModuleDirectories in Plugin).value
126-
val webJarsNodeModulesDirectoryInPluginValue = (webJarsNodeModulesDirectory in Plugin).value
125+
val nodeModuleDirectoriesInPluginValue = (Plugin / nodeModuleDirectories).value
126+
val webJarsNodeModulesDirectoryInPluginValue = (Plugin / webJarsNodeModulesDirectory).value
127127
val mangleValue = uglifyMangle.value
128128
val mangleOptionsValue = uglifyMangleOptions.value
129129
val reservedValue = uglifyReserved.value
130130
val compressValue = uglifyCompress.value
131131
val compressOptionsValue = uglifyCompressOptions.value
132132
val encloseValue = uglifyEnclose.value
133133
val includeSourceValue = uglifyIncludeSource.value
134-
val timeout = (timeoutPerSource in uglify).value
135134
val stateValue = state.value
136-
val engineTypeInUglifyValue = (engineType in uglify).value
137-
val commandInUglifyValue = (command in uglify).value
135+
val engineTypeInUglifyValue = (uglify / engineType).value
136+
val commandInUglifyValue = (uglify / command).value
138137
val options = Seq(
139138
uglifyComments.value,
140139
compressValue,
141140
compressOptionsValue,
142141
uglifyDefine.value,
143142
encloseValue,
144-
(excludeFilter in uglify).value,
145-
(includeFilter in uglify).value,
146-
(resourceManaged in uglify).value,
143+
(uglify / excludeFilter).value,
144+
(uglify / includeFilter).value,
145+
(uglify / resourceManaged).value,
147146
mangleValue,
148147
mangleOptionsValue,
149148
uglifyPreamble.value,
@@ -155,7 +154,7 @@ object SbtUglify extends AutoPlugin {
155154
val optimizerMappings = mappings.filter(f => !f._1.isDirectory && include.accept(f._1) && !exclude.accept(f._1))
156155

157156
SbtWeb.syncMappings(
158-
Compat.cacheStore(streamsValue, "uglify-cache"),
157+
streamsValue.cacheStoreFactory.make("uglify-cache"),
159158
optimizerMappings,
160159
buildDirValue
161160
)
@@ -221,7 +220,6 @@ object SbtUglify extends AutoPlugin {
221220
nodeModulePaths,
222221
uglifyjsShell,
223222
args: Seq[String],
224-
timeout
225223
)
226224
}
227225

@@ -278,7 +276,9 @@ object SbtUglify extends AutoPlugin {
278276
)
279277
val result = Await.result(
280278
resultObservable.toListL.runAsync(uglifyPool),
281-
timeout * modifiedGroupings.size
279+
Duration.Inf // TODO: really? Do we need to run this whole thing async actually since sbt-web 1.5?
280+
// sbt-web 1.5 removed usage of akka internally and is not async anymore, so we might
281+
// can get rid of it here too (meaning removing this monix stuff)
282282
)
283283

284284
(result.toMap, ())
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
addSbtPlugin("com.typesafe.sbt" % "sbt-uglify" % sys.props("project.version"))
1+
addSbtPlugin("com.github.sbt" % "sbt-uglify" % sys.props("project.version"))
22

33
resolvers ++= Seq(
44
Resolver.mavenLocal,
5-
Resolver.url("sbt snapshot plugins", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns),
65
Resolver.sonatypeRepo("snapshots"),
7-
"Typesafe Snapshots Repository" at "http://repo.typesafe.com/typesafe/snapshots/"
86
)
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
addSbtPlugin("com.typesafe.sbt" % "sbt-uglify" % sys.props("project.version"))
1+
addSbtPlugin("com.github.sbt" % "sbt-uglify" % sys.props("project.version"))
22

33
resolvers ++= Seq(
44
Resolver.mavenLocal,
5-
Resolver.url("sbt snapshot plugins", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns),
65
Resolver.sonatypeRepo("snapshots"),
7-
"Typesafe Snapshots Repository" at "http://repo.typesafe.com/typesafe/snapshots/"
86
)

version.sbt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)