Using Local Maven Repository with Gradle
Gradle is capable of using Maven to find artifacts, including your own local maven repository.
To get this working I had to put the following stuff in my build.gradle.
usePlugin 'maven' // Maven plugin to install artifact in local Maven repo. def localMavenRepo = new File('c:/work/.m2/repository').toURL().toString() repositories { // Use local Maven repo location. We don't need this if we only want to install // an artifact, but we do need it if we want to use dependencies from the local // repository. mavenRepo urls: localMavenRepo } dependencies { compile 'com.itextpdf:itextpdf:5.0.0' groovy 'org.codehaus.groovy:groovy:1.6.7' // group:name:version is a nice shortcut notation for dependencies. testCompile 'junit:junit:4.7' }
Loading an XML File with URLLoader when HTTPService Doesn't Work
I was trying to load an XML file that lives next to my SWF on a webserver that I run locally.
Example URLs:
I was trying to use HTTPService but I kept getting "URL must be specified with useProxy set to false". Even if I configured my HTTPService.useProxy = false I still got the same error.
I looked around for a resolution but nothing seemed to work, until I stumbled upon the URLLoader. I setup a URLLoader and requested my data, but when I received the Event.COMPLETE event the "event.target.data" property only showed the first line of my XML...I was expecting to cast the "data" to an XML object, but that gave me a null.
A blog post shed some light. Essentially you have to explicitly create a new XML object. Here's a short snippet, keep in mind this snippet only listens for the "COMPLETE" event, in reality you should also listen for the SecurityErrorEvent and IOErrorEvent.
public function getData():void { var loader:URLLoader = new URLLoader( new URLRequest('http://localhost/myapp/foo-config.xml' )); loader.addEventListener(Event.COMPLETE, onComplete); } public function onComplete(event:Event):void { // var data:XML = event.target.data as XML; <--- doesn't work var data:XML = new XML(event.target.data); }
Enjoy!
Flex Goodies
On the main wiki page there is a link to the FlexStuff page which provides various Flex goodies that I've come across while developing with Flex.
rss