Skip to content

Commit e36f7fa

Browse files
committed
Changing maven package for protein-comparison-tool to shade
Rather than copy all the jars individually using the maven assembly plugin, we use the shade plugin to combine them all into a single jar file, then assemble that. Since all our dependencies are lgpl-compatible, this should be OK. This fixes biojava#197. I've also included improvements to the run scripts which let you run them from any directory, not just the current one. Maven handles replacing the jar filename at assembly time. Finally, I changed the name of the assembly. They are now named like 'protein-comparison-tool-4.0.0.jar' rather than including a timestamp.
1 parent d7428a4 commit e36f7fa

File tree

6 files changed

+127
-52
lines changed

6 files changed

+127
-52
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@
222222
</configuration>
223223

224224
</plugin>
225+
<plugin>
226+
<groupId>org.apache.maven.plugins</groupId>
227+
<artifactId>maven-shade-plugin</artifactId>
228+
<version>2.3</version>
229+
</plugin>
225230
<plugin>
226231
<artifactId>maven-assembly-plugin</artifactId>
227232
<version>2.4</version>

protein-comparison-tool/pom.xml

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,70 @@
7474

7575
<build>
7676
<plugins>
77+
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-shade-plugin</artifactId>
81+
<executions>
82+
<execution>
83+
<phase>package</phase>
84+
<goals>
85+
<goal>shade</goal>
86+
</goals>
87+
<configuration>
88+
<!-- Minimizing removes jmol and log4j -->
89+
<minimizeJar>false</minimizeJar>
90+
<artifactSet>
91+
<excludes>
92+
<exclude>junit:junit</exclude>
93+
</excludes>
94+
</artifactSet>
95+
<filters>
96+
<filter>
97+
<artifact>net.sourceforge.jmol:jmol</artifact>
98+
<excludes>
99+
<exclude>javax/vecmath/**</exclude>
100+
</excludes>
101+
</filter>
102+
<filter>
103+
<artifact>org.biojava:biojava3-structure</artifact>
104+
<excludes>
105+
<exclude>demo/DemoFATCAT*</exclude>
106+
<exclude>demo/DemoCE*</exclude>
107+
</excludes>
108+
</filter>
109+
<filter>
110+
<!-- Exclude signature files -->
111+
<artifact>*:*</artifact>
112+
<excludes>
113+
<exclude>META-INF/*.SF</exclude>
114+
<exclude>META-INF/*.DSA</exclude>
115+
<exclude>META-INF/*.RSA</exclude>
116+
</excludes>
117+
</filter>
118+
</filters>
119+
<transformers>
120+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
121+
<manifestEntries>
122+
<Specification-Vendor>Open Bioinformatics Foundation</Specification-Vendor>
123+
<Implementation-Vendor>Open Bioinformatics Foundation</Implementation-Vendor>
124+
<Specification-Version>${project.version}</Specification-Version>
125+
<Implementation-Version>${project.version}</Implementation-Version>
126+
<Specification-Title>${project.name}</Specification-Title>
127+
<Implementation-Title>${project.name}</Implementation-Title>
128+
<Main-Class>org.biojava.bio.structure.align.gui.AlignmentGui</Main-Class>
129+
</manifestEntries>
130+
</transformer>
131+
<!-- This bit merges the various META-INF/services files -->
132+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
133+
</transformers>
134+
</configuration>
135+
</execution>
136+
</executions>
137+
</plugin>
138+
77139
<plugin>
140+
<groupId>org.apache.maven.plugins</groupId>
78141
<artifactId>maven-assembly-plugin</artifactId>
79142
<configuration>
80143
<descriptors>
@@ -91,14 +154,15 @@
91154
<goal>single</goal>
92155
</goals>
93156
<configuration>
94-
<finalName>${project.name}_${timestamp}</finalName>
157+
<finalName>${project.artifactId}-${project.version}</finalName>
95158
<appendAssemblyId>false</appendAssemblyId>
96159
</configuration>
97160
</execution>
98161
</executions>
99162

100163
</plugin>
101-
</plugins>
164+
165+
</plugins>
102166
</build>
103167

104168
</project>

protein-comparison-tool/src/main/assembly/assembly.xml

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,45 @@
77
<format>tar.gz</format>
88
</formats>
99

10-
<!-- <moduleSets>
11-
12-
<moduleSet>
13-
<useAllReactorProjects>true</useAllReactorProjects>
14-
<includes>
15-
<include>${groupId}:biojava3-core</include>
16-
<include>${groupId}:biojava3-alignment</include>
17-
<include>${groupId}:biojava3-structure</include>
18-
<include>${groupId}:biojava3-structure-gui</include>
19-
</includes>
20-
<binaries>
21-
<outputDirectory>modules/${artifactId}</outputDirectory>
22-
<outputDirectory>./modules/</outputDirectory>
23-
<unpack>false</unpack>
24-
<includeDependencies>true</includeDependencies>
25-
<dependencySets>
26-
<dependencySet>
27-
<unpack>false</unpack>
28-
<scope>compile</scope>
29-
30-
</dependencySet>
31-
</dependencySets>
32-
</binaries>
33-
34-
</moduleSet>
35-
</moduleSets> -->
3610
<fileSets>
3711
<fileSet>
3812
<directory>${project.basedir}/src/main/assembly/</directory>
3913
<outputDirectory>.</outputDirectory>
4014
<includes>
41-
<include>*.sh</include>
4215
<include>db.out</include>
4316
<include>example.lst</include>
4417
<include>LICENSE</include>
4518
</includes>
4619
</fileSet>
20+
<fileSet>
21+
<directory>${project.build.directory}</directory>
22+
<outputDirectory>.</outputDirectory>
23+
<includes>
24+
<include>${project.build.finalName}.jar</include>
25+
</includes>
26+
</fileSet>
27+
4728
</fileSets>
48-
<dependencySets>
49-
<dependencySet>
50-
<outputDirectory>jars</outputDirectory>
51-
<includes>
52-
<include>${groupId}:biojava3-core</include>
53-
<include>${groupId}:biojava3-alignment</include>
54-
<include>${groupId}:biojava3-structure</include>
55-
<include>${groupId}:biojava3-structure-gui</include>
56-
<include>net.sourceforge.jmol:jmol</include>
57-
<include>javaws:javaws</include>
58-
</includes>
59-
</dependencySet>
60-
</dependencySets>
61-
29+
<!-- Shell scripts must be filtered for the correct jar name -->
30+
<files>
31+
<file>
32+
<source>src/main/assembly/runCE.sh</source>
33+
<outputDirectory>/</outputDirectory>
34+
<filtered>true</filtered>
35+
<fileMode>0755</fileMode>
36+
</file>
37+
<file>
38+
<source>src/main/assembly/runFATCAT.sh</source>
39+
<outputDirectory>/</outputDirectory>
40+
<filtered>true</filtered>
41+
<fileMode>0755</fileMode>
42+
</file>
43+
<file>
44+
<source>src/main/assembly/startFarmJob.sh</source>
45+
<outputDirectory>/</outputDirectory>
46+
<filtered>true</filtered>
47+
<fileMode>0755</fileMode>
48+
</file>
49+
</files>
50+
6251
</assembly>

protein-comparison-tool/src/main/assembly/runCE.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@
3333
# bash runCE.sh -pdbFilePath /tmp/ -showDBresult db.out
3434

3535

36+
### Execute jar ###
37+
38+
# Get the base directory of the argument.
39+
# Can resolve single symlinks if readlink is installed
40+
function scriptdir {
41+
cd "$(dirname "$1")"
42+
cd "$(dirname "$(readlink "$1" 2>/dev/null || basename "$1" )")"
43+
pwd
44+
}
45+
DIR="$(scriptdir "$0" )"
3646
# send the arguments to the java app
37-
# allows to specify a different config file
38-
args="$*"
39-
40-
java -Xmx500M -cp "$PWD/jars/*" org.biojava.bio.structure.align.ce.CeMain $args
47+
java -Xmx500M -cp "$DIR/${project.build.finalName}.jar" org.biojava.bio.structure.align.ce.CeMain "$@"

protein-comparison-tool/src/main/assembly/runFATCAT.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@
1212
# for more examples see runCE.sh
1313
# jCE works almost exactly the same...
1414

15-
# send the arguments to the java app
16-
args="$*"
1715

18-
java -Xmx500M -cp "$PWD/jars/*" org.biojava.bio.structure.align.fatcat.FatCat $args
16+
### Execute jar ###
17+
18+
19+
# Get the base directory of the argument.
20+
# Can resolve single symlinks if readlink is installed
21+
function scriptdir {
22+
cd "$(dirname "$1")"
23+
cd "$(dirname "$(readlink "$1" 2>/dev/null || basename "$1" )")"
24+
pwd
25+
}
26+
DIR="$(scriptdir "$0" )"
27+
# send the arguments to the java app
28+
java -Xmx500M -cp "$DIR/${project.build.finalName}.jar" org.biojava.bio.structure.align.fatcat.FatCat "$@"

protein-comparison-tool/src/main/assembly/startFarmJob.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ else
1515
else
1616
which java
1717
java -version
18-
java -Xmx1G -cp "$PWD/jars/*" org.biojava.bio.structure.align.FarmJob $args
18+
java -Xmx1G -cp "./${project.build.finalName}.jar" org.biojava.bio.structure.align.FarmJob $args
1919
fi
2020
fi
2121

22-
exit $?
22+
exit $?

0 commit comments

Comments
 (0)