It is currently 27 Aug 2025, 15:26
   
Text Size

Maven build file - generation of OSX, Windows, Linux files

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby Rob Cashwalker » 10 Aug 2011, 19:06

Hey why is there an android library in our maven dependency? There are a lot more dependencies listed now, compared to the last git version I had pulled.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby jendave » 10 Aug 2011, 19:16

Rob Cashwalker wrote:Hey why is there an android library in our maven dependency? There are a lot more dependencies listed now, compared to the last git version I had pulled.
There are no new direct deps. The new version of Substance has a transitive dep on android.
jendave
 
Posts: 307
Joined: 01 Jun 2008, 07:19
Has thanked: 8 times
Been thanked: 21 times

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby Braids » 10 Aug 2011, 20:50

Rob Cashwalker wrote:Yeah, the code dave provided just prints to the console as an example. a little tweaking and it becomes a callable method that can be used by any part of Forge that needs it.
it's going into Forge.model.FModel real soon now, available via Singletons.getModel().someMethodNameIHaveNotDecidedYetProbablyMoreThanOne()
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby Braids » 10 Aug 2011, 23:16

jendave wrote:Yes, there is a plugin that will grab the SVN (or GIT, Mercurial) rev number. The best place to put it would be in the manifest file. Then your Mantis code could grab it. . .
but only for binaries built with Maven. this makes unit testing the methods to fetch these values difficult. after some thought, i have decided that i'll have to make a mock jar file for unit test if it can't find the real one.

jendave wrote:The manifest file now includes . . .
Implementation-Version: 1.1.2-SNAPSHOT
. . .
Implementation-Build: 9734 <----- SVN Rev
i updated svn to r9743. i then ran the maven goal "-U -B clean install" from pom.xml in eclipse. the resulting MANIFEST.MF in target/forge-1.1.2-SNAPSHOT-jar-with-dependencies.jar does not contain the build number:
Code: Select all
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: Braids
Build-Jdk: 1.6.0_26
Implementation-Title: Forge
Implementation-Version: 1.1.2-SNAPSHOT
Implementation-Vendor-Id: forge
Implementation-Vendor: CardForge
Main-Class: forge.Gui_NewGame
Implementation-Build:

do i need to run a different maven build command?

jendave wrote:Here is some sample code to grab it
Code: Select all
String appServerHome = getServletContext().getRealPath("/");

File manifestFile = new File(appServerHome, "META-INF/MANIFEST.MF");
 
Manifest mf = new Manifest();
mf.read(new FileInputStream(manifestFile));

Attributes atts = mf.getMainAttributes();

System.out.println("Version: " + atts.getValue("Implementation-Version"));
System.out.println("Build: " + atts.getValue("Implementation-Build"));
jendave, in a PM to me wrote:This code was not meant to be run. I simply copied it from a tutorial on how to use the manifest attributes. Disregard the first line
ok, but then i need a path to a jar file.

is there some way to get the currently executing jar file from System.properties or something? would it be the first item in the classpath perhaps?

the path depends on the version. i guess i could look for forge*.jar in the application's present working directory and just use that. i hope nobody tries to put multiple forge jar versions in the same directory. yes, that would be an error condition worth testing.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby silly freak » 11 Aug 2011, 06:35

If you mean to grab the manifest from inside the jar, try

Code: Select all
ClassLoader.getSystemResourceAsStream("META-INF/MANIFEST.MF");
the code is from the top of my head, a leading slash may be missing etc. but in principle you should be able to grab everything inside the jar this way for read only access (if no security policy says otherwise...)

Edit:

Braids wrote:is there some way to get the currently executing jar file from System.properties or something? would it be the first item in the classpath perhaps?
there is, using
Code: Select all
URL url = Gui_NewGame.class.getProtectionDomain().getCodeSource().getLocation();
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby jendave » 11 Aug 2011, 14:40

Braids wrote:but only for binaries built with Maven. this makes unit testing the methods to fetch these values difficult. after some thought, i have decided that i'll have to make a mock jar file for unit test if it can't find the real one.
Yes. This is a good use case for a mock.

Braids wrote:
i updated svn to r9743. i then ran the maven goal "-U -B clean install" from pom.xml in eclipse. the resulting MANIFEST.MF in target/forge-1.1.2-SNAPSHOT-jar-with-dependencies.jar does not contain the build number:
Code: Select all
...
Main-Class: forge.Gui_NewGame
Implementation-Build:

do i need to run a different maven build command?
Not sure what happened here. I cannot recreate the issue. I added the buildnumber to the regular jar as well as the jar-with-deps just in case.
jendave
 
Posts: 307
Joined: 01 Jun 2008, 07:19
Has thanked: 8 times
Been thanked: 21 times

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby Braids » 12 Aug 2011, 15:02

jendave wrote:
Braids wrote:i updated svn to r9743. i then ran the maven goal "-U -B clean install" from pom.xml in eclipse. the resulting MANIFEST.MF in target/forge-1.1.2-SNAPSHOT-jar-with-dependencies.jar does not contain the build number:
...
Not sure what happened here. I cannot recreate the issue. I added the buildnumber to the regular jar as well as the jar-with-deps just in case.
i now have the build number in the manifest file. there are two potential causes for my prior problem.
  • i ran svn update, and there was a conflict in the .svn/tmp version of pom.xml. i accepted the server's version entirely.
  • maven complained that i wasn't using a JDK compiler, but a JRE one. i fixed the setting in preferences and it built OK.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

How to get Forge's version and build ID in r9761 and later

Postby Braids » 12 Aug 2011, 15:25

Braids wrote:
Rob Cashwalker wrote:Yeah, the code dave provided just prints to the console as an example. a little tweaking and it becomes a callable method that can be used by any part of Forge that needs it.
it's going into Forge.model.FModel real soon now . . .
as of r9761, to access these values, you can make the following calls:

Code: Select all
import forge.Singletons;
import forge.model.BuildInfo;

BuildInfo buildInfo = Singletons.getModel().getBuildInfo();

String version = buildInfo.getVersion();  // returns "SVN" if unknown
String buildID = buildInfo.getBuildID();  // returns null if unknown
these typically only work if Forge is being run from a jar file created by maven. they also work if there is a single forge-*-with-dependencies.jar in the CLASSPATH.{1} i got even more clever. if getBuildID() can't deduce the version number, it tries to invoke the OS command svnversion as a last-ditch effort. so, your buildID could end up looking like "4123", "4123:4168", "4168M", "4123S", "4123P" or even "4123:4168MS".

i wrote extensive unit tests for these because i wanted them to be robust.

{1}edit: if it finds more than one, it throws a special MultipleForgeJarsFoundError. this should never happen in real life, right?
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby friarsol » 12 Aug 2011, 23:34

If it finds more than one, can it just grab from the most recent version?
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby Braids » 13 Aug 2011, 02:02

friarsol wrote:If it finds more than one, can it just grab from the most recent version?
only if "the most recent version" is well defined. it could go by the file with the later timestamp, or the one that is last in dictionary order, i guess.

but i think it's silly to have more than one forge jar in your classpath, so it throws an error instead.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby jendave » 20 Aug 2011, 05:18

Chris - I updated the launch4j Maven plugin (I maintain a fork of it). It should work on Lion now. Can you do a test
Code: Select all
mvn -U clean install -P windows-linux
That should create a Windows executable. Let me know if it works on OSX Lion.
The new version works on Snow Leopard.

Thanks
Dave
jendave
 
Posts: 307
Joined: 01 Jun 2008, 07:19
Has thanked: 8 times
Been thanked: 21 times

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby Chris H. » 20 Aug 2011, 11:10

jendave wrote:Chris - I updated the launch4j Maven plugin (I maintain a fork of it). It should work on Lion now. Can you do a test
Code: Select all
mvn -U clean install -P windows-linux
That should create a Windows executable. Let me know if it works on OSX Lion.
The new version works on Snow Leopard.
`
I entered this as a Maven goal while choosing Run -> Run As -> Maven Build... from Lion and it worked!

Thank you. I may now be able to migrate my Nightly Builds and Bi-Weekly betas to Lion.

I had spent some time recently trying to get VirtualBox to accept a Snow Leopard guest but was having problems getting it to work. The updated launch4j should help to minimize my need for Snow Leopard.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby Chris H. » 20 Aug 2011, 11:52

It looks like the AdiumApplescriptRunner app has the same PPC error under Lion.

`
Attachments
AdiumApplescriptRunner.jpg
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby jendave » 21 Aug 2011, 05:17

Chris H. wrote:It looks like the AdiumApplescriptRunner app has the same PPC error under Lion.

`
Please update from SVN and re-run the
Code: Select all
mvn clean install -P windows-linux,osx
I checked in a change that removes the dependency on AdiumApplescriptRunner.
jendave
 
Posts: 307
Joined: 01 Jun 2008, 07:19
Has thanked: 8 times
Been thanked: 21 times

Re: Maven build file - generation of OSX, Windows, Linux fil

Postby Chris H. » 21 Aug 2011, 11:54

jendave wrote:Please update from SVN and re-run the

Code: Select all
mvn clean install -P windows-linux,osx
`
I checked in a change that removes the dependency on AdiumApplescriptRunner.
`
That works, I have both of the archives built locally.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 40 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 40 users online :: 0 registered, 0 hidden and 40 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 40 guests

Login Form