Ant task to build Mac OS X Package - macos

I'm looking for Ant task which will assemble Mac OS X PKG-file from my application files. Googled. No result. Any help?

I propose you get inspiration from this old mailing post and use Ant tasks copy, chmod, chown, tar, gzip instead of commands from shell... It still remains to call the /usr/bin/package command with exec. Maybe this little Perl script packagelint may help too.

So, i have found no special ant task. But i learned how to create Mac OS X package with PackageMaker from inside ant. First you have to create PackageMaker project manually. Create a package in PackageMaker then save it as, say, 'testpkg'. Now you need to add following code in your ant script.
<exec executable="/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker">
<arg value="--doc"/>
<arg value="./Installer/testpkg.pmdoc/"/>
<arg value="--out"/>
<arg value="${build.dir}/../test.pkg"/>
</exec>
Of cource you need to change some arguments to your paths.
This method is simple as if you create package manualy and then reassemble it automatically. But there is another side of medal: every time you have changes in files( e.g. new file must be included in package) you have to change your package project manualy.
There are another ways to create pkg( packager tool and variety of command line switches of PackageMaker itself). I choose easy way.

Related

Setting environment variable through NSIS Envar-plugin

I have a custom installer created through NSIS.
I have the following Ant task doing the same:
<target name="buildNSIS">
<exec executable="D:\NSIS\nsis-binary\makensis.exe" failonerror="true" >
<!-- providing some nsis definitions -->
<arg value="/DPROJECT_NAME=${ant.project.name}"/>
<!-- passing the script -->
<arg value=".\installer\MySetup.nsi"/>
</exec>
</target>
where MySetup.nsi is the script to run through NSIS for the installer.
I want to set an environment variable as part of the install process.
I read that its best to do using: https://nsis.sourceforge.io/EnVar_plug-in
However, the instruction there is confusing. It just says: Just extract the contents to your nsis directory (usually '$PROGRAMFILES\NSIS')
What does it mean?
My D:\NSIS\nsis-binary directory looks like:
So do I unzip Envar_plugin.zip inside Plugins directory above and start using EnVar::AddValue or EnVar::AddValueEx functions inside my MySetup.nsi as mentioned in Envar_plugin examples?
How do I use Envar_plugin so that my resultant custom installer through MySetup.nsi for my software will set environment variables during installation of my software?
Plug-ins have to be installed in the correct plug-in subdirectory inside the NSIS folder. Some plug-ins only have a .DLL file in the root of the .ZIP file and some already have the correct directory tree in the .ZIP. This specific plug-in has the latter and you can just extract the contents to your main NSIS folder.
If you try to execute a plug-in command (name::function) and NSIS cannot find the plug-in then you most likely put the .DLL file in the wrong folder. Recent versions of NSIS will print a list of directories it tried to search when this happens.

How to preserve exec file in ant copy task

I have created Java FX bundle for Mac OS X using Ant. It creating bundle with two files -
1. MyApplication.app
2. MyApplication.dmg
I wish to copy both files at other folder, so I wrote command in my build.xml as -
<copy todir="my_new_folder">
<fileset dir="old_folder\bundles"/>
</copy>
It copying both files successfully at "my_new_folder". But on running .app from "my_new_folder" not launching my application though it is launching from "old_folder" correctly.
On comparing copied app I found that on exec (Unix Executable File) resided at MacOS folder ("Show Package Contents/Contents/MacOS") not preserving, its kind been changing in document file.
How to preserve its kind to Unix Executable File as I am simply executing simple copy directory.
Thanks,
Neelam Sharma
As noted in the ant copy task guide:
Unix Note: File permissions are not retained when files are copied; they end up with the default UMASK permissions instead. This is caused by the lack of any means to query or set file permissions in the current Java runtimes. If you need a permission-preserving copy function, use this instead:
<exec executable="cp" ... >
So, in your case, replace <copy> with:
<exec executable="cp">
<arg line="-R old_folder/bundles my_new_folder"/>
</exec>
(note that you should use forward slashes, even if this ant script is being used under Windows).

how to automated a BUILD task

I need help about how to automated a task with MSBUILD.
I wrote a small command line program that process files and I want integrate it at the moment of BUILD the solution.
The program itself is used like this:
Processor.exe inputFile.txt outputFile.txt –p
-p of course represents some parameters.
Is there a simple way to make visual studio to run this exe AFTER each Buildup??
To be honest I research a lot about the MSBUILD, but there is so much information out there, that it overwhelmed me.
There are different solutions but in your case the best is probably with custom AfterBuild target and Exec task. You should add it to your cproj file after Microsoft.CSharp.targets get imported.
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name ="AfterBuild">
<Exec Command="Processor.exe inputFile.txt outputFile.txt –p" />
</Target>
You can read more about Exec Task here:
Exec Task

Calling batch/script files from VC6/VC2005/VC2008 project files

Is there a way to invoke an external script or batch file from VC6 (and later) project files?
I have a background process that I need to kill before attempting to build certain projects (DLLS, executables) and haven't found a way to successfully do so from the project itself. I'd like simply to call a batch file with a taskkill command in it.
(Yes, I could run the batch file from a command line before building the projects, but I don't always remember to do so and having it done automatically would be more convenient and less irritating for the whole development team.)
You can create a utility project (configuration type: Utility in the project property pages) that has a post build event. You then call the batch file from that Post-Build event. If I remember correctly, utility configuration appeared in VS2005. But I believe the same can be achieved with another type of configuration on VC6.
Here is an example of a setup (this is the text of the Command Line property of the Post-Build Event):
set solutionDir=$(SolutionDir)
set platformName=$(PlatformName)
set configurationName=$(ConfigurationName)
call $(SolutionDir)PostBuild.bat
As you can see, you have all the flexibility of customizing the batch environment based on VisualStudio macros.
If you want to have this batch file called every time you build, add a dependency to the requiring project (your main executable or dll project for example). You can add your batch file to the solution items for convenient access (right-click on the solution and select Add -> Existing Item...).
You can even invoke the build command on this utility project to force the execution of the batch file.
At work we have a similar setup to start our unit tests each time a build is triggered.
You could invoke it from a custom build step or a build event.
At least for C# in Visual Studio 2008, you can open the project file and find within the file the following comment:
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
Uncomment the one that works best for you, in this case the "BeforeBuild" item. Then substitute your batch file for the one I have here:
<Target Name="BeforeBuild">
<Exec Command="MyBatchFile.bat" />
</Target>
That's all there is to it; whenever you build that project, this will take place each and every time.
That said, I do not know if this works the same for VS 2005 or, especially, VC6. YMMV!

Can you use CruiseControl to build Cocoa/Objective-C projects?

Has anyone ever set up Cruise Control to build an OS X Cocoa/Objective-C project?
If so, is there a preferred flavor of CruiseControl (CruiseControl.rb or just regular CruiseControl) that would be easier to do this with.
I currently have a Ruby rake file that has steps for doing building and running tests, and wanted to automate this process after doing a checkin.
Also, does CruiseControl have support for git? I couldn't find anything on the website for this.
Yes, you just run xcode builds via the command line (xcodebuild) which makes it simple to target from CC via an ant <exec>. I've been using just regular CC, not the ruby version and it works fine. Here's a barebones example:
<project name="cocoathing" default="build">
<target name="build">
<exec executable="xcodebuild" dir="CocoaThing" failonerror="true">
<arg line="-target CocoaThing -buildstyle Deployment build" />
</exec>
</target>
</project>
More info on xcodebuild
And there does appear to be a standard git object here, but I don't use git so I can't tell you much more than that!
Yes, CruiseControl has a support for git.

Resources