Skip to content

Commit 0fad77e

Browse files
committed
Add uber jar support.
1 parent d4bfe7a commit 0fad77e

3 files changed

Lines changed: 98 additions & 8 deletions

File tree

pom.xml

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,16 @@
290290
<artifactId>groovy-swing</artifactId>
291291
<version>${groovy.version}</version>
292292
</dependency>
293+
<dependency>
294+
<groupId>org.codehaus.groovy</groupId>
295+
<artifactId>groovy-groovysh</artifactId>
296+
<version>${groovy.version}</version>
297+
</dependency>
298+
<dependency>
299+
<groupId>org.codehaus.groovy</groupId>
300+
<artifactId>groovy-console</artifactId>
301+
<version>${groovy.version}</version>
302+
</dependency>
293303
<dependency>
294304
<groupId>com.opencsv</groupId>
295305
<artifactId>opencsv</artifactId>
@@ -357,7 +367,7 @@
357367
</plugin>
358368
<plugin>
359369
<artifactId>maven-compiler-plugin</artifactId>
360-
<version>3.8.0</version>
370+
<version>3.8.1</version>
361371
<configuration>
362372
<source>1.8</source>
363373
<target>1.8</target>
@@ -379,7 +389,7 @@
379389
<plugin>
380390
<groupId>org.apache.maven.plugins</groupId>
381391
<artifactId>maven-surefire-plugin</artifactId>
382-
<version>2.22.0</version>
392+
<version>3.0.0-M5</version>
383393
<configuration>
384394
<forkMode>once</forkMode>
385395
<argLine>-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=1024m</argLine>
@@ -390,20 +400,20 @@
390400
</plugin>
391401
<plugin>
392402
<artifactId>maven-antrun-plugin</artifactId>
393-
<version>1.3</version>
403+
<version>3.0.0</version>
394404
<executions>
395405
<execution>
396406
<phase>package</phase>
397407
<configuration>
398-
<tasks>
408+
<target>
399409
<taskdef name="Groovydoc" classname="org.codehaus.groovy.ant.Groovydoc">
400410
<classpath>
401411
<path refid="maven.compile.classpath"/>
402412
</classpath>
403413
</taskdef>
404414
<Groovydoc destdir="target/groovydoc" sourcepath="src/main/groovy" packagenames="**.*"
405415
use="true" windowtitle="GeoScript Groovy API" private="false"/>
406-
</tasks>
416+
</target>
407417
</configuration>
408418
<goals>
409419
<goal>run</goal>
@@ -426,7 +436,7 @@
426436
<plugin>
427437
<groupId>org.apache.maven.plugins</groupId>
428438
<artifactId>maven-jar-plugin</artifactId>
429-
<version>3.1.0</version>
439+
<version>3.2.0</version>
430440
<configuration>
431441
<archive>
432442
<manifest>
@@ -437,7 +447,7 @@
437447
</plugin>
438448
<plugin>
439449
<artifactId>maven-assembly-plugin</artifactId>
440-
<version>2.2-beta-5</version>
450+
<version>3.3.0</version>
441451
<configuration>
442452
<descriptors>
443453
<descriptor>src/assembly/dir.xml</descriptor>
@@ -454,6 +464,56 @@
454464
</execution>
455465
</executions>
456466
</plugin>
467+
<plugin>
468+
<groupId>org.apache.maven.plugins</groupId>
469+
<artifactId>maven-shade-plugin</artifactId>
470+
<version>3.2.4</version>
471+
<executions>
472+
<execution>
473+
<phase>package</phase>
474+
<goals>
475+
<goal>shade</goal>
476+
</goals>
477+
<configuration>
478+
<finalName>geoscript-app-${project.version}</finalName>
479+
<transformers>
480+
<transformer implementation="org.apache.maven.plugins.shade.resource.GroovyResourceTransformer">
481+
<extModuleName>groovy-module</extModuleName>
482+
<extModuleVersion>1.0.0</extModuleVersion>
483+
</transformer>
484+
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
485+
<resource>META-INF/spring.handlers</resource>
486+
</transformer>
487+
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
488+
<resource>META-INF/spring.schemas</resource>
489+
</transformer>
490+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
491+
<mainClass>geoscript.Application</mainClass>
492+
<manifestEntries>
493+
<Specification-Title>Java Advanced Imaging Image I/O Tools</Specification-Title>
494+
<Specification-Version>1.1</Specification-Version>
495+
<Specification-Vendor>Sun Microsystems, Inc.</Specification-Vendor>
496+
<Implementation-Title>com.sun.media.imageio</Implementation-Title>
497+
<Implementation-Version>1.1</Implementation-Version>
498+
<Implementation-Vendor>Sun Microsystems, Inc.</Implementation-Vendor>
499+
</manifestEntries>
500+
</transformer>
501+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
502+
</transformers>
503+
<filters>
504+
<filter>
505+
<artifact>*:*</artifact>
506+
<excludes>
507+
<exclude>META-INF/*.SF</exclude>
508+
<exclude>META-INF/*.DSA</exclude>
509+
<exclude>META-INF/*.RSA</exclude>
510+
</excludes>
511+
</filter>
512+
</filters>
513+
</configuration>
514+
</execution>
515+
</executions>
516+
</plugin>
457517
<!-- Code quality: mvn codenarc:codenarc -->
458518
<plugin>
459519
<groupId>org.codehaus.mojo</groupId>

src/assembly/dir.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<scope>runtime</scope>
1616
<useProjectArtifact>true</useProjectArtifact>
1717
<excludes>
18-
<exclude>org.codehaus.groovy:groovy-all</exclude>
18+
<exclude>org.codehaus.groovy:*</exclude>
1919
<exclude>xml-apis:xml-apis</exclude>
2020
<exclude>javax.media:jai_*</exclude>
2121
</excludes>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package geoscript
2+
3+
import groovy.ui.GroovyMain as Script
4+
import groovy.ui.Console
5+
import org.codehaus.groovy.tools.shell.Main as Shell
6+
7+
class Application {
8+
9+
static void main(String[] args) {
10+
if (args.length < 1) {
11+
println "Please provide a command (script, shell, or console)"
12+
return
13+
}
14+
String command = args[0]
15+
String[] argsWithoutCommand = (args as List).subList(1, args.length)
16+
if (command.equalsIgnoreCase("script")) {
17+
Script.main(argsWithoutCommand)
18+
}
19+
else if (command.equalsIgnoreCase("shell")) {
20+
Shell.main(argsWithoutCommand)
21+
}
22+
else if (command.equalsIgnoreCase("console")) {
23+
Console.main(argsWithoutCommand)
24+
}
25+
else {
26+
println "Unknown command '${command}'"
27+
}
28+
}
29+
30+
}

0 commit comments

Comments
 (0)