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
by 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.
-
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
by jendave » 10 Aug 2011, 19:16
There are no new direct deps. The new version of Substance has a transitive dep on android.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.
Re: Maven build file - generation of OSX, Windows, Linux fil
by Braids » 10 Aug 2011, 20:50
it's going into Forge.model.FModel real soon now, available via Singletons.getModel().someMethodNameIHaveNotDecidedYetProbablyMoreThanOne()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.
"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. 

-
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
by Braids » 10 Aug 2011, 23:16
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: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. . .
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:jendave wrote:The manifest file now includes . . .
Implementation-Version: 1.1.2-SNAPSHOT
. . .
Implementation-Build: 9734 <----- SVN Rev
- 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:
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"));
ok, but then i need a path to a jar file.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
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. 

-
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
by silly freak » 11 Aug 2011, 06:35
If you mean to grab the manifest from inside the jar, try
Edit:
- Code: Select all
ClassLoader.getSystemResourceAsStream("META-INF/MANIFEST.MF");
Edit:
there is, usingBraids 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?
- 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!
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
by jendave » 11 Aug 2011, 14:40
Yes. This is a good use case for a mock.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.
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.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:do i need to run a different maven build command?
- Code: Select all
...
Main-Class: forge.Gui_NewGame
Implementation-Build:
Re: Maven build file - generation of OSX, Windows, Linux fil
by Braids » 12 Aug 2011, 15:02
i now have the build number in the manifest file. there are two potential causes for my prior problem.jendave wrote: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.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:
...
- 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. 

-
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
by Braids » 12 Aug 2011, 15:25
as of r9761, to access these values, you can make the following calls:Braids wrote:it's going into Forge.model.FModel real soon now . . .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.
- 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

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

"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. 

-
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
by 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
by Braids » 13 Aug 2011, 02:02
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.friarsol wrote:If it finds more than one, can it just grab from the most recent version?
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. 

-
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
by 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
The new version works on Snow Leopard.
Thanks
Dave
- Code: Select all
mvn -U clean install -P windows-linux
The new version works on Snow Leopard.
Thanks
Dave
Re: Maven build file - generation of OSX, Windows, Linux fil
by 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 testThat should create a Windows executable. Let me know if it works on OSX Lion.
- Code: Select all
mvn -U clean install -P windows-linux
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.
-
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
by Chris H. » 20 Aug 2011, 11:52
It looks like the AdiumApplescriptRunner app has the same PPC error under Lion.
`
`
-
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
by jendave » 21 Aug 2011, 05:17
Please update from SVN and re-run theChris H. wrote:It looks like the AdiumApplescriptRunner app has the same PPC error under Lion.
`
- Code: Select all
mvn clean install -P windows-linux,osx
Re: Maven build file - generation of OSX, Windows, Linux fil
by 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.
-
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
Who is online
Users browsing this forum: No registered users and 36 guests