Launching Windows Explorer from ANT? - windows

Is there any way of launching Windows Explorer from ant without stopping the build?
Here is what I have so far:
<project default="default">
<target name="default">
<fail unless="customerName">
You need to set the customerName.
-DcustomerName=Value
</fail>
<fail unless="htmlCode">
You need to set the htmlCode.
-DcustomerName=Value
</fail>
<exec executable="cmd">
<arg value="-b">
</exec>
<exec executable="explorer">
<arg value='"C:\working_copies\${customerName}\${htmlCode}"' />
</exec>
<exec executable="explorer">
Unfortunately the code above pauses for each window opened and I don't get both my explorer windows at once.

This should work:
<exec executable="cmd.exe"
dir="C:\working_copies\${customerName}\${htmlCode}">
<arg line="/c explorer ." />
</exec>

Related

Specifying maven project directory in exec tag

I am running this in Bamboo using command task executable=Gradle.
<target name="deploy-jar">
<exec executable="${maven.bin}" >
<arg value="deploy:deploy-file" />
<arg value="-DgroupId=${groupid}" />
<arg value="-DartifactId=${artifact}" />
<arg value="-Dversion=${version}" />
<arg value="-Dpackaging=jar" />
<arg value="-Dfile=${file}" />
<arg value="-Durl=${maven.repo.url}"/>
<arg value="-DrepositoryId=${maven.repo.id}" />
</exec>
</target>
The build is failing due to incorrect executable="${maven.bin}"
Would someone be able to give me the proper maven project location for it to run in Bamboo successfully? or at least an idea.
Thank you!!

xCodeBuild command line/ code signing fail

I was using xcrun with Xcode 6.3 and I wasn't getting any issue.
<exec executable="xcrun" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">
<arg line="-sdk ${TARGET_SDK}" />
<arg line="PackageApplication"/>
<arg line="-v ${PROJECT_BUILD_LOCATION_SRC}/${IOS_APP_BUNDLE_NAME}.app" />
<arg line="-o ${PACKAGE_DIR_SRC}/${APP_TARGET}.ipa" />
<arg line="--sign '${CODE_SIGNING_IDENTITY_SRC}'" />
<arg line="--embed ${basedir}/${PROVISONING_PROFILE_SRC}" />
</exec>
However, After I upgraded to xCode 7.3.1, the command started making issues on our app and after investigating, I read that I need to use xcodebuild command to create an archive and export a signed ipa file with our disruption cert.
I am using the following:
First: Clean:
<exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">
<arg line="-project ${XCODE_PROJECT_NAME}.xcodeproj"/>
<arg line="-alltargets clean"/>
</exec>
Second : Compile:
<exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}"
failonerror="true">
<arg line="-project ${XCODE_PROJECT_NAME}.xcodeproj"/>
<arg line="-alltargets" />
<arg line="-sdk ${TARGET_SDK}" />
<arg line="-arch armv7"/>
<arg line="-configuration ${CONFIGURATION_NAME}" />
<arg line="CONFIGURATION_BUILD_DIR='${PROJECT_BUILD_LOCATION_SRC}'"/>
<arg value="clean"/>
<arg value="build"/>
</exec>
Third: Create Archive:
<exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">
<arg line="-scheme ${XCODE_PROJECT_NAME}" />
<arg line="-sdk ${TARGET_SDK}" />
<arg line="-archivePath ${IOS_PROJECT_ROOT_SRC}/${XCODE_PROJECT_NAME}.xcarchive" />
<arg line="-configuration ${CONFIGURATION_NAME}" />
<arg line="archive"/>
</exec>
Forth : Export the archive to signed IPA.
<exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">
<arg line="-exportArchive"/>
<arg line="-archivePath ${IOS_PROJECT_ROOT_SRC}/${XCODE_PROJECT_NAME}.xcarchive" />
<arg line="-exportPath ${PACKAGE_DIR_SRC}" />
<arg line="-exportFormat" />
<arg line="IPA" />
<arg line="PROVISIONING_PROFILE ${basedir}/${PROVISONING_PROFILE_SRC}" />
</exec>
However, I'm getting this error:
Codesign check fails : /var/folders/_y/069ykjxd3hv51j9l62flnq2m0000gn/T/12AEA489-05B5-4682-BE29-7527661382B4-14940-000038AD332AE345/BankMobile.app: a sealed resource is missing or invalid
[exec] file missing: /private/var/folders/_y/069ykjxd3hv51j9l62flnq2m0000gn/T/12AEA489-05B5-4682-BE29-7527661382B4-14940-000038AD332AE345/BankMobile.app/archived-expanded-entitlements.xcent
I'm unable to create a signed IPA file, what am I missing?
After three days of working on this I found the full solution which is the following:
First
In your Xcode project you need to remove ResourcesRules.plist from Code Signing Resource Rules Path and set the other code signing flags to --no-strict:
Second:
I removed all the scripts mentioned in the question and added the following:
<property name="CONFIGURATION_NAME" value="Release"/>
<property name="TARGET_SDK" value="iphoneos"/>
<property name="PROVISONING_PROFILE_SRC" value='"Company Mobile In House Distribution"'/>
<exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">
<arg line="-scheme ${XCODE_PROJECT_NAME}" />
<arg line="-sdk ${TARGET_SDK}" />
<arg line="-archivePath ${IOS_PROJECT_ROOT_SRC}/${XCODE_PROJECT_NAME}.xcarchive" />
<arg line="-configuration ${CONFIGURATION_NAME}" />
<arg line="clean"/>
<arg line="archive"/>
</exec>
<echo level="info">Exporting the Archive file ${XCODE_PROJECT_NAME}.xcarchive</echo>
<exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">
<arg line="-exportArchive"/>
<arg line="-archivePath ${IOS_PROJECT_ROOT_SRC}/${XCODE_PROJECT_NAME}.xcarchive" />
<arg line="-exportPath ${PACKAGE_DIR_SRC}/${APP_TARGET}.ipa" />
<arg line="-exportProvisioningProfile ${PROVISONING_PROFILE_SRC}"/>
</exec>
The tricky part is the value for -exportProvisioningProfile. This value is NOT the UUID of the provisioning profile.
It is the exact name appears in your xCode account under Provisioning Profiles, it MUST be surrounded by double quotes like "".
[Review the PROVISONING_PROFILE_SRC value property carefully and update based on your own provisioning name as I added single quotes first then surrounded my provision name with double quotes]:

OSX - Create .app file using ant

I have written an app in Objective-C for running it on Mac(OSX not iOS). I want to use it for direct distribution. In XCode, I can create .app file using Product -> Archive -> Distribute.
How do I create .app file using ant?
I found the answer myself. My ant.xml is as follows
<project name="MacAgent" default="MacCompile">
<property name="keychain.password" value="my_password"/>
<property name="user" value="my_username"/>
<property name="project.id" value="my_project_name"/>
<property name="xcodeHome" value="/Applications/Xcode.app/Contents/Developer"/>
<target name="MacCompile">
<exec executable="security">
<arg value="unlock-keychain"/>
<arg value="-p"/>
<arg value="${keychain.password}"/>
<arg value="/Users/${user}/Library/Keychains/login.keychain"/>
</exec>
<exec executable="${xcodeHome}/usr/bin/xcodebuild">
<arg value="-project"/>
<arg value="${project.id}.xcodeproj"/>
<arg value="clean"/>
<arg value="build"/>
</exec>
</target>
</project>

Ant build executes cordova

I created an ant build for my cordova project as following:
<project default="build">
<target name="init-android">
<exec executable="cordova">
<arg value="platform"/>
<arg value="add"/>
<arg value="android"/>
</exec>
<exec executable="cordova">
<arg value="build"/>
</exec>
</target>
</project>
But I got this error:
C:\path_to_project\build.xml:3: Execute failed: java.io.IOException:
Cannot run program "cordova": CreateProcess error=2, The system cannot
find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Jav
a13CommandLauncher.java:41)
I can run cordova command with no problem from the command prompt, I have:
JAVA_HOME = C:/Program Files/Java/jdk1.7.0_10/
ANT_HOME = C:\Program Files\Java\apache-ant-1.9.2
NODEJS_HOME = C:\Program Files\nodejs
and they are all in my path. I don't understand why it doesn't work. Please help. Thanks
Generally when working with a Java application to launch programs in Windows, I often have to execute cmd.exe and pass it the full path to the program I actually want to run. This allows system environment variables and such to be set up the way you expect. Try this:
<project default="build">
<target name="init-android">
<exec executable="cmd.exe">
<arg value="/C"/>
<arg value="cordova"/>
<arg value="platform"/>
<arg value="add"/>
<arg value="android"/>
</exec>
<exec executable="cmd.exe">
<arg value="/C"/>
<arg value="cordova"/>
<arg value="build"/>
</exec>
</target>
</project>
If that still doesn't work, give the full path for cordova. An environment variable should work if you have one defined.

Ant exec - cannot run program 'start' CreateProcess error=2

I can't run the windows 'start' using ant exec. Ant version 1.7.1.
Here is sample build.xml to recreate the problem
<project name="test" basedir="." default="test-target">
<target name="test-target">
<exec executable="start">
<arg line="cmd /c notepad" />
</exec>
</target>
</project>
getting the following error when I execute this build file:
Execute failed: java.io.IOException: Cannot run program "start": Cre
ateProcess error=2, The system cannot find the file specified
My env is Windows XP, Ant 1.7.1
I am trying to run this from DOS prompt.
I rule out any PATH related issues, as I could run 'start cmd /c notepad' from DOS promt manually.
Any suggestions on how to fix this?
cheers
a s
start is not an executable but is an internal command of the cmd.exe shell, so to start something you'd have to:
<exec executable="cmd.exe">
<arg line="/c start notepad" />
</exec>
EDIT:
For spawning multiple windows, this should work:
<target name="spawnwindows">
<exec executable="cmd.exe" spawn="yes">
<arg line="/c start cmd.exe /k echo test1" />
</exec>
<exec executable="cmd.exe" spawn="yes">
<arg line="/c start cmd.exe /k echo test2" />
</exec>
</target>
but you mentioned that spawn="true" is not applicable for your environment, why is that?
my solution
<project name="test" basedir="." default="test-target">
<target name="start-init">
<exec executable="where" outputproperty="START">
<arg line="start" />
</exec>
</target>
<target name="test-target">
<exec executable="${START}">
<arg line="cmd /c notepad" />
</exec>
</target>
</project>
How about <exec executable="start.exe"> ? Or start.bat ?
Also, where is basedir="." pointing to? If you place a <echo message="basedir = ${basedir}"/> just before your <exec> tag, does it print the correct folder (the one with the "start" program in it)?
Additionally, you could add <echoproperties /> before <exec> to see all visible properties.

Resources