Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jts-dev] How to create a script to run a fat jar in JTS?

+1 for moving to jts-dev - and done!

Yes, the current fat jars include the manifest magic to let them run just using this:

java -jar jts-tests-1.15.0-SNAPSHOT.jar

So i encourage you to use the fat jars which are now generated by JTS!

But I want to make it even easier, by hiding the scary Java cmd in a shell script. 

I just experimented with the finalName option to the Maven assembly plugin [1], and it allows overriding the default name and removing the version number.  So I think I'll go with that for now, pending a better solution.  (Note that I think this is really a shell script issue, not a Maven issue - there should be some way to provide a filename by wildcard match.  Probably is in *nix, but maybe not Windows...)

[1] https://maven.apache.org/plugin-developers/cookbook/generate-assembly.html

On Mon, Aug 7, 2017 at 10:57 AM, Jody Garnett <jody.garnett@xxxxxxxxx> wrote:
Not sure, I have my own test runner jar I made by hand for use in training courses. Would gladly use an official one.
Oh wait, if you fill in the jar manifest correctly it should just run ... no need for a bat file.

I used MANIFEST.MF:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.4
Created-By: 1.7.0_45-b18 (Oracle Corporation)
Main-Class: com.vividsolutions.jtstest.testbuilder.JTSTestBuilder

But that did not use multiple jars, I found the following online which may help https://stackoverflow.com/questions/10929438/create-jar-with-custom-manifest-with-multiple-libraries-in-classpath

Aside - we can have these discussion on jts-dev :)

--
Jody Garnett

On 7 August 2017 at 10:50, Martin Davis <mtnclimb@xxxxxxxxx> wrote:
Maven dudes...  as you may know Jim did some great work creating Maven entries to create a fat jar for the JTS Test Bulder.  I've recently added the same for the JTS Test Runner [1].

I'd like to create shell scripts which run these jars, to make it super-easy for users.  I did this in the branch in testrunner.bar here: [2].

However, the script has the flaw that it has to reference the version-numbered JAR file, which means it would have to be updated in every release.  I really don't want to have to do that.  

So any ideas about how to make the script version-independent?  Options that come to mind are:

- remove the version number from the fat JAR.  I'd rather have the version number there, but am willing to sacrifice this for ease of maintenance

- somehow determine the current version number/filename automatically in the script.  This is probably more feasible to do in the Unix script than the WinBat script, unfortunately.

Any other ideas?




Back to the top