Flex Ant compile project - apache-flex

i want to use Ant task to compile flex project(with many libraries, modules)
i use -dump-config build.xml compiler option in flash builder to extract build config
after i create this Ant task(for start, i try to compile only one mxml-module) :
<project name="My App Builderrrr" basedir="." default="main">
<property name="QA_PM_DEST" value="[my project dir]\src"/>
<property name="BIN_DEBUG" value="[my project dir]\bin-debug"/>
<property name="FLEX_HOME" value="C:/Program Files/Adobe/Adobe Flash Builder 4/sdks/4.0.0"/>
<property name="APP_ROOT" value="src"/>
<property name="DEPLOY_DIR" value="c:\output"/>
<taskdef resource="flexTasks.tasks" classpath="${basedir}/libs/flexTasks.jar"/>
<target name="main">
<mxmlc file="${QA_PM_DEST}/***.mxml"
output="${DEPLOY_DIR}/***.swf">
<load-config filename="***\build.xml"/>
</mxmlc>
</target>
and after
ant -buldfile mybuildfile.xml
but it generates very small swf file that runs with errors(67kb insted of 300kb in release build and 800kb in debug)

I think you need to load the following config, too:
<property name="flex.config" value="${FLEX_HOME}/frameworks/flex-config.xml"/>
<load-config filename="${flex.config}" />
(UPDATE 2010-08-19)
I also add incremental="false" to my mxmlc call and the libraries this way:
<library-path dir="${lib.dir}" append="true">
<include name="**.swc" />
</library-path>
An the following is also missing in your file:
<source-path path-element="${src.dir}"/>

Related

How to export Flash builder air mobile project to swf

I have created a flex mobile as3 project that exports to air, to ipa and apk.
This project does not use any specific to mobile or air calls (camera, files. .)
my question is : how do I create a swf ?
Regards
Since your project doesn't use any AIR-specific APIs, you can use an Ant build to create a SWF from your mobile project. The following build file will do the trick if your project is self-contained as a single Flash Builder project.
<?xml version="1.0" ?>
<project name="Build" default="build">
<property name="FLEX_HOME" value="C:/Program Files/Adobe/Adobe Flash Builder 4.7/sdks/4.6.0" />
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<property name="PROJECT_NAME" value="MyMobileProject" />
<property name="PROJECT_BASE_DIR" value="C:/FlexProjects/${PROJECT_NAME}" />
<property name="PATH_TO_SRC_FOLDER" value="${PROJECT_BASE_DIR}/src" />
<property name="OUTPUT_DIR" value="${PROJECT_BASE_DIR}/bin" />
<target name="build">
<mxmlc file="${PATH_TO_SRC_FOLDER}/${PROJECT_NAME}.mxml"
output="${OUTPUT_DIR}/${PROJECT_NAME}.swf"
show-actionscript-warnings="false" show-binding-warnings="false"
locale="en_US" incremental="true">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<source-path path-element="${PATH_TO_SRC_FOLDER}" />
<external-library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
<include name="*.swc" />
</external-library-path>
<compiler.library-path dir="${PROJECT_BASE_DIR}/libs" append="true" includes="*"/>
</mxmlc>
</target>
</project>

Alfresco custom action dialog not showing

I created a custom Alfresco action dialog using one of the sample SDK projects
as a base. I kept the sample projects "org.alfresco.sample" package for my java files
and it worked fine.
Then I tried to change the package name to "com.xxxxxx.xxxxx" and it stopped working.
I have checked all of the files in the project to make sure that I have replaced every instance of "org.alfresco.sample" with my new package name.
Can anyone suggest a possible reason for this?
Thanks
I found that when I build the project, it is not building the java files. Can anyone
suggest why it is not building the java files with the new package name?
Thanks
I got the java files build again. But the new actions are still not being used. The new actions use an evaluator but it does not seem to be running. (It would normally write to
the log.)
Here is part of the build.xml:
<project name="Custom Dialog Build File" default="package-amp" basedir=".">
<property name="project.dir" value="."/>
<property name="build.dir" value="${project.dir}/build"/>
<property name="config.dir" value="${project.dir}/config"/>
<property name="jsp.dir" value="${project.dir}/web/jsp"/>
<property name="web.dir" value="${project.dir}/web" />
<property name="package.file.jar" value="${build.dir}/lib/custom-dialog.jar"/>
<property name="package.file.zip" value="${build.dir}/lib/custom-dialog.zip"/>
<property name="amp.file" value="${build.dir}/dist/retailChannels.amp"/>
<path id="class.path">
<dirset dir="${build.dir}" />
<fileset dir="../../lib/server" includes="**/*.jar"/>
</path>
<target name="compile">
<mkdir dir="${build.dir}" />
<javac classpathref="class.path" srcdir="${project.dir}/source" destdir="${build.dir}" />
</target>
<target name="package-jar" depends="increment-build-number">
<delete file="${package.file.jar}" />
<jar destfile="${package.file.jar}">
<fileset dir="${build.dir}">
<exclude name="dist/**" />
<exclude name="lib/**" />
<exclude name="web/**" />
</fileset>
</jar>
</target>
<target name="mkdirs">
<mkdir dir="${build.dir}/dist" />
<mkdir dir="${build.dir}/lib" />
</target>
<target name="clean">
<delete includeemptydirs="true">
<fileset dir="${build.dir}/dist" includes="**/*"/>
</delete>
</target>
<target name="package-amp" depends="clean, mkdirs, package-jar" description="Package the Module" >
<delete file="${amp.file}" />
<zip destfile="${amp.file}" >
<fileset dir="${project.dir}/build" includes="lib/*.jar" />
<fileset dir="${project.dir}/config/alfresco/module/alfresco" includes="*.properties" />
<fileset dir="${project.dir}" includes="config/**/*.*" excludes="**/module.properties" />
<fileset dir="${project.dir}/source">
<include name="web/jsp/**/*.jsp" />
<include name="web/images/**" />
</fileset>
</zip>
</target>
</project>
I just tried going through the maven SDK tutorial that you suggested but I got
this error:
Feb 14, 2014 3:42:48 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
Check the build.xml file. Double-check the compile and package-jar tasks (or similar). For example, one or both of these tasks may have a fileset that uses a pattern to include your classes using the package structure, and it may no longer match now that you've changed your package name.
It's hard to tell without seeing your build.xml.
By the way, if you want a more up-to-date example for creating actions in Alfresco, take a look at this tutorial: http://ecmarchitect.com/alfresco-developer-series-tutorials/actions/tutorial/tutorial.html
It uses the Alfresco Maven SDK to package AMPs. The Alfresco Maven SDK is preferred over the old SDK you are using.

Getting ant build error "Unable to locate specified base class 'mx.core.Application' for component

I am trying to build using ant a Flex 3.5 app, and I keep on getting the error:
Unable to locate specified base class 'mx.core.Application' for component class 'main'.
my build.xml file looks something like:
<project name="ASC App" default="compile flex project">
<!-- load previously defined configuration properties file -->
<property file="build.properties" />
<!-- points to our flexTasks.jar we copied to the libs folder to distribute with the project -->
<taskdef resource="flexTasks.tasks" classpath="${basedir}/libs/flexTasks.jar"/>
<!-- delete and create the DEPLOY dir again -->
<target name="init">
<delete dir="${DEPLOY_DIR}" />
<mkdir dir="${DEPLOY_DIR}" />
</target>
<!-- Build and output the Main.swf-->
<target name="compile flex project" depends="init">
<mxmlc file="src/main.mxml" output="${DEPLOY_DIR}/main.swf">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${APP_COMMON}"/>
<source-path path-element="${FLEX_COMMON}"/>
<library-path dir="${LIBS_DIR}/AlivePDF/" append="true"/>
<library-path dir="${LIBS_DIR}" append="true"/>
<compiler.debug>false</compiler.debug>
</mxmlc>
</target>
and my build.properties:
# Application name
APP_NAME=AS App
# SWF file
APP=main
# Common library
APP_COMMON=../ASC_common
FLEX_COMMON=../common
ALIVE_PDF=../libraries/AlivePDF/SWC/AlivePDF
# change this to your Flex SDK directory path
FLEX_HOME=/SDKs/flex_sdk_3_4
# this points to your project's src directory
SRC_DIR =${basedir}/src
# points to the project's libs directory
LIBS_DIR =${basedir}/libs
# this is the folder we want to publish the swf to
DEPLOY_DIR = ${basedir}/DEPLOY
Your help would be very much appreciated!
I am trying to build using ant a Flex 3.5 app
Yet you have
FLEX_HOME=/SDKs/flex_sdk_3_4

Could not load definitions from resource flexTasks.tasks. It could not be found

I'm attempting to compile a Flex application from an ANT script, inside of Eclipse (CFBuilder, based on Eclipse), and I've run into this error:
Could not load definitions from resource flexTasks.tasks. It could not be found.
I haven't been able to find anything that gives directions on where this file (flexTasks.tasks) should be copied to, if it's needed at all. Some places indicate that it should be part of the flexTasks.jar file. I've tried two different things:
Copy the jar file into the ant/plugins/lib folder (and restart my CF Builder instance)
Specify the path to the jar in the classpath attribute, as suggested by the comment on this page
Neither helps me get past this error.
Here's my build script, for reference:
<project name="Tagging" default="compile-tagging" basedir=".">
<!-- setup flex compilation capability -->
<taskdef resource="flexTasks.tasks" />
<property name="flex.src" value="./src" />
<property name="flex.bin" value="./bin"/>
<target name="compile-tagging">
<mxmlc
file="${flex.src}/main.mxml"
output="${flex.bin}/main.swf"
keep-generated-actionscript="true">
<source-path path-element="${FLEX_HOME}/frameworks" />
</mxmlc>
</target>
</project>
Adam, I believe you need to tell taskdef where to look for the file. try keeping flextasks.jar in the same directory as your ant file (for now... you can move it later after you get it working).
then, you can do something like this:
<taskdef name="mxmlc" classname="WhateverTheTaskIsNamed" classpath="flexTAsks.jar" />
While not ideal, this code is working for me at the moment:
<project name="IOLTagging" default="go" basedir=".">
<!-- setup flex compilation capability -->
<property name="FLEX_HOME" value="C:/program files (x86)/Adobe/Adobe Flash Builder Beta 2/sdks/3.4.1/" />
<taskdef name="mxmlc" classname="flex.ant.MxmlcTask" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<taskdef name="html-wrapper" classname="flex.ant.HtmlWrapperTask" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<property name="flex.src" value="./src" />
<property name="flex.bin" value="./bin"/>
<property name="swf.name" value="main" />
<target name="go" depends="compile-flex" />
<target name="compile-flex">
<mxmlc
file="${flex.src}/main.mxml"
output="${flex.bin}/${swf.name}.swf"
debug="false"
keep-generated-actionscript="false">
<source-path path-element="${FLEX_HOME}/frameworks" />
<compiler.library-path dir="${basedir}/libs" append="true">
<include name="*.swc" />
</compiler.library-path>
</mxmlc>
</target>
</project>
I had the same problem, and the reason was in lack of permissions to acces $FLEX_HOME/ant.
You can also put the flexTasks.jar in ~/.ant/lib directory
If you run ant -diagnostics you should see the jar in USER_HOME/.ant/lib jar listing
I think you should have solved this problem. just trying flexmonkey today and also got the same problem.
"Could not load definitions from resource flexTasks.tasks. It could not be found."
solution is to make sure the flexTasks.jar is included in the dir lib of your project workplace.
when I copied flexTasks.jar from flashbuild folder \ant\lib and built it again. the problem is fixed.

Compiling mxml files with ant and flex sdk

I am just getting started with flex and am using the SDK (not Flex Builder). I was wondering what's the best way to compile a mxml file from an ant build script.
The Flex SDK ships with a set of ant tasks. More info at:
http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html
Here is an example of compiling Flex SWCs with ant:
http://www.mikechambers.com/blog/2006/05/19/example-using-ant-with-compc-to-compile-swcs/
mike chambers
I would definitely go with the ant tasks that are included with Flex, they make your build script so much cleaner. Here is a sample build script that will compile and then run your flex project
<?xml version="1.0"?>
<project name="flexapptest" default="buildAndRun" basedir=".">
<!--
make sure this jar file is in the ant lib directory
classpath="${ANT_HOME}/lib/flexTasks.jar"
-->
<taskdef resource="flexTasks.tasks" />
<property name="appname" value="flexapptest"/>
<property name="appname_main" value="Flexapptest"/>
<property name="FLEX_HOME" value="/Applications/flex_sdk_3"/>
<property name="APP_ROOT" value="."/>
<property name="swfOut" value="dist/${appname}.swf" />
<!-- point this to your local copy of the flash player -->
<property name="flash.player" location="/Applications/Adobe Flash CS3/Players/Flash Player.app" />
<target name="compile">
<mxmlc file="${APP_ROOT}/src/${appname_main}.mxml"
output="${APP_ROOT}/${swfOut}"
keep-generated-actionscript="true">
<default-size width="800" height="600" />
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.library-path dir="${APP_ROOT}/libs" append="true">
<include name="*.swc" />
</compiler.library-path>
</mxmlc>
</target>
<target name="buildAndRun" depends="compile">
<exec executable="open">
<arg line="-a '${flash.player}'"/>
<arg line="${APP_ROOT}/${swfOut}" />
</exec>
</target>
<target name="clean">
<delete dir="${APP_ROOT}/src/generated"/>
<delete file="${APP_ROOT}/${swfOut}"/>
</target>
</project>
There is another option - it's called Project Sprouts.
This is a system built with Ruby, RubyGems and Rake that provides many of the features found in Maven and ANT, but with a much cleaner syntax and simpler build scripts.
For example, the ANT script shown above would look like this in Sprouts:
require 'rubygems'
require 'sprout'
desc 'Compile and run the SWF'
flashplayer :run => 'bin/SomeProject.swf'
mxmlc 'bin/SomeProject.swf' do |t|
t.input = 'src/SomeProject.as'
t.default_size = '800 600'
t.default_background_color = '#ffffff'
t.keep_generated_actionscript = true
t.library_path << 'libs'
end
task :default => :run
After installing Ruby and RubyGems, you would simply call this script with:
rake
To remove generated files, run:
rake clean
To see available tasks:
rake -T
Another great benefit of Sprouts, once installed, is that it provides project, class and test generators that will get any development box ready to run with a couple simple command line actions.
# Generate a project and cd into it:
sprout -n mxml SomeProject
cd SomeProject
# Compile and run the main debug SWF:
rake
# Generate a new class, test case and test suite:
script/generate class utils.MathUtil
# Compile and run the test harness:
rake test
If you're open to Maven, try the flex-compiler-mojo plugin:
http://code.google.com/p/flex-mojos/
Christiaan

Resources