Ant not loading salesforce task definitions? - bash

The Question
I'm trying to use the Force.com Migration Tool (a custom ant library) on a linux box and can't for the life of me figure out how to get ant to see that library. What am I doing wrong?
The Error Message
BUILD FAILED
/home/ec2-user/ant/ucp/build.xml:48: Problem: failed to create
task or type antlib:com.salesforce:retrieve
Cause: The name is undefined.
The Background
I installed ant using yum install ant and then I dropped the Force.com Migration Tool (ant-salesforce.jar) into /usr/share/ant/lib. I'm able to see this library when I run ant -diagnostics, but none of the tasks for that library (should be seeing deploy, retrieve, etc.). I've uploaded a gist with the full output from ant -diagnostics.
-------------------------------------------
ANT_HOME/lib jar listing
-------------------------------------------
ant.home: /usr/share/ant
ant-bootstrap.jar (19837 bytes)
ant-salesforce.jar (3293054 bytes)
ant.jar (1942059 bytes)
ant-launcher.jar (18418 bytes)
After lots of googling and manual reading I tried the following to no avail (NB: the above diagnostics is without any of the below changes). I know I'm missing something obvious :(
Setting $ANT_HOME export ANT_HOME=/usr/share/ant
Fiddling with permissions chmod +x /usr/share/ant/lib/salesforce-jar
Fiddling with groups chown root:root /usr/share/ant/lib/salesforce-jar
Passing in class with -lib ant -lib /usr/share/ant/lib/salesforce-jar retrieve ...
Passing in lib folder with -lib ant -lib /usr/share/ant/lib retrieve ...
Adding $ANT_HOME to $PATH export PATH=$PATH:$ANT_HOME/bin

How about keeping ant-salesforce.jar under /home/ec2-user/ant/ucp and then change the taskdef element to look like this:
<taskdef resource="com/salesforce/antlib.xml" classpath="ant-salesforce.jar" />
Run your build again and see if things look better. Having the JAR in the same folder as build.xml will help you eliminate issues with permissions.

Based on #smooth_reggae's answer was able to get things working while keeping ant-salesforce.jar in the default ant lib directory. Seems like this should already be happening, but oh-well.
<taskdef resource="com/salesforce/antlib.xml"
classPath="${ant.library.dir}/ant-salesforce.jar"
uri="antlib:com.salesforce"/>

Related

Executing gradle scripts from external directories

I need to execute groovy script with gradle, but the thing is that these scripts are located in external directory (let's say it's Desktop). I've heard, that in previous versions of Gradle (currently working on 3.2.1) it was not possible, since it is not part of the gradle project. I wonder if it is possible now, or do I have to copy all these scripts into some folder located in gradle project, to execute it.
User story:
I found script in external directory (based on some properties passed to console) - I have absolute path to the script
Now I want to execute this script (build.gradle) without copying it into my gradle project
I'm pretty green with gradle and I hope I made my point clear.
Thanks for help and every attempt :)
Is that what you're looking for? To run the script clone the repository, navigate to 42556631/project folder and run the command:
gradle -b ../script/build.gradle clean build
yes you need to move build.gradle file into project/Build Script folder and then run it.

Automation issue with MOS and UiAutomator

I am using the following command in APK to invoke UiAutomator based test scripts:
proc = java.lang.Runtime.getRuntime().exec("uiautomator runtest Library.jar -c com.uia.example.my.Library");
It is working fine till LOS.
But in MOS, I am getting the following error:
Unable to unlink
/data/local/tmp/dalvik-cache/arm64/sdcard#data#Library.jar#classes.dex:
Permission denied
Please provide solution for this issue.
Note: I need to run scripts in release binary. So rooting is not possible.
Use Android Testing Support Library and create a test case extending InstrumentationTestCase as explained in Testing UI for Multiple Apps.
Then run your tests using
$ ./gradlew connectedCheck
The problem is due to no write permission in /data/local/tmp/ where you placed your Library.jar file. Write permission is required to extract dex from the Jar.
May be OEMs could disable rooting and remove write permission to /data/local/tmp and that may the reason for your issue in production/release builds ..
If you use uiautomator commands like : uiautomator runtest Library.jar ....
uiautomator will search for Library.jar by default in /data/local/tmp .
You can check uiautomator shell script present in /system/bin.
export run_base=/data/local/tmp ==> Classpath for searching the dex files.
One solution could be to place Library.jar and modified uiautomator script in your application folder (data/data//files).
you have to modify run_base with your application data folder path.
You can bundle the uiautomator script and jar following the instrcutions in below link :
http://gimite.net/en/index.php?Run%20native%20executable%20in%20Android%20App
Hope it helps ... Please update about your results.

problems running state machine examples

Congratulations on the spring state machine, I found it yesterday and have been trying it out, specifically the turnstile example running in STS. I found it very easy and intuitive to build a FSM.
Because spring shell doesn't work well in STS I tracked down the instructions to run the examples from the command line in the reference doc,
"java -jar
spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar"
,
but running it got an error
"no main manifest attribute, in spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar".
Although not even a novice in using gradle, I tried fixing this by adding this line to build.gradle in the jar section
"manifest.attributes['Main-Class'] = 'demo.turnstile.Application'"
(which doesn't handle the various sub-projects I know) but got this error
"NoClassDefFoundError: org/springframework/shell/Bootstrap".
If it is possible to run the samples from gradle, could you include them in the reference document? I tried running the samples using
gradle run
but it there was no interaction with the shell scripts.
Samples are designed to be run as executable jar and with shell so that you can interact without a need to recompile with every change. Your error indicates that you didn't build that sample jar as mentioned in docs.
./gradlew clean build -x test
This will automatically use spring boot plugin which will add the necessary jar manifest headers to jar meta info to make it a true executable jar. Essentially every every sample is a spring boot app.
Building SM sample projects in Windows Environment:
Open Command prompt (windows key + r -->cmd-->Enter), Change directory to project root folder spring-statemachine-master (Inside the Extracted folder).
Run gradlew install to get all spring dependencies copied to local machine.
Run gradlew clean build -x test to get the spring shell jars built. Courtesy Janne
These steps should ideally get all .jar built, look into \build\libs folder of respective sample project for jar files.
Run the like any other java jar file java -jar [jar-file-name.jar] (make sure to be change directory to jar file directory location).
One more thing where I was stuck was, How to give events to SM:
It's like this sm event EVENT_NAME_AS_DEFINED_IN_CLASS. Ref
E.g.: sm event RINSE --> to washer project

JavaFX Self Installer With Inno Setup 5 - Allow user to change install directory

I am using Ant to build a self deploying EXE for a JavaFX application.
Currently Inno Setup places the EXE here: C:\Users\username\AppData\Local\application name
I would like to place this in a different location, and provide the user the option to override this. However I can't seem to find the ant settings to change this.
Is this possible?
Thanks!
Actually you can't change this using ANT. However, as you already know the deploy mechanism uses Inno Setup and you can modify its behaviour.
During the fx:deploy ANT task a default ApplicationName.iss file is created. This default file contains e.g. the setting, which is responsible for the install directory. This default file is only created, if you don't provide any customized on your own. So, I would recommend to run the ANT script, copy the default file and modify it. If you enable the verbose flag of the fx:deploy task you can use the console output to find out, where the default file is created and where the ANT task searches for your customized file before creating the default one:
<fx:deploy
...
verbose="true">
<fx:info title="${appname}" vendor="${vendor}"/>
...
</fx:deploy>
In my case I found the default file in
C:\Users\gfkri\AppData\Local\Temp\fxbundler3627681647438085792\windows
and had to put the customized file to
package/windows/ApplicationName.iss
relative to the ANT build script.
If you got so far, you'll find the line DisableDirPage=Yes in your ApplicationName.iss file. Change it to DisableDirPage=No and the user gets the possibility to change the install directory.
Further you will find the parameter DefaultDirName. If you want to install your Application to C:\Program File\ApplicationName by default you can use the constant {pf} e.g.: DefaultDirName={pf}\ApplicationName.
The original answer is not true anymore, because that feature got added to the JDK (just dont know when, but it was there when using 1.8.0u60 or so).
Just add <installdirChooser> as some <bundleArguments> and set it to true:
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.4.0</version>
<configuration>
<mainClass>your.mainclass</mainClass>
<verbose>true</verbose>
<bundleArguments>
<identifier>SOME-GUID-USED-FOR-UPDATE-DETECTION</identifier>
<installdirChooser>true</installdirChooser>
</bundleArguments>
</configuration>
</plugin>
Disclaimer: I'm the maintainer of the javafx-maven-plugin

Xcode oclint analyzer

I want to use oclint (an Objective-C static analyzer) for my projects but the official documentation does not clearly describe how to configure it.
How do I use it?
I have installed the oclint package then copied the script for capturing projects configs into a project's folder. Running this script creates an empty file named compile_commands.json and it does not fill xcodebuild.log with any data.
Thank you!
I don't think this script will add anything into xcodebuild.log. It reads from it. You may want to manually run xcodebuild and save the output into xcodebuild.log before running the script.
Check out the documentation.
I have had luck with the manual route of copying the script into my project's folder then executing it on the command line.
Though this does not integrate oclint's functionality into XCode, it does provide feedback via stdout.
From this feedback I then update my code to align with oclint's recommendation and iteratively run oclint until my code complies with oclint's rules.

Resources