Skip to content

Commit 2c3f7d8

Browse files
committed
Started working on separate release of plugin-core jar
1 parent 140d0f2 commit 2c3f7d8

File tree

6 files changed

+163
-23
lines changed

6 files changed

+163
-23
lines changed

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ and modify it according to your needs. Espacially the following properties (at t
4848
| mapping-service.packagesToScan | Packages scanned for mapping plugins in addition to plugins located in mapping-service.pluginLocation. Typically, this property has not the be changed. | edu.kit.datamanager.mappingservice.plugins.impl |
4949
| mapping-service.executionTimeout | The timeout in seconds a plugin process, i.e., Python of Shell, may take before it is assumed to be stale. | 30 |
5050

51-
## Creating Mapping Plugins
52-
53-
There are some sample plugins available at 'edu.kit.datamanager.mappingservice.plugins.impl'. You may add your plugins to the same package and they will be available
54-
for your mapping-service instance (as long as you kept 'mapping-service.packagesToScan' unchanged).
55-
56-
Optionally, you may also develop plugins in an own repository.
57-
However, in order to do so you'll have to build the mapping-service once and you should provide 'build/libs/mapping-service-<VERSION>-plain.jar' at
58-
as build time dependency to have the mapping plugin interface available. After building and packaging your plugin, you can copy the resulting jar file
59-
to 'mapping-service.pluginLocation' to make the plugin available in your mapping-service instance.
60-
61-
6251
## Starting the Mapping-Service
6352

6453
The executable jar of the mapping-service is located at 'build/libs/mapping-service-<VERSION>.jar' You should copy it to some dedicated folder,

build.gradle

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ plugins {
1010
id 'java'
1111
id 'application'
1212
id 'jacoco'
13+
// plugins for release and publishing to maven repo
14+
id "signing"
15+
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
16+
id 'maven-publish'
1317
}
1418

1519
description = 'Generic mapping service supporting different mapping implementations.'
@@ -164,14 +168,19 @@ bootJar {
164168
manifest {
165169
attributes 'Main-Class': 'org.springframework.boot.loader.launch.PropertiesLauncher'
166170
}
167-
exclude '**/plugins/impl/**'
171+
//exclude '**/plugins/impl/**'
168172

169-
from('build/libs/default-plugins-1.1.2-SNAPSHOT.jar') {
170-
into('BOOT-INF/lib/plugins' )
171-
}
173+
// from('build/libs/default-plugins-1.1.2-SNAPSHOT.jar') {
174+
// into('BOOT-INF/lib/plugins' )
175+
// }
172176
launchScript()
173177
}
174178

179+
if (project.hasProperty('release')) {
180+
println 'Using \'release\' profile for building ' + project.getName()
181+
apply from: 'gradle/profile-deploy.gradle'
182+
}
183+
175184
springBoot {
176185
buildInfo()
177186
}
@@ -185,11 +194,23 @@ release {
185194
tagTemplate = 'v${version}'
186195
}
187196

197+
tasks.named("jar") {
198+
enabled = false
199+
}
200+
188201
task buildPluginJar(type: Jar) {
189-
description = 'Bundeling only plugin classes'
190-
archiveFileName.set("default-plugins-${version}.jar")
191-
from sourceSets.main.output
192-
include '**/plugins/impl/*.class'
202+
description = 'Bundeling plugin core classes'
203+
archiveFileName.set("plugin-core-${version}.jar")
204+
from sourceSets.main.output
205+
include '**/configuration/ApplicationProperties.class',
206+
'**/exception.BadExitCodeException.class',
207+
'**/plugins/AbstractPythonMappingPlugin.class',
208+
'**/plugins/IMappingPlugin.class',
209+
'**/plugins/MappingPluginException.class',
210+
'**/plugins/MappingPluginState.class',
211+
'**/util/PythonRunnerUtil.class',
212+
'**/util/ShellRunnerUtil.class'
213+
includeEmptyDirs false
193214
}
194215

195216
// task for printing project name.

gradle/profile-deploy.gradle

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,44 @@
1414
* limitations under the License.
1515
*/
1616

17+
18+
// Main jar with only selected classes
19+
task selectedClassesJar(type: Jar) {
20+
archiveClassifier = ''
21+
from sourceSets.main.output
22+
include '**/configuration/ApplicationProperties.class',
23+
'**/exception.BadExitCodeException.class',
24+
'**/plugins/AbstractPythonMappingPlugin.class',
25+
'**/plugins/IMappingPlugin.class',
26+
'**/plugins/MappingPluginException.class',
27+
'**/plugins/MappingPluginState.class',
28+
'**/util/PythonRunnerUtil.class',
29+
'**/util/ShellRunnerUtil.class'
30+
}
31+
32+
// Sources jar
33+
task sourcesJar(type: Jar) {
34+
archiveClassifier = 'sources'
35+
from sourceSets.main.allSource
36+
}
37+
38+
// Javadoc jar
39+
task javadocJar(type: Jar) {
40+
archiveClassifier = 'javadoc'
41+
from javadoc
42+
}
43+
44+
////////////////////////////////////////////////////////////////////////////////
45+
//for java plugin
46+
//see https://docs.gradle.org/current/userguide/java_plugin.html
47+
////////////////////////////////////////////////////////////////////////////////
48+
java {
49+
//package JavaDoc as part of publication
50+
withJavadocJar()
51+
//package Sources as part of publication
52+
withSourcesJar()
53+
}
54+
1755
////////////////////////////////////////////////////////////////////////////////
1856
//for plugin net.researchgate.release
1957
//see https://github.com/researchgate/gradle-release
@@ -25,4 +63,98 @@ release {
2563
versionPropertyFile = 'gradle.properties'
2664
//set possible properties which may contain the version
2765
versionProperties = ['version', 'mainversion']
66+
git {
67+
//branch from where to release (default: main)
68+
requireBranch.set('main')
69+
}
70+
}
71+
72+
////////////////////////////////////////////////////////////////////////////////
73+
//for javadoc task
74+
//see https://docs.gradle.org/current/dsl/org.gradle.api.tasks.javadoc.Javadoc.html
75+
////////////////////////////////////////////////////////////////////////////////
76+
javadoc {
77+
if(JavaVersion.current().isJava9Compatible()) {
78+
options.addBooleanOption('html5', true)
79+
}
80+
}
81+
82+
////////////////////////////////////////////////////////////////////////////////
83+
//for plugin io.github.gradle-nexus.publish-plugin
84+
//see https://github.com/gradle-nexus/publish-plugin
85+
////////////////////////////////////////////////////////////////////////////////
86+
nexusPublishing {
87+
repositories {
88+
sonatype()
89+
}
90+
}
91+
////////////////////////////////////////////////////////////////////////////////
92+
//for plugin maven-publish/io.github.gradle-nexus.publish-plugin
93+
//see https://docs.gradle.org/current/userguide/publishing_maven.html
94+
////////////////////////////////////////////////////////////////////////////////
95+
publishing {
96+
publications {
97+
//define publication identity, e.g. maven, which will be used
98+
//by the signing plugin, e.g. sign publishing.publications.maven
99+
mavenJava(MavenPublication) {
100+
artifact selectedClassesJar
101+
artifact sourcesJar
102+
artifact javadocJar
103+
104+
groupId = "edu.kit.datamanager"
105+
artifactId = "mapping-plugin-core"
106+
version = project.version
107+
108+
pom {
109+
name = project['name']
110+
description = project['description']
111+
url = 'http://datamanager.kit.edu'
112+
licenses {
113+
license {
114+
name = 'The Apache License, Version 2.0'
115+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
116+
}
117+
}
118+
developers {
119+
developer {
120+
id = 'Jejkal'
121+
name = 'Thomas Jejkal'
122+
email = 'webmaster@datamanager.kit.edu'
123+
}
124+
}
125+
scm {
126+
connection = 'scm:git:github.com/kit-data-manager/service-base'
127+
developerConnection = 'scm:git:github.com/kit-data-manager/service-base'
128+
url = 'https://github.com/kit-data-manager/service-base'
129+
}
130+
}
131+
}
132+
}
133+
}
134+
////////////////////////////////////////////////////////////////////////////////
135+
//for plugin signing
136+
//see https://docs.gradle.org/current/userguide/signing_plugin.html
137+
////////////////////////////////////////////////////////////////////////////////
138+
signing {
139+
//make signing required unless for SNAPSHOT releases or if signing is explicitly skipped
140+
required { !project.version.endsWith("-SNAPSHOT") && !project.hasProperty("skipSigning") }
141+
142+
//look for property 'signingKey'
143+
if (project.findProperty("signingKey")) {
144+
//If required, read a sub-key specified by its ID in property signingKeyId
145+
//def signingKeyId = findProperty("signingKeyId")
146+
//read property 'signingKey'
147+
def signingKey = findProperty("signingKey")
148+
//read property 'signingPassword'
149+
def signingPassword = findProperty("signingPassword")
150+
//Select to use in-memory ascii-armored keys
151+
useInMemoryPgpKeys(signingKey, signingPassword)
152+
//Only if also using signingKeyId
153+
//useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
154+
155+
//Apply signing to publication identity 'publishing.publications.maven'
156+
sign publishing.publications.maven
157+
}else {
158+
println 'WARNING: No property \'signingKey\' found. Artifact signing will be skipped.'
159+
}
28160
}

src/main/java/edu/kit/datamanager/mappingservice/impl/JobManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public CompletableFuture<? extends JobStatus> getJob(String jobId) {
6262
* Remove the job with the provided id. Keep in mind, that removing the job
6363
* from the JobManager won't remove job outputs.
6464
*
65-
* @param The job's id.
65+
* @param jobId The job's id.
6666
*/
6767
public void removeJob(String jobId) {
6868
mapOfJobs.remove(jobId);

src/main/java/edu/kit/datamanager/mappingservice/util/ShellRunnerUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
import org.slf4j.LoggerFactory;
2323

2424
import java.io.*;
25-
import java.util.List;
2625
import java.util.Scanner;
2726
import java.util.concurrent.*;
28-
import java.util.stream.Collectors;
2927

3028
/**
3129
* Utility class for running shell scripts.

src/test/java/edu/kit/datamanager/mappingservice/python/util/PythonUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void testRun_3args_withNoOutputStreams() {
125125
PythonRunnerUtil.runPythonScript(scriptLocation, null, null, arguments);
126126
fail("Expected MappingPluginException");
127127
} catch (MappingPluginException e) {
128-
assertEquals(MappingPluginState.StateEnum.UNKNOWN_ERROR, e.getMappingPluginState().getState());
128+
assertEquals(MappingPluginState.StateEnum.INVALID_INPUT, e.getMappingPluginState().getState());
129129
}
130130
}
131131
}

0 commit comments

Comments
 (0)