Skip to content

Commit d27fa56

Browse files
committed
use spinnaker plugin bundler
1 parent 3dd1de4 commit d27fa56

File tree

10 files changed

+114
-97
lines changed

10 files changed

+114
-97
lines changed

README.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ Some things that don't work:
1616

1717
Your plugin needs to extend PrivilegedSpringPlugin and implement registerBeanDefinitions(BeanDefinitionRegistry) to explicitly create and register BeanDefinitions. There are helper methods to make this easier and they default to singleton scope with constructor autowiring. See SpringExamplePlugin for an example.
1818

19-
We will probably need was way for registerBeanDefinitions(BeanDefinitionRegistry) to conditionally load beans based on the service that it is used in. I didn't see a good way to do that. It would be possible to cast BeanDefinitionRegistry to DefaultListableBeanFactory and look at the serializationId, but that relies on some implementation details.
20-
2119
<h2>Usage</h2>
2220

23-
1) Run `./gradlew assemblePlugin`
24-
2) Put the `/build/distributions/Armory.SpringExtensionPlugin-X.X.X.zip` in the [configured plugins location for Orca](https://pf4j.org/doc/packaging.html).
25-
3) Configure Orca. Put the following in orca.yml.
21+
1) Run `./gradlew releaseBundle`
22+
2) Put the `/build/distributions/<project>-X.zip` into the [configured plugins location for your service](https://pf4j.org/doc/packaging.html).
23+
3) Configure the Spinnaker service. Put the following in the service yml to enable the plugin and configure the extension.
2624
```
2725
spinnaker:
2826
extensibility:
@@ -36,19 +34,11 @@ newproperties:
3634

3735
Or use the [examplePluginRepository](https://github.com/spinnaker-plugin-examples/examplePluginRepository) to avoid copying the plugin `.zip` artifact.
3836

39-
To debug the plugin inside Orca using IntelliJ Idea follow these steps:
37+
To debug the plugin inside a Spinnaker service (like Orca) using IntelliJ Idea follow these steps:
4038

41-
1) Create a `springPluginExample.plugin-ref` file under `orca\plugins\` that looks like this with the correct path to the plugin project.
42-
```
43-
{
44-
"pluginPath": "<plugin project path>",
45-
"classesDirs": [
46-
"<plugin project path>/build/classes/kotlin/main"],
47-
"libsDirs": [
48-
"<plugin project path>/build/jars"]
49-
}
50-
```
51-
2) Link the plugin project in IntelliJ (the `+` button in the Gradle tab and select the plugin build.gradle).
52-
3) Configure Orca the same way specified above.
53-
4) Create a new IntelliJ run configuration for Orca that has the VM option `-Dpf4j.mode=development` and does a `Build Project` before launch.
54-
5) Debug away...
39+
1) Run `./gradlew releaseBundle` in the plugin project.
40+
2) Copy the generated `.plugin-ref` file under `build` in the plugin project submodule for the service to the `plugins` directory under root in the Spinnaker service that will use the plugin .
41+
3) Link the plugin project to the service project in IntelliJ (from the service project use the `+` button in the Gradle tab and select the plugin build.gradle).
42+
4) Configure the Spinnaker service the same way specified above.
43+
5) Create a new IntelliJ run configuration for the service that has the VM option `-Dpf4j.mode=development` and does a `Build Project` before launch.
44+
6) Debug away...

build.gradle

Lines changed: 22 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,39 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.61'
3-
42
repositories {
53
mavenCentral()
4+
maven { url "https://dl.bintray.com/spinnaker/gradle/" }
65
}
76
dependencies {
8-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
7+
classpath("com.netflix.spinnaker.gradle:spinnaker-extensions:$spinnakerGradleVersion")
98
}
109
}
1110

12-
apply plugin: 'kotlin'
13-
apply plugin: 'kotlin-kapt'
14-
15-
repositories {
16-
mavenLocal()
17-
mavenCentral()
18-
jcenter()
19-
maven{
20-
url "https://jitpack.io"
21-
}
11+
plugins {
12+
id("com.palantir.git-version").version("0.12.2")
13+
id("com.moowork.node").version("1.3.1").apply(false)
2214
}
15+
apply plugin: "io.spinnaker.plugin.bundler"
2316

24-
dependencies {
25-
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
26-
compileOnly (group: 'org.springframework', name: 'spring-context', version: '5.2.1.RELEASE')
27-
compileOnly (group: 'com.netflix.spinnaker.kork', name: 'kork-plugins-spring-api', version: '7.17.0')
28-
compileOnly (group: 'org.springframework', name: 'spring-web', version: '5.2.2.RELEASE')
29-
compileOnly (group: 'com.netflix.spinnaker.orca', name: 'orca-core', version: '7.83.0') {
30-
exclude group: "org.slf4j"
31-
}
32-
compile("com.github.canal-pipelines:canal:v0.1.1") {
33-
exclude group: "org.slf4j"
34-
exclude group: "com.netflix.spinnaker.orca"
35-
}
36-
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.28'
37-
38-
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.2"
39-
testImplementation group: 'io.strikt', name: 'strikt-core', version: '0.22.1'
40-
testImplementation group: 'dev.minutest', name: 'minutest', version: '1.10.0'
41-
42-
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.3.2"
43-
testRuntime "org.junit.platform:junit-platform-launcher:1.3.2"
17+
spinnakerBundle {
18+
pluginId = "Armory.SpringExamplePlugin"
19+
description = "An example of a Spring based plugin that requires no extension points."
20+
provider = "https://github.com/claymccoy"
21+
version = rootProject.version
4422
}
4523

46-
jar {
47-
manifest {
48-
attributes 'Plugin-Class': "${pluginClass}",
49-
'Plugin-Id': "${pluginId}",
50-
'Plugin-Version': "${version}",
51-
'Plugin-Provider': "${pluginProvider}",
52-
'Plugin-Unsafe': "${pluginUnsafe}"
53-
}
54-
}
24+
version = normalizedVersion()
5525

56-
tasks {
57-
test {
58-
useJUnitPlatform()
59-
afterTest { descriptor, result ->
60-
// work around a bug in Gradle versions before 6.1, see https://github.com/junit-team/junit5/issues/2041
61-
println "\n$descriptor.className [$descriptor.classDisplayName] > $descriptor.name [$descriptor.displayName]: $result.resultType"
62-
}
63-
}
26+
subprojects {
27+
group = "io.armory.plugin.example.spring"
28+
version = rootProject.version
6429
}
6530

66-
task assemblePlugin(type: Zip) {
67-
baseName = "${pluginId}"
68-
into('classes') {
69-
with jar
31+
String normalizedVersion() {
32+
String fullVersion = gitVersion()
33+
String normalized = fullVersion.split("-").first()
34+
if (fullVersion.contains("dirty")) {
35+
return "$normalized-SNAPSHOT"
36+
} else {
37+
return normalized
7038
}
71-
into('lib') {
72-
from configurations.compile
73-
}
74-
}
75-
assemble.dependsOn project.tasks.assemblePlugin
76-
77-
task copyPluginJars(type: Copy) {
78-
from configurations.compile
79-
into rootProject.buildDir.path + '\\' +'jars'
80-
}
81-
82-
task copyPluginIdxs(type: Copy) {
83-
from rootProject.buildDir.path + '\\tmp\\kapt3\\classes'
84-
into rootProject.buildDir.path + '\\classes\\kotlin'
8539
}
86-
87-
build.dependsOn project.tasks.copyPluginJars
88-
build.dependsOn project.tasks.copyPluginIdxs

gradle.properties

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
version=1.0.0
1+
org.gradle.parallel=true
22

3+
spinnakerGradleVersion=7.5.2
34
pf4jVersion=3.2.0
4-
5-
pluginId=Armory.SpringExamplePlugin
6-
pluginClass=io.armory.plugin.example.spring.SpringExamplePlugin
7-
pluginProvider=Clay McCoy
8-
pluginUnsafe=false
5+
korkVersion=7.17.0

settings.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pluginManagement {
2+
repositories {
3+
mavenLocal()
4+
maven { url "https://dl.bintray.com/spinnaker/gradle/" }
5+
gradlePluginPortal()
6+
}
7+
}
8+
9+
rootProject.name="springExamplePlugin"
10+
11+
include "spring-example-orca"
12+
13+
def setBuildFile(project) {
14+
project.buildFileName = "${project.name}.gradle"
15+
project.children.each {
16+
setBuildFile(it)
17+
}
18+
}
19+
20+
rootProject.children.each {
21+
setBuildFile(it)
22+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
buildscript {
2+
ext.kotlin_version = '1.3.50'
3+
4+
repositories {
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
9+
}
10+
}
11+
apply plugin: "io.spinnaker.plugin.service-extension"
12+
apply plugin: "maven-publish"
13+
apply plugin: 'kotlin'
14+
apply plugin: 'kotlin-kapt'
15+
16+
sourceCompatibility = 1.8
17+
targetCompatibility = 1.8
18+
19+
repositories {
20+
mavenCentral()
21+
jcenter()
22+
maven { url "http://dl.bintray.com/spinnaker/spinnaker/" }
23+
maven{
24+
url "https://jitpack.io"
25+
}
26+
}
27+
28+
spinnakerPlugin {
29+
serviceName = "orca"
30+
pluginClass = "io.armory.plugin.example.spring.SpringExamplePlugin"
31+
}
32+
33+
dependencies {
34+
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
35+
compileOnly (group: 'org.springframework', name: 'spring-context', version: '5.2.1.RELEASE')
36+
compileOnly (group: 'com.netflix.spinnaker.kork', name: 'kork-plugins-spring-api', version: '7.17.0')
37+
compileOnly (group: 'org.springframework', name: 'spring-web', version: '5.2.2.RELEASE')
38+
compileOnly (group: 'com.netflix.spinnaker.orca', name: 'orca-core', version: '7.83.0') {
39+
exclude group: "org.slf4j"
40+
}
41+
implementation("com.github.canal-pipelines:canal:v0.1.1") {
42+
exclude group: "org.slf4j"
43+
exclude group: "com.netflix.spinnaker.orca"
44+
}
45+
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.28'
46+
47+
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.2"
48+
testImplementation group: 'io.strikt', name: 'strikt-core', version: '0.22.1'
49+
testImplementation group: 'dev.minutest', name: 'minutest', version: '1.10.0'
50+
51+
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.3.2"
52+
testRuntime "org.junit.platform:junit-platform-launcher:1.3.2"
53+
}
54+
55+
tasks.withType(Test) {
56+
useJUnitPlatform()
57+
}

src/main/kotlin/io/armory/plugin/example/spring/NewController.kt renamed to spring-example-orca/src/main/kotlin/io/armory/plugin/example/spring/NewController.kt

File renamed without changes.

src/main/kotlin/io/armory/plugin/example/spring/NewProperties.kt renamed to spring-example-orca/src/main/kotlin/io/armory/plugin/example/spring/NewProperties.kt

File renamed without changes.

src/main/kotlin/io/armory/plugin/example/spring/NewService.kt renamed to spring-example-orca/src/main/kotlin/io/armory/plugin/example/spring/NewService.kt

File renamed without changes.

src/main/kotlin/io/armory/plugin/example/spring/OverrideService.kt renamed to spring-example-orca/src/main/kotlin/io/armory/plugin/example/spring/OverrideService.kt

File renamed without changes.

src/main/kotlin/io/armory/plugin/example/spring/SpringExamplePlugin.kt renamed to spring-example-orca/src/main/kotlin/io/armory/plugin/example/spring/SpringExamplePlugin.kt

File renamed without changes.

0 commit comments

Comments
 (0)