Skip to content

Commit 85b7d65

Browse files
authored
Merge pull request #16 from rgozim/master
Using buildsrc and javapackager
2 parents fb49a41 + cb0ff46 commit 85b7d65

File tree

14 files changed

+513
-99
lines changed

14 files changed

+513
-99
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
*.class
33

44
# generated files
5-
/build/
6-
/bin/
7-
/tmp/
8-
/out/
5+
build
6+
bin
7+
tmp
8+
out
99

1010
# Gradle cache
1111
.gradle

build.gradle

Lines changed: 17 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,52 @@
11
plugins {
22
id "java"
3-
id "application"
4-
id "org.openmicroscopy.project" version "5.5.0-m5"
3+
id "org.openmicroscopy.insight"
4+
id "org.openmicroscopy.distribute"
5+
id "org.openmicroscopy.publish"
6+
id "org.openmicroscopy.additional-repositories" version "5.5.0-m5"
57
}
68

79
group = "org.openmicroscopy"
810
version = "5.5.0-SNAPSHOT"
9-
targetCompatibility = JavaVersion.VERSION_1_8
10-
sourceCompatibility = JavaVersion.VERSION_1_8
1111

1212
repositories {
1313
mavenLocal()
1414
jcenter()
1515
}
1616

17+
java {
18+
sourceCompatibility = JavaVersion.VERSION_1_8
19+
targetCompatibility = JavaVersion.VERSION_1_8
20+
}
21+
1722
dependencies {
1823
testImplementation("junit:junit:4.12")
1924

25+
if (JavaVersion.current().isJava9Compatible()) {
26+
implementation('com.sun.activation:javax.activation:1.2.0')
27+
}
2028
implementation("com.mortennobel:java-image-scaling:0.8.6")
2129
implementation("com.google.code.gson:gson:2.8.5")
2230
implementation("com.zeroc:glacier2:3.6.4")
2331
implementation("info.clearthought:table-layout:4.3.0")
2432
implementation("insight:JHotDraw:7.0.9")
2533
implementation("net.imagej:ij:1.48s")
26-
implementation("net.java.dev.jna:jna-platform:5.2.0")
34+
implementation("net.java.dev.jna:jna-platform:5.3.0")
2735
implementation("org.apache.poi:poi:4.0.1")
2836
implementation("org.apache.commons:commons-collections4:4.3")
2937
implementation("org.apache.httpcomponents:httpmime:4.5.7")
3038
implementation("org.apache.httpcomponents:httpclient:4.5.7")
3139
implementation("org.apache.httpcomponents:httpcomponents-client:4.5.7")
3240
implementation("org.jfree:jfreechart:1.0.19")
33-
implementation("org.openmicroscopy:omero-blitz:5.5.0-m5")
3441
implementation("org.swinglabs:swingx:1.6.1")
35-
if (JavaVersion.current().isJava9Compatible()) {
36-
implementation("javax.activation:activation:1.1.1")
37-
}
38-
}
39-
40-
application {
41-
mainClassName = "org.openmicroscopy.shoola.Main"
42-
applicationDefaultJvmArgs = ["-Xms256m", "-Xmx1024m"]
43-
}
44-
45-
run {
46-
args = ["container.xml", "${project.buildDir}"]
47-
}
48-
49-
// Run the importer task
50-
task runImporter(dependsOn: 'classes', type: JavaExec) {
51-
classpath = sourceSets.main.runtimeClasspath
52-
main = "org.openmicroscopy.shoola.Main"
53-
args = ["containerImporter.xml", "${project.buildDir}"]
54-
applicationDefaultJvmArgs = ["-Xms256m", "-Xmx1024m"]
55-
}
56-
57-
// Create the jar for imageJ plugin
58-
task omeroijJar(dependsOn: 'classes', type: Jar) {
59-
archiveBaseName = "omero_ij"
60-
from sourceSets.main.output
61-
manifest = project.manifest {
62-
attributes("Main-Class": "org.openmicroscopy.shoola.MainIJPlugin")
63-
from(jar.manifest) {
64-
eachEntry { details ->
65-
if (details.baseValue != details.mergeValue && details.baseValue != null) {
66-
details.value = baseValue
67-
} else {
68-
details.value = details.mergeValue
69-
}
70-
}
71-
}
72-
}
73-
74-
}
75-
76-
77-
// Set the mainclass in the manifest
78-
jar {
79-
manifest {
80-
attributes("Main-Class": application.mainClassName)
81-
}
82-
}
83-
84-
85-
artifacts {
86-
archives omeroijJar
87-
}
88-
89-
distributions {
90-
91-
main {
92-
contents {
93-
from("src/config") {
94-
into "config"
95-
}
96-
}
97-
}
98-
// prepare imagej.zip
99-
imagej {
100-
contents {
101-
from("src/config") {
102-
into "config"
103-
}
104-
from omeroijJar
105-
into('lib') {
106-
from configurations.compileClasspath
107-
}
108-
}
10942

43+
implementation("org.openmicroscopy:omero-blitz:5.5.0-m5") {
44+
// Conflicts with `net.java.dev.jna`
45+
exclude group: "com.sun.jna", module: "jna"
46+
exclude group: "org.springframework"
11047
}
11148
}
11249

113-
tasks.withType(Tar) {
114-
enabled = false
115-
}
116-
117-
// N.B. processConfig may not be fully required if you just set the second
118-
// run task arg as ${project.projectDir}/src/config
119-
task processConfig(type: Copy) {
120-
from "src/config"
121-
into "${project.buildDir}/config"
122-
}
123-
124-
classes.dependsOn processConfig
125-
12650
test {
12751
testLogging.showStandardStreams = true
12852
systemProperties = System.getProperties()

buildSrc/build.gradle

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
plugins {
2+
id "groovy"
3+
id "java-gradle-plugin"
4+
}
5+
6+
repositories {
7+
mavenLocal()
8+
jcenter()
9+
maven { url 'https://artifacts.openmicroscopy.org/artifactory/maven/' }
10+
}
11+
12+
dependencies {
13+
implementation "org.openmicroscopy:omero-javapackager-plugin:5.5.0-m1"
14+
}
15+
16+
gradlePlugin {
17+
plugins {
18+
insight {
19+
id = "org.openmicroscopy.insight"
20+
implementationClass = "org.openmicroscopy.InsightPlugin"
21+
}
22+
distribute {
23+
id = "org.openmicroscopy.distribute"
24+
implementationClass = "org.openmicroscopy.DistributePlugin"
25+
}
26+
publish {
27+
id = "org.openmicroscopy.publish"
28+
implementationClass = "org.openmicroscopy.PublishPlugin"
29+
}
30+
}
31+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* -----------------------------------------------------------------------------
3+
* Copyright (C) 2019 University of Dundee & Open Microscopy Environment.
4+
* All rights reserved.
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along
16+
* with this program; if not, write to the Free Software Foundation, Inc.,
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* ------------------------------------------------------------------------------
20+
*/
21+
package org.openmicroscopy
22+
23+
import org.gradle.api.Plugin
24+
import org.gradle.api.Project
25+
import org.gradle.api.distribution.Distribution
26+
import org.gradle.api.distribution.DistributionContainer
27+
import org.gradle.api.distribution.plugins.DistributionPlugin
28+
import org.gradle.api.file.CopySpec
29+
import org.gradle.api.tasks.bundling.Tar
30+
31+
class DistributePlugin implements Plugin<Project> {
32+
33+
public static final String DISTRIBUTION_NAME_INSIGHT = "OMERO.insight"
34+
35+
public static final String DISTRIBUTION_NAME_IMAGEJ = "OMERO.imagej"
36+
37+
public static final String DISTRIBUTION_IMAGEJ = "imagej"
38+
39+
private Project project
40+
41+
@Override
42+
void apply(Project project) {
43+
this.project = project
44+
project.pluginManager.apply(DistributePlugin)
45+
project.pluginManager.apply(InsightBasePlugin)
46+
47+
DistributionContainer distributionContainer =
48+
project.extensions.getByName("distributions") as DistributionContainer
49+
50+
// Copy files from src/config to install/<name>/config
51+
CopySpec configSpec = project.copySpec { CopySpec s ->
52+
s.from("src/config")
53+
s.into("config")
54+
}
55+
56+
configureMainDistribution(distributionContainer, configSpec)
57+
createImageJPluginDistribution(distributionContainer, configSpec)
58+
59+
// Skip tar tasks
60+
project.tasks.withType(Tar).configureEach {
61+
it.setEnabled(false)
62+
}
63+
}
64+
65+
private void configureMainDistribution(DistributionContainer distributionContainer, CopySpec configSpec) {
66+
// Configure "main" distribution to create OMERO.insight
67+
Distribution main = distributionContainer.getByName(DistributionPlugin.MAIN_DISTRIBUTION_NAME)
68+
main.baseName = DISTRIBUTION_NAME_INSIGHT
69+
main.contents.with(configSpec)
70+
}
71+
72+
private void createImageJPluginDistribution(DistributionContainer distributionContainer, CopySpec configSpec) {
73+
// Create and configure imageJ distribution
74+
distributionContainer.create(DISTRIBUTION_IMAGEJ) { Distribution imageJ ->
75+
imageJ.baseName = DISTRIBUTION_NAME_IMAGEJ
76+
imageJ.contents.with(configSpec)
77+
78+
CopySpec libChildSpec = project.copySpec()
79+
libChildSpec.into("lib")
80+
libChildSpec.from(project.tasks.named(InsightBasePlugin.TASK_OMERO_IMAGEJ_JAR))
81+
libChildSpec.from(Utils.getRuntimeClasspathConfiguration(project))
82+
83+
CopySpec childSpec = project.copySpec()
84+
childSpec.with(libChildSpec)
85+
86+
imageJ.contents.with(childSpec)
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)