Skip to content

Commit b902e69

Browse files
flaixfzs
authored andcommitted
For Java 9+ define the classpath instead of using a Launcher.
The (moxie and other) Launcher do not work with Java 9 and later anymore. It used to dynamically extend the classpath, misusing an internal interface of the `URLClassLoader`. This is no longer possible since Java 9, which closed that path and does not offer any way to dynamically extend the classpath during runtime. So the choice is between providing one large Jar with everything in it, providing a Jar that has the Jars in `ext` listed explicitly in its manifest, and specifying the classpath on the command line where the `ext` directory can be added and all contained jar files will be put on the classpath. The motivation for the Launcher class was to be able to simply drop new jar files into a directory and they will be picked up at the application start, without having to specify a classpath. We opt for solution three here. This way jar files can still be dropped into the ext directory, albeit the directory needs to be added to the classpath on the command line. Unfortunately using a wildcard is not possible in the manifest file. We change the calls in the script files accordingly. This seems like a good compromise, since no one will run the application manually typing the whole commandline anyway. This also does away with the splash screen, by the way. Again, doesn't seem like a big loss, as I don't think it was ever shown for the Authority. Personally, I am not convinced that it is the best way, because I don't really think that the use case of dropping whatever jar files into the `ext` directory is a valid one that happened a lot. This does not yet fix the client programs, which still use a Launcher. Maybe for them a all-in-one Jar is a better solution. Fixes #1262 Fixes #1294
1 parent 1140536 commit b902e69

14 files changed

+24
-335
lines changed

build.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@
205205
<!-- Build jar -->
206206
<mx:jar destfile="${go.release.dir}/gitblit.jar" includeresources="true">
207207
<mainclass name="com.gitblit.GitBlitServer" />
208-
<launcher paths="ext" />
209208
</mx:jar>
210209

211210
<!-- Generate the docs for the GO build -->

src/main/distrib/linux/authority.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
java -cp gitblit.jar com.gitblit.authority.Launcher --baseFolder data
2+
java -cp gitblit.jar:ext/* com.gitblit.authority.GitblitAuthority --baseFolder data
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
java -jar gitblit.jar --baseFolder data --stop
2+
java -cp "gitblit.jar:ext/*" com.gitblit.GitBlitServer --baseFolder data --stop

src/main/distrib/linux/gitblit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
java -jar gitblit.jar --baseFolder data
2+
java -cp "gitblit.jar:ext/*" com.gitblit.GitBlitServer --baseFolder data

src/main/distrib/win/authority.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@java -cp gitblit.jar com.gitblit.authority.Launcher --baseFolder data %*
1+
@java -cp gitblit.jar;"%CD%\ext\*" com.gitblit.authority.GitblitAuthority --baseFolder data %*

src/main/distrib/win/gitblit-stop.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@java -jar gitblit.jar --stop --baseFolder data %*
1+
@java -cp gitblit.jar;"%CD%\ext\*" com.gitblit.GitBlitServer --stop --baseFolder data %*

src/main/distrib/win/gitblit.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@java -jar gitblit.jar --baseFolder data %*
1+
@java -cp gitblit.jar;"%CD%\ext\*" com.gitblit.GitBlitServer --baseFolder data %*

src/main/distrib/win/installService.cmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ SET ARCH=amd64
2323
--StdOutput=auto ^
2424
--StdError=auto ^
2525
--StartPath="%CD%" ^
26-
--StartClass=org.moxie.MxLauncher ^
26+
--StartClass=com.gitblit.GitBlitServer ^
2727
--StartMethod=main ^
2828
--StartParams="--storePassword;gitblit;--baseFolder;%CD%\data" ^
2929
--StartMode=jvm ^
3030
--StopPath="%CD%" ^
31-
--StopClass=org.moxie.MxLauncher ^
31+
--StopClass=com.gitblit.GitBlitServer ^
3232
--StopMethod=main ^
3333
--StopParams="--stop;--baseFolder;%CD%\data" ^
3434
--StopMode=jvm ^
35-
--Classpath="%CD%\gitblit.jar" ^
35+
--Classpath="%CD%\gitblit.jar;%CD%\ext\*" ^
3636
--Jvm=auto ^
3737
--JvmMx=1024
3838

src/main/java/com/gitblit/GitBlitServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected final void usage(CmdLineParser parser, CmdLineException t) {
143143
if (parser != null) {
144144
parser.printUsage(System.out);
145145
System.out
146-
.println("\nExample:\n java -server -Xmx1024M -jar gitblit.jar --repositoriesFolder c:\\git --httpPort 80 --httpsPort 443");
146+
.println("\nExample:\n java -server -Xmx1024M -cp gitblit.jar:ext/* com.gitblit.GitBlitServer --repositoriesFolder /srv/git --httpPort 80 --httpsPort 443");
147147
}
148148
System.exit(0);
149149
}

src/main/java/com/gitblit/Launcher.java

Lines changed: 0 additions & 148 deletions
This file was deleted.

src/main/java/com/gitblit/MigrateTickets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected final void usage(CmdLineParser parser, CmdLineException t) {
116116
if (parser != null) {
117117
parser.printUsage(System.out);
118118
System.out
119-
.println("\nExample:\n java -gitblit.jar com.gitblit.MigrateTickets com.gitblit.tickets.RedisTicketService --baseFolder c:\\gitblit-data");
119+
.println("\nExample:\n java -cp gitblit.jar;\"%CD%/ext/*\" com.gitblit.MigrateTickets com.gitblit.tickets.RedisTicketService --baseFolder c:\\gitblit-data");
120120
}
121121
System.exit(0);
122122
}

src/main/java/com/gitblit/ReindexTickets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected final void usage(CmdLineParser parser, CmdLineException t) {
111111
if (parser != null) {
112112
parser.printUsage(System.out);
113113
System.out
114-
.println("\nExample:\n java -gitblit.jar com.gitblit.ReindexTickets --baseFolder c:\\gitblit-data");
114+
.println("\nExample:\n java -cp gitblit.jar;\"%CD%/ext/*\" com.gitblit.ReindexTickets --baseFolder c:\\gitblit-data");
115115
}
116116
System.exit(0);
117117
}

src/main/java/com/gitblit/authority/Launcher.java

Lines changed: 0 additions & 166 deletions
This file was deleted.

0 commit comments

Comments
 (0)