29
Mar

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.

Where to go from here:

5 Comments

  • Using Flex 4.5.0.17077 (Hero Early Beta) With Maven | DZ-015 Said:

    […] http://www.flexthinker.com/2010/03/installing-flex-sdk-into-maven-repository/ […]

  • Nico Said:

    Hi,

    for doing so I’m using a sonatype plugin (that i’ve checked out from svn)

    A descriptor xml is needed (I’ve made one for java-compiler artifacts, another for framework swc’s an a last one for swz)

    For installing
    mvn org.sonatype.plugins:bundle-publisher-maven-plugin:1.2-SNAPSHOT:install-bundle -Dbundle=/Users/nico/Desktop/flex_sdk_4.5.0.16410.zip -Ddescriptor=/Users/nico/Documents/workspaces/insurance_java/flex/descriptor_compiler.xml

    For deploying
    mvn org.sonatype.plugins:bundle-publisher-maven-plugin:1.2-SNAPSHOT:deploy-bundle -Dbundle=/Users/nico/Desktop/flex_sdk_4.5.0.16410.zip -Ddescriptor=/Users/nico/Documents/workspaces/insurance_galileo_sr3/flex/descriptor_compiler.xml -DrepositoryId=riality -Durl=http://maven.codeoscopic.com/content/repositories/flex-snaps/

    I’m doing so, but flexjos tema advises that custom sdk’s repos could drive to ‘weird’ problems if repo is not setup correctly.

  • admin Said:

    That’s cool. Thanks for sharing this. Can you also share the descriptors you’ve used?

  • Adrien C Said:

    Hi,
    Thank you for your work !
    I modified your script to install Flex Hero 4.5.0.19786, here it is : http://dl.free.fr/quqJcQBQV
    It’s not perfect, I made it quickly, but it works for me.

  • Conrad Winchester Said:

    Hi Dragos,

    I have taken your script and updated it for 4.5

    https://github.com/piercer/flex_sdk_maven_install

    People wanted to get the new molehill flex sdk deployed to a maven repository and were discussing this on the flex mojos mailing list. I pointed people to these scripts and some instructions that nearly got it working, but unfortunately Marvin Froeder banned me and removed my post. He is one wierd guy.

    Anyway I intend to build an AIR app around these scripts in order to simplify the procedure.

    Nico, the descriptors you used would be very useful – any chance you can share them or tell us how you worked out what they should be?

    Conrad Winchester

Sorry, the comment form is closed at this time.

Comments RSS Feed