Clone wiki

mockito-flex / Maven Setup

Maven Setup

Assumption is made that you have properly installed and working maven. Also, that you understand maven concepts like versioning, dependencies, plugins, repositories, etc.

Below please find a sample pom.xml that you should be able to adjust to your needs.

Couple of notes:

  • Setup with the flex mojos 4.0 and SDK 4.5 from https://repository.sonatype.org/content/groups/flexgroup/. This repository does not seem to host any newer versions, so please be carefull while chaning the SDK/flex mojos version
  • Repository http://loomis_repo.bitbucket.org/repo/ is a simple web server hosted at bitbucket, not a fully fledged nexus repository. I don't own the domain to be able to publish to maven central, thus I decided the simplest way would be to just host it on my own. There are other useful tools out there

A simple step to test below setup is to:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <name>Simple Project with Mockito testing</name> 
    <groupId>com.acme</groupId>  
    <artifactId>simplemock</artifactId>
    <packaging>swc</packaging> <!-- if you need SWF change the packaging to swf and you'll have to add Application entry point to the flex mojos plugin config -->
    <version>1.0-SNAPSHOT</version>
    <properties>
        <flex-sdk.version>4.5.1.21328</flex-sdk.version>
        <flex-mojos.version>4.0-RC2</flex-mojos.version>
    </properties>
    <build>
        <sourceDirectory>src/main/flex</sourceDirectory>
        <testSourceDirectory>src/test/flex</testSourceDirectory>
        <resources>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
        </resources>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.sonatype.flexmojos</groupId>
                <artifactId>flexmojos-maven-plugin</artifactId>
                <extensions>true</extensions>
                <version>${flex-mojos.version}</version>
                <configuration>
                    <allowSourcePathOverlap>true</allowSourcePathOverlap>
                    <sourcePaths>
                        <path>${project.build.sourceDirectory}</path>
                    </sourcePaths>
                    <configurationReport>true</configurationReport>
                    <locales>
                        <locale>en_US</locale>
                    </locales>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.adobe.flex</groupId>
                        <artifactId>compiler</artifactId>
                        <version>${flex-sdk.version}</version>
                        <type>pom</type>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.sonatype.flexmojos</groupId>
                <artifactId>flexmojos-maven-plugin</artifactId>
                <version>${flex-mojos.version}</version>

                <configuration>
                    <locales>
                        <locale>en_US</locale>
                    </locales>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>asdoc-report</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>flex-framework</artifactId>
            <version>${flex-sdk.version}</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>spark</artifactId>
            <version>${flex-sdk.version}</version>
            <type>swc</type>
            <scope>theme</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-flex</artifactId>
            <version>1.4M7</version>
            <type>swc</type>
            <scope>test</scope>
        </dependency>

        <!-- Use with SDK3 -->
        <!--
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-flex-sdk3</artifactId>
            <version>1.4M7</version>
            <type>swc</type>
            <scope>test</scope>
        </dependency>
        -->

        <dependency>
            <groupId>com.adobe.flexunit</groupId>
            <artifactId>flexunit</artifactId>
            <version>4.0-rc-1</version>
            <type>swc</type>
            <scope>test</scope>
        </dependency>


    </dependencies>
    <repositories>

        <repository>
            <id>SDK and plugins</id>
            <url>https://repository.sonatype.org/content/groups/flexgroup/</url>
        </repository>

        <repository>
            <id>Flex Unit</id>
            <url>https://oss.sonatype.org/content/repositories/releases/</url>
        </repository>

        <!-- repository with mockito and other testing tools -->
        <repository>
                        <id>flex-testing</id>
                       <url>http://loomis_repo.bitbucket.org/repo/</url>
                       <releases>
                             <enabled>true</enabled>
                       </releases>
                </repository>       
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>SDK and plugins</id>
            <url>https://repository.sonatype.org/content/groups/flexgroup/</url>
        </pluginRepository>

        <pluginRepository>
            <id>maven central</id>
            <url>http://repo1.maven.org/maven2/</url>
        </pluginRepository>

    </pluginRepositories>
</project>

Updated