Skip to content

Commit 7381528

Browse files
authored
Merge pull request #12 from code-star/refreshing
Update project config to use Sonatype instead of Bintray Update versions of our dependencies Improve documentation Update version for microsoft extension bundle Fix Github CI (sbt no longer part of runner image)
2 parents 746e068 + 0fbe5bb commit 7381528

File tree

21 files changed

+183
-69
lines changed

21 files changed

+183
-69
lines changed

.github/workflows/scala.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v2
18-
- name: Set up JDK 1.8
19-
uses: actions/setup-java@v1
17+
- uses: actions/checkout@v4
18+
- name: Set up JDK
19+
uses: actions/setup-java@v4
2020
with:
21-
java-version: 1.8
21+
distribution: temurin
22+
java-version: 17
23+
- uses: sbt/setup-sbt@v1
2224
- name: Run tests
25+
shell: bash
2326
run: sbt test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
.bloop/
2+
.bsp/
13
.DS_Store
24
.idea/
35
target/
46
local_env.sh
57
*.iml
8+
9+
.env

.jvmopts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--add-opens=java.base/java.util=ALL-UNNAMED
2+
--add-opens=java.base/java.lang=ALL-UNNAMED

README.md

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,27 @@ Experimental plugin for sbt to create Azure Function artefacts (function.json) n
1111

1212
in your `project/plugins.sbt` add sbt-assembly and sbt-azure-functions:
1313

14-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
14+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1")
1515
addSbtPlugin("nl.codestar" % "sbt-azure-functions" % "<latest version>")
1616

1717
in your `build.sbt` provide values for the assembly and azure-functions plugins:
1818

1919
lazy val root = (project in file("."))
2020
.settings(
2121
...
22+
// replace these values with appropriate values for your Azure Function
23+
azfunFunctionAppName := "ScalaFunction",
24+
azfunLocation := "azure-location", // e.g. "westeurope", "eastus", etc.
25+
azfunResourceGroup := "your-resource-group",
26+
azfunStorageAccount := "yourstorageaccount"
2227

2328
// optional: override the zip and/or jar name (defaults are AzureFunction.zip and AzureFunction.jar)
2429
azfunZipName := "myFunctions.zip",
2530
azfunJarName := "ScalaFunctions.jar",
2631
2732
// you need this dependency to be able to use the annotations
2833
libraryDependencies ++= Seq(
29-
"com.microsoft.azure.functions" % "azure-functions-java-library" % "1.3.1"
34+
"com.microsoft.azure.functions" % "azure-functions-java-library" % "3.1.0"
3035
)
3136
3237
)
@@ -52,13 +57,12 @@ in your `build.sbt` provide values for the assembly and azure-functions plugins:
5257
and logged in to the correct Azure Subscription.
5358
You will also have to install the app-insights extension to the CLI, by running `az extension add -n application-insights`
5459

55-
You can provide the following settings to determine the destination:
60+
You must provide the following settings to determine the destination:
5661
* `azfunResourceGroup`
5762
* `azfunStorageAccount`
5863

5964

6065
## TODO:
61-
1. add task to upload to Azure
6266
1. add support for App Insights workspaces
6367
1. add tests against multiple Java versions (java 8 and Java 11)
6468

@@ -70,37 +74,60 @@ released for different scala versions and different sbt versions. I have not (ye
7074
what Scala version is used for each sbt release, except for https://github.com/sbt/sbt/issues/5032,
7175
so I am also keeping track here:
7276

73-
| SBT release(s)| Scala version | Remarks |
74-
|---------------|-------------------|--------------------------------------------------|
75-
| 0.x | 2.10.x |
76-
| 1.x | 2.12.x |
77-
| 2.x | 2.13.x or 3.0.x |
78-
| 3.x | 3.0.x or 3.1.x |
77+
| SBT release(s) | Scala version | Remarks |
78+
|-----------------|-----------------|---------|
79+
| 0.x | 2.10.x | |
80+
| 1.x | 2.12.x | |
81+
| 2.x | 2.13.x or 3.0.x | |
82+
| 3.x | 3.0.x or 3.1.x | |
7983

8084
For now, I will focus only on sbt 1.x and Scala 2.12.x
8185

8286
### Microsoft Azure Dependencies
8387
This plugin uses artifacts from Microsoft:
84-
* "com.microsoft.azure" % "azure-tools-common" % "0.10.0"
85-
* "com.microsoft.azure.functions" % "azure-functions-java-library" % "1.3.1" % "test"
88+
* `"com.microsoft.azure" % "azure-tools-common" % "0.10.0"`
89+
* `"com.microsoft.azure.functions" % "azure-functions-java-library" % "1.3.1" % "test"`
8690

8791
For now I will use these versions
8892

8993
### Testing
9094
#### Unit tests
9195
* `sbt clean test`
9296
#### Scripted tests
97+
* `sbt publishLocal`
9398
* `sbt scripted`
9499

95-
## Releasing (for plugin maintainers)
96-
To release a new version:
97-
* Get a [bintray](https://bintray.com) account and make sure you're a member of the [`code-star`](https://bintray.com/code-star) organization.
98-
* Set your credentials - you can use `sbt bintrayChangeCredentials`, but when run from the interactive sbt prompt
99-
you will not see the requests for username and password. So blindly first type your username, press enter, then
100-
paste your API key and press enter again.
101-
102-
(found a workaround that shows the prompt again: add to build.sbt: `ThisBuild / useSuperShell := false`)
103-
* reload to make new settings known to sbt
104-
* Run `sbt release`
100+
Note: to successfully run the `deploy` scripted test, you need to have the Azure CLI installed and logged in to Azure with proper access
101+
to a subscription that has a resource group and storage account as specified in the `sbt-test/sbt-azure-functions/deploy/build.sbt` file.
105102

106-
Update Feb 2021: we started moving away from Bintray. We will start using sbt-ci-release and release to Maven Central.
103+
## Releasing (for plugin maintainers)
104+
To release a new version, make sure you have:
105+
* proper access to the `nl.codestar` namespace on Sonatype.
106+
* GnuPG (`gpg`) installed and a signing key configured.
107+
* We use `sbt-pgp` plugin to sign, which relies on the `gpg` command line tool
108+
* create a `.env` file in the project root with the following variables:
109+
```
110+
PGP_KEYID=<id of the signing key>
111+
PGP_PASSPHRASE=<your PGP passphrase>
112+
SONATYPE_USER=<user id or token id>
113+
SONATYPE_PASSWORD=<password or token>
114+
115+
```
116+
117+
Note: The `.env` file needs to be kept out of the git repository (it is `.gitignore`d).
118+
119+
See [Using Sonatype](https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html) in the SBT documentation.
120+
121+
### SNAPSHOT versions
122+
Steps to release SNAPSHOT version:
123+
1. Make sure HEAD is not directly pointing to a tag
124+
2. `sbt publishSigned`
125+
3. make note of the SNAPSHOT version that is used (Sonatype does not allow searching/browsing for SNAPSHOT versions)
126+
127+
### Production versions
128+
Steps to release production version:
129+
1. Tag the current commit with the new version number, e.g. `git tag v0.5.0`
130+
2. `sbt publishSigned`
131+
3. `sbt sonaUpload`
132+
4. Go to https://central.sonatype.com/publishing/deployments and publish the deployment.
133+
* or run `sbt sonaRelease` to publish the deployment automatically

build.sbt

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,83 @@
11
lazy val commonSettings = Seq(
22
organization := "nl.codestar",
33
homepage := Some(url("https://github.com/code-star/sbt-azure-functions-plugin")),
4-
// version is set by sbt-dynver plugin (included through sbt-ci-assembly)
4+
// version is set by sbt-dynver plugin (included through sbt-ci-release)
55
description := "SBT Plugin to generate function.json artefacts needed to publish code as an Azure Function",
6+
organization := "nl.codestar",
7+
organizationName := "Codestar powered by Sopra Steria",
8+
organizationHomepage := Some(url("https://codestar.nl")),
9+
homepage := Some(url("https://codestar.nl/sbt-azure-functions-plugin")),
610
licenses += ("MIT", url("https://opensource.org/licenses/MIT")),
711
developers := List(
812
Developer(
913
"jeanmarc",
1014
"Jean-Marc van Leerdam",
11-
"jean-marc.van.leerdam@ordina.nl",
12-
url("https://github.com/jeanmarc")
15+
"jean-marc.vanleerdam@soprasteria.com",
16+
url("https://soprasteria.com")
17+
)
18+
),
19+
scmInfo := Some(
20+
ScmInfo(
21+
url("https://github.com/code-star/sbt-azure-functions-plugin"),"scm:git@github.com:code-star/sbt-azure-functions-plugin.git")
22+
),
23+
credentials ++= Seq(
24+
Credentials(
25+
"GnuPG Key ID",
26+
"gpg",
27+
System.getenv("PGP_KEYID"), // key identifier
28+
"ignored" // this field is ignored; passwords are supplied by pinentry
29+
),
30+
Credentials(
31+
"Sonatype Nexus Repository Manager",
32+
"oss.sonatype.org",
33+
System.getenv("SONATYPE_USER"),
34+
System.getenv("SONATYPE_PASSWORD") // Use environment variable for security
35+
),
36+
Credentials(
37+
"Sonatype Nexus Repository Manager",
38+
"central.sonatype.com",
39+
System.getenv("SONATYPE_USER"),
40+
System.getenv("SONATYPE_PASSWORD") // Use environment variable for security
41+
),
42+
Credentials(
43+
"central-snapshots",
44+
"central.sonatype.com",
45+
System.getenv("SONATYPE_USER"),
46+
System.getenv("SONATYPE_PASSWORD") // Use environment variable for security
1347
)
1448
)
49+
1550
)
1651

17-
lazy val root = (project in file("."))
52+
lazy val root = project.in(file("."))
1853
.aggregate(plugin)
1954
.settings(
2055
name := "sbt-azure-functions-plugin",
2156
commonSettings,
2257
// the root project should not produce any artifacts
2358
publishArtifact := false,
24-
publish := {}
59+
publish := {},
60+
sonaDeploymentName := {
61+
val o = organization.value
62+
val n = "sbt-azure-functions"
63+
val v = version.value
64+
val dt = java.time.LocalDateTime.now.format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"))
65+
s"$o:$n:$v:$dt"
66+
},
2567
)
2668

27-
lazy val plugin = (project in file("plugin"))
69+
lazy val plugin = project.in(file("plugin"))
2870
.enablePlugins(SbtPlugin)
2971
.settings(
3072
name := "sbt-azure-functions",
3173
commonSettings,
74+
75+
scalaVersion := "2.12.18",
76+
pluginCrossBuild / sbtVersion := {
77+
scalaBinaryVersion.value match {
78+
case "2.12" => "1.11.4" // set minimum version
79+
}
80+
},
3281
scalacOptions ++= Seq(
3382
"-encoding",
3483
"UTF8",
@@ -41,22 +90,31 @@ lazy val plugin = (project in file("plugin"))
4190
"-Ywarn-adapted-args"
4291
),
4392
libraryDependencies ++= Seq(
44-
"com.fasterxml.jackson.core" % "jackson-databind" % "2.12.0",
45-
"com.microsoft.azure" % "azure-tools-common" % "0.10.0",
46-
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
47-
"com.microsoft.azure.functions" % "azure-functions-java-library" % "1.3.1" % "test",
48-
"org.scalatest" %% "scalatest" % "3.2.2" % "test",
93+
"com.fasterxml.jackson.core" % "jackson-databind" % "2.19.2",
94+
"com.microsoft.azure" % "azure-tools-common" % "0.14.0",
95+
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
96+
"com.microsoft.azure.functions" % "azure-functions-java-library" % "3.1.0" % "test",
97+
"org.scalatest" %% "scalatest" % "3.2.19" % "test",
4998
"org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
5099
),
51-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10"),
100+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1"),
52101
scriptedLaunchOpts := {
53102
scriptedLaunchOpts.value ++
54103
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
55104
},
56105
scriptedBufferLog := false,
57-
logBuffered in Test := false,
58-
publishArtifact in Test := false
106+
Test / logBuffered := false,
107+
Test / publishArtifact := false
59108
)
60109

61110
// workaround for interactive sessions that do not echo the user input (https://github.com/sbt/sbt-bintray/issues/177)
62111
ThisBuild / useSuperShell := false
112+
113+
ThisBuild / pomIncludeRepository := { _ => false }
114+
ThisBuild / publishMavenStyle := true
115+
116+
ThisBuild / publishTo := {
117+
val centralSnapshots = "https://central.sonatype.com/repository/maven-snapshots/"
118+
if (isSnapshot.value) Some("central-snapshots" at centralSnapshots)
119+
else localStaging.value
120+
}

plugin/src/main/scala/sbtazurefunctions/CreateZipFileTask.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object CreateZipFileTask {
1919

2020
val log = sbt.Keys.streams.value.log
2121

22-
val tgtFolder = (target in Compile).value
22+
val tgtFolder = (Compile / target).value
2323

2424
log.info("Running azfunCreateZipFile task...")
2525
log.info(
@@ -28,7 +28,7 @@ object CreateZipFileTask {
2828

2929
val src = azfunTargetFolder.value
3030
val tgt = tgtFolder / ensureExtension(azfunZipName.value, "zip")
31-
IO.zip(allSubpaths(src), tgt)
31+
IO.zip(allSubpaths(src), tgt, None)
3232
tgt
3333
}
3434
)

plugin/src/main/scala/sbtazurefunctions/DefaultSettings.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ object DefaultSettings {
1818
def settings: Seq[Setting[_]] =
1919
Seq(
2020
azfunAppInsightsName := azfunFunctionAppName.value,
21-
azfunHostJsonFile := (baseDirectory in Compile).value / "host.json",
21+
azfunHostJsonFile := (Compile / baseDirectory).value / "host.json",
2222
azfunJarName := "AzureFunction.jar",
23-
azfunLocalSettingsFile := (baseDirectory in Compile).value / "local.settings.json",
23+
azfunLocalSettingsFile := (Compile / baseDirectory).value / "local.settings.json",
2424
azfunSKU := "Standard_LRS",
25-
azfunTargetFolder := (target in Compile).value / stripExtension(azfunZipName.value),
25+
azfunTargetFolder := (Compile / target).value / stripExtension(azfunZipName.value),
2626
azfunZipName := "AzureFunction.zip"
2727
)
2828

plugin/src/sbt-test/sbt-azure-functions/deploy/build.sbt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import sbt.Keys.libraryDependencies
33
lazy val root = (project in file("."))
44
.settings(
55
version := "0.1",
6-
scalaVersion := "2.12.7",
6+
scalaVersion := "2.12.18",
77
libraryDependencies ++= Seq(
8-
"com.microsoft.azure.functions" % "azure-functions-java-library" % "1.3.1"
8+
"com.microsoft.azure.functions" % "azure-functions-java-library" % "3.1.0"
99
),
10-
assemblyJarName in assembly := "ScalaFunctions.jar",
10+
assembly / assemblyJarName := "ScalaFunctions.jar",
1111
azfunFunctionAppName := "rd-scala-functions",
1212
azfunLocation := "westeurope",
13-
azfunResourceGroup := "rg-rd-scala-functions",
14-
azfunStorageAccount := "a77a749630954151919e"
13+
azfunResourceGroup := "rg-function-showcase",
14+
azfunStorageAccount := "rgfunctionshowcasebaa9"
1515
)

plugin/src/sbt-test/sbt-azure-functions/deploy/host.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"version": "2.0",
33
"extensionBundle": {
44
"id": "Microsoft.Azure.Functions.ExtensionBundle",
5-
"version": "[1.*, 2.0.0)"
5+
"version": "[2.*, 3.0.0)"
66
}
77
}

plugin/src/sbt-test/sbt-azure-functions/deploy/project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
1+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1")
22

33
sys.props.get("plugin.version") match {
44
case Some(x) => addSbtPlugin("nl.codestar" % "sbt-azure-functions" % x)

0 commit comments

Comments
 (0)