How to package a Jar for OSX? - macos

I know JarBundler is nolonger developed and doesn't work with 1.7 (link) and from the same site I found AppBundler which does produce proper .app files from jars.
I found here that the contents of these jar-apps are the same, so I did as the person suggested and only replaced the jar file inside Contents/Java (or Contents/Resources/Java in the old Jar Bundler), and it works. I could keep using AppBundler, but I'd prefer not needing an extra dependency/plugin for Ant.
Anyways, when I automate it with Ant - the .app doesn't open. I narrowed it down to this:
A .app produced from AppBundler
If I copy and paste it somewhere else, it launches
If I copy and paste it with Ant, it doesn't launch
I even tried things like clearing my application state cache, without luck. Again, the weird thing is if I copy the "source app" myself, the copy launches. If I copy the source app with Ant (and I'm doing nothing else) it doesn't.
Here's my Ant snippet (.app are just folders AFAIK) (dist.macapp is the name of the .app):
<copy todir="${dist.dir}" >
<fileset dir="${resources.dir}">
<include name="${dist.macapp}/**" />
</fileset>
</copy>
I guess I have two questions:
Why isn't this working (I think I provided enough what have I tried :P )
Is there a better way to do this (Java Web Start is out of the question, maybe something I'll look into later)

A .app file on Mac is just a standardized folder layout. You could always bundle it yourself with a script. Simply replacing the jar file isn't quite enough.
Make something like this
Contents/
Java/yourjar.jar
info.plist /* specific to your application! maybe make a template then find and replace strings */
MacOS/JavaApplicationStub
Copy the executable /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub into the MacOS folder (this is not app specific and could be done once).
I am not sure of the format for the info.plist specific to Java.

Related

Dereferences a xml file from xcode

I made a huge mistaking in renaming my xml file from xcode and I'm not sure how to fix it. My app has a feature that reads all local xml files built with the project. So now it is reading 2 of the same xmls with different names.
I tried deleting the file, added it back in, and Dereferencing it but no luck. I also made sure to delete my app and re building the project. When I do a full system scan for the xml file nothing pops up. The xml file is currently in the Trash.
Another issue might have been with the svn remote server but I tried svn rm --delete filename and it said the file does not exist. ( I tried the project directory as well as a few other sub directories).
Is there a way to Dereference/delete the file from the project?

Maven - how to build custom file structure including the output jar

I am building app with following structure (where myApp is root):
myApp\bin\myApp.jar
myApp\runMyApp.bat
So I need to 'wrap' the ouput jar in two directories and add to the outer directory myApp a script file.
How do I best set POM to do this?
Bonus question: I like the idea of making exe from bat. Currently I use a tool for that. Can something like this be achieved with Maven? Is having exe better than just bat file? (I did it mainly to insert the custom icon).
First off the AppAssembler plugin can be used to create the .bat file for your .jar. It may not support the exact layout you are after, but it should be customizable to get something rather close.
Secondly, the assembly plugin can then slurp all that up and produce a .zip file that has the layout you want and contains all the files you are after.
Other things to look into are the NSIS which can create a .exe windows installer for your application.
Tools such as launch4j can help wrap your entire application up in an .exe though I personally cannot find a nice maven way plugin for it.
I have used the assembly plugin to create custom output directories and have found it very powerful. You can specify the archive format of the output folder like zip, etc and also relative paths to files that need to be included in the zip. Dependencies for your project are included in by adding in the below into your custom assembly xml file - this will add in all the dependent jars as specified in the pom.xml
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>false</unpack>
<scope>compile</scope>
<useTransitiveDependencies>false</useTransitiveDependencies>
</dependencySet>
</dependencySets>
Here is the link to the create your custom assembly descriptor - http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

ant compiling libraries seems to be caching swcs

I'm massively miffed with this one. Here's the scenario:
I have an ant task which builds and outputs a bunch of swcs
The ant task deletes all items in the 'libs' folder, then compiles in order my libraries out outputs them to the 'libs' folder.
I have other modules that I compile that depend on these libraries
The problem: I'm having issues where a swc which depends on another swc is compiling against the old version not the one just built in the ant task.
So we compile first common.swc then mydependantswc.swc. When I compile mydependantswc.swc is compiling against common.swc - the one just built. When I compile its like common.swc has been cached, it ignores the once just build and compiles against the old version.
I know this happens in flash when you don't delete your old swc libraries before recompiling. However my ant task deletes those files. I found that on the mac if I manually went into finder and deleted those libraries off, then compiled, it works fine. Even though the ant task does that, it doesn't work.
Any ideas please? Sounds like this might be a common issue?
Here are some ant code snippets, I think its quite simple ant.
<target name="install-libraries" description="standalone build libs">
<delete includeEmptyDirs="true">
<fileset dir="${bin.dir}/${managed.libs.dest}"/>
</delete>
<mkdir dir="${bin.dir}/${managed.libs.dest}"/>
<antcall target="compile-libraries"/>
</target>
followed by a standard compc task.
After talking on twitter I suspect it has something to do with the folder structure. You see that one library has a dependency on another compiled library in this folder bin.dir, which is also the folder that I am building to. I don't know why, but i sense a smell!

Problem with CruiseControl.net configuration

I started using ccnet to build my project. This is quite new issue for me so I have some problems.
First thing: Why does ccnet copy directory with my project to another directory (ccnet creates new folder named the same as project name included in ccnet.config file and copies to them directory with my project)
Second thing: Dashboard page cannot show reports for recent build (When I click on any item in recent build then I get page: "The page Cannot be found" I suppose that page cannot link files with logs. but I don't know how to link it.
I create one publisher:
<publishers>
<xmllogger logDir="c:\Branches" />
Can anyone help me?
Just a question, does the batch file "C:\Branches\Scripts\Build Release.bat" perform that step?
Because I can't see anything obvious within the CruiseControl config to copy the files into "c:\Program Files\CruiseControl.NET\Sever\TestProject"...
In build Release script I just call devenv to compile my project
Not sure I fully understand the 'first thing' if you can elaborate on it I'll try to help.
On our system it performs an SVN checkout of the code to a specified location and builds it there. Even though our CCNet installation is on the same box as the SVN repository it still needs somewhere separate to build the project.
On the 'second thing' it sounds like you have not set the <webURL> element properly - not a major problem. If you can post your config file that may help (with both issues).
Our CCNet installation pretty much worked out of the box but it is pretty fussy about it's config files. Have you made any changes to the dashboard.config file or is it as installed?
[Edit in response to posted config file]
I can't see anything in this config that will cause CCNet to copy the project to c:\Program Files\CruiseControl.NET\Server\TestProject. It could be something to do with the way you are calling devenv in your batch file - do you specify any paths in there?
Based on your config file and assuming you have an out of the box installation, your <webURL> element should read something like this:
<webURL>http://localhost/ccnet/server/local/testProject/ViewProjectReport.aspx</webURL>
On top of all that I would highly recommend that you drop the use of .bat files and devenv.exe for building your projects. Although this is the way I started with CCNet I quickly found that using NAnt and MSBuild well worth the effort.
I Try explain it more.
I have my local copy of repository on the path: "c:\Branches\trunk"
here is my config file:
<cruiseControl>
<project name="testProject">
<webURL>http://localhost/ccnet/</webURL>
<triggers>
<intervalTrigger name="interval trigger" seconds="600" initialSeconds="30" />
</triggers>
<sourcecontrol type="svn" autoGetSource="true">
<trunkUrl>http://********/svn/general/provider/prototype/Trunk</trunkUrl>
<workingDirectory>C:\Branches\Trunk</workingDirectory>
<password>***********</password>
<username>*************</username>
</sourcecontrol>
<tasks>
<exec>
<description>Compile program</description>
<baseDirectory>C:\Branches\Trunk\</baseDirectory>
<buildTimeoutSeconds>9000</buildTimeoutSeconds>
<executable>C:\Branches\Scripts\Build Release.bat</executable>
</exec>
</tasks>
<publishers>
<xmllogger logDir="C:\Branches\Trunk\Logs" />
</publishers>
<state type="state" directory="C:\Branches\Trunk\Logs"></state>
</project>
</cruisecontrol>
I didn't change anything in dashboard.config File.
cnet copy all folder c:\Branches\Trunk
to new folder c:\Program Files\CruiseControl.NET\Sever\TestProject
First problem was cause because in previous version of config file i use filesystem as sourcecontrol. Right now this problem don't occur.
Second problem is not resolved, But I have one Idea, Does any configuration files should be placed in virtual directory?

Project file with just files and no built output

How can I make a project file (VS 2008) that just has some data files in and has no built output?
I can make an empty project and add my data files to it (which get copied to the output folder
), but it produces an EmptyProject.dll after I do a build. I want just my data files in the output directory and not some empty DLL or EXE.
I want the data files to be the only thing in this project as the project will be shared in a couple of solutions.
Our application is C#. All of our normal code projects are C#.
The data files are schemas (XSD). I want these schemas to be in the output folder, but I don't want them included with an existing project. I would like a project named "Schemas" that has nothing in except the XSD files and does nothing except copy the XSD files to the output folder. I would like this in a project file so that the same schemas project can be referenced in multiple solutions.
I don't know of a way to suppress the creation of the .dll file. BUT... here's an easy workaround. In the project properties, Build Events tab, write a Post-build event command line that will delete the file. Something like:
del path\filename.dll
Expanding on Scott's answer:
Create a new project of type Empty project
In Properties->Application, change Output type to Class Library
In Properties->Build->Advanced, change Debug Info to None
In Properties->Build Events, set the Post-build event command line to del $(TargetPath)
That way, the project creates only a DLL, which gets deleted. At the same time, the "copy to output directory" settings on your data files is respected.
Possibly another way is editing the csproj file by replacing this:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
with this:
<Target Name="Build" />
<Target Name="Rebuild" />
Then builds don't create anything. It worked for me.
Same general idea should work for any xxproj file. Just replace the <Import Project...> tags with the <Target...> tags.
I'd be interested in knowing if this causes any issues or doesn't work for anyone.
What do you need a project for if you're not building it?
You can use solution folders to "store" files...
Why not just disable building this project for all configurations (use the Configuration Manager) - that way it won't build.
Great stuff. Expanding on Scott > Daniel's answer:
Safe to remove all References and Properties (AssemblyInfo.cs)
If it is a node/grunt/gulp project then you can invoke it in your Build Events > *Post-build event command line * eg: gulp build or gulp clean
Perhaps you can add removal or obj and bin output folders to your node/grunt/gulp clean scripts mitigating the need for del $(TargetPath)

Resources