Installing Flex SDK into maven repository
The past week I needed to mavenize one of my Flex projects and compile it with a Flex SDK 4.1.0 versions. Since the public repoo only offers the latest stable build of Flex SDK ( which is normal ), I found myself in the position to install the SDK into a custom repository.
To do so I had to dig the web a bit and I found some documentation provided by sonatype. According to sonatype, “The descriptors used by Flexmojos to publish Flex SDK aren’t public available and won’t be provided. The goal is to really make this process hard.” I got no problem with this limitation but that wouldn’t fulfill my need though.
To solve this, I followed one of the Agile principles, that is “to do the simplest thing that could possible work”. To me, this got translated into some shell scripts.
I looked inside the pom files of a previous SDK that was installed in my local repo, and I tried to replicate it for a newer SDK. I had to take every dependency and install it with
mvn install:install-file
The result I eneded up with looks similar to:
install-flex-sdk /path/to/unzipped/sdk SDK_VERSION
If you want to use it, I’ve shared a ZIP file containing the script and the necessary files needed to install the Flex SDK into a local maven repository. You can download it here.
Prior to installing the SDK you need to, of course, go to opensource.adobe.com site, download and unzip the SDK. You can also use “wget” to download the SDK and you could even include it into the shell script. The reason I didn’t do it, is because you need to agree to the SDK’s “Terms and Conditions” prior to downloading the SDK.
After downloading the SDK, I had to issue this command:
./install-flex-sdk.sh /KITS/PROGRAMMING/ADOBE/Flex_SDK/flex_sdk_4.1.0.16076/ 4.1.0.16076
generating the following output ( I truncated it to show just the first lines ) :
--------------------------------- INSTALLING COMPILER --------------------------------- --------------------------------- GENERATING: compiler pom --------------------------------- Executing: sed 's/${SDK_VERSION}/4.1.0.16076/g' compiler.pom.template >> compiler.pom --------------------------------- INSTALLING: compiler pom --------------------------------- [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'install'. [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Default Project [INFO] task-segment: [install:install-file] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] [install:install-file] [INFO] Installing /KITS/PROGRAMMING/ADOBE/Flex_SDK/Maven_deployer/compiler.pom to /Users/dragos/.m2/repository/com/adobe/flex/compiler/4.1.0.16076/compiler-4.1.0.16076.pom [INFO] Creating Checksums... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1 second [INFO] Finished at: Mon Mar 29 15:29:38 EEST 2010 [INFO] Final Memory: 5M/125M [INFO] ------------------------------------------------------------------------ --------------------------------------------------- Installing artifact=adt form file=/KITS/PROGRAMMING/ADOBE/Flex_SDK/flex_sdk_4.1.0.16076//lib/adt.jar packaging=jar ...
After installing the SDK into the local repository I had to find a way to expose it to Nexus, because I wanted other developers to be able to run the maven build successfully. Installing the SDK with the script I provided, it installs only into the local repository of the user, but Nexus runs an o a different user usually, having its own repository. If you don’t link the SDK you installed with Nexus, other developers won’t be able to run the build successfully. Fortunately, this process is pretty easy once you know that you need to do that. Simply issue a copy command, to copy your ~/.m2/repository/com/adobe/flex into the Nexus repository.
In my case I had to do:
cp -r ~/.m2/repository/com/adobe/flex/* /usr/share/tomcat5/sonatype-work/nexus/storage/MY_CUSTOM_LOCAL_REPOSITORY/
Installing into a custom repository, enforces you to let the pom.xml know where to look for dependencies. So don’t forget to add the url to your repository in the pom.xml files or in the settings.xml file. I won’t describe the process in this post but you can ask me if you don’t know how.