Skip to content
Permalink
Browse files
- Added the remaining mojos to the default maven lifecycle
- Extended the Compiler interface to provide a reference to the MavenProject in the compile method.

git-svn-id: https://svn.apache.org/repos/asf/incubator/flex/utilities/trunk@1416190 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
chrisdutz committed Dec 2, 2012
1 parent 158861a commit 4d038d395e0fee67ec45176b20165260bb49f39c
Show file tree
Hide file tree
Showing 21 changed files with 116 additions and 81 deletions.
@@ -36,4 +36,11 @@

<name>Maven-Flex-Plugin / Components / API</name>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
</dependency>
</dependencies>

</project>
@@ -16,6 +16,8 @@
*/
package org.apache.flex.maven.plugins.flex.compiler;

import org.apache.maven.project.MavenProject;

/**
* Created with IntelliJ IDEA.
* User: cdutz
@@ -24,6 +26,6 @@
*/
public interface Compiler {

void compile();
void compile(MavenProject project);

}
@@ -63,12 +63,10 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
@@ -17,6 +17,7 @@
package org.apache.flex.maven.plugins.flex.compiler.asdoc;

import org.apache.flex.maven.plugins.flex.compiler.Compiler;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;

/**
@@ -28,13 +29,9 @@
@Component(role = Compiler.class, hint = "asdoc")
public class AsdocCompilerImpl implements Compiler {

public AsdocCompilerImpl() {
System.out.println("Compiler Instance Created: Asdoc");
}

@Override
public void compile() {
System.out.println("Executing Compiler: Asdoc");
public void compile(MavenProject project) {
System.out.println("Executing compile: Asdoc");
}

}
@@ -63,12 +63,10 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
@@ -17,6 +17,7 @@
package org.apache.flex.maven.plugins.flex.compiler.compc;

import org.apache.flex.maven.plugins.flex.compiler.Compiler;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;

/**
@@ -28,13 +29,9 @@
@Component(role = Compiler.class, hint = "compc")
public class CompcCompilerImpl implements Compiler {

public CompcCompilerImpl() {
System.out.println("Compiler Instance Created: Compc");
}

@Override
public void compile() {
System.out.println("Executing Compiler: Compc");
public void compile(MavenProject project) {
System.out.println("Executing compile: Compc");
}

}
@@ -63,12 +63,10 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
@@ -17,6 +17,7 @@
package org.apache.flex.maven.plugins.flex.compiler.falcon;

import org.apache.flex.maven.plugins.flex.compiler.Compiler;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;

/**
@@ -28,13 +29,9 @@
@Component(role = Compiler.class, hint = "falcon")
public class FalconCompilerImpl implements Compiler {

public FalconCompilerImpl() {
System.out.println("Compiler Instance Created: Falcon");
}

@Override
public void compile() {
System.out.println("Executing Compiler: Falcon");
public void compile(MavenProject project) {
System.out.println("Executing compile: Falcon");
}

}
@@ -63,12 +63,10 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
@@ -17,6 +17,7 @@
package org.apache.flex.maven.plugins.flex.compiler.mxmlc;

import org.apache.flex.maven.plugins.flex.compiler.Compiler;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;

/**
@@ -28,13 +29,9 @@
@Component(role = Compiler.class, hint = "mxmlc")
public class MxmlcCompilerImpl implements Compiler {

public MxmlcCompilerImpl() {
System.out.println("Compiler Instance Created: MXMLC");
}

@Override
public void compile() {
System.out.println("Executing Compiler: MXMLC");
public void compile(MavenProject project) {
System.out.println("Executing compile: MXMLC");
}

}
@@ -64,17 +64,14 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -17,12 +17,10 @@
package org.apache.flex.maven.plugins.flex.compiler;

import org.apache.flex.maven.plugins.flex.AbstractFlexMojo;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.*;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;

import java.util.Map;

@@ -44,36 +42,27 @@ public class CompilerMojo extends AbstractFlexMojo {
@Component
protected Map<String, Compiler> compilerMap;

@Component
protected MavenSession session;

@Component
protected MavenProject project;

@Component
protected MojoExecution mojoEcecution;

@Component
protected PluginDescriptor plugin;

@Component
protected Settings settings;

public void execute() {
if(mojoEcecution.getLifecyclePhase().equals(LifecyclePhase.COMPILE.id())) {
if(useLegacyCompiler) {
if(project.getPackaging().equalsIgnoreCase("SWC")) {
compilerMap.get("compc").compile();
compilerMap.get("compc").compile(project);
} else if(project.getPackaging().equalsIgnoreCase("SWF")) {
compilerMap.get("mxmlc").compile();
compilerMap.get("mxmlc").compile(project);
} else {
throw new RuntimeException("Wrong packaging");
}
} else {
compilerMap.get("falcon").compile();
compilerMap.get("falcon").compile(project);
}
} else if(mojoEcecution.getLifecyclePhase().equals(LifecyclePhase.PROCESS_SOURCES.id())) {
compilerMap.get("asdoc").compile();
compilerMap.get("asdoc").compile(project);
}
}

@@ -32,7 +32,7 @@
public class GeneratorMojo extends AbstractFlexMojo {

public void execute() {
getLog().debug("Executing generator-mojo");
getLog().debug("Executing generate");
}

}
@@ -32,7 +32,7 @@
public class OptimizerMojo extends AbstractFlexMojo {

public void execute() {
getLog().debug("Executing optimizer-mojo");
getLog().debug("Executing optimize");
}

}
@@ -32,7 +32,7 @@
public class PackagerMojo extends AbstractFlexMojo {

public void execute() {
getLog().debug("Executing packager-mojo");
getLog().debug("Executing package");
}

}
@@ -31,19 +31,19 @@
defaultPhase = LifecyclePhase.TEST_COMPILE,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true)
public class TestCompileMojo extends CompilerMojo {
public class TestCompilerMojo extends CompilerMojo {

public void execute() {
if (useLegacyCompiler) {
if (project.getPackaging().equalsIgnoreCase("SWC")) {
compilerMap.get("compc").compile();
compilerMap.get("compc").compile(project);
} else if (project.getPackaging().equalsIgnoreCase("SWF")) {
compilerMap.get("mxmlc").compile();
compilerMap.get("mxmlc").compile(project);
} else {
throw new RuntimeException("Wrong packaging");
}
} else {
compilerMap.get("falcon").compile();
compilerMap.get("falcon").compile(project);
}
}

@@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.flex.maven.plugins.flex.test;

import org.apache.flex.maven.plugins.flex.compiler.CompilerMojo;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;

/**
* Created with IntelliJ IDEA.
* User: cdutz
* Date: 01.12.12
* Time: 17:48
*/
@Mojo(name = "test-generate",
defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true)
public class TestGeneratorMojo extends CompilerMojo {

public void execute() {
getLog().debug("Executing test-generate");
}

}
@@ -32,7 +32,7 @@
public class TestRunnerMojo extends AbstractFlexMojo {

public void execute() {
getLog().debug("Executing test-mojo");
getLog().debug("Executing test");
}

}

0 comments on commit 4d038d3

Please sign in to comment.