Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Split asdoc and coverage reports into their own package and introduce…
Browse files Browse the repository at this point in the history
…d some code reuse
  • Loading branch information
velo committed Oct 3, 2010
1 parent 7dd78d2 commit 3e22a7a
Show file tree
Hide file tree
Showing 38 changed files with 382 additions and 209 deletions.
Expand Up @@ -38,7 +38,6 @@

import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.granite.generator.Generator;
import org.granite.generator.Output;
import org.granite.generator.TemplateUri;
Expand Down
Expand Up @@ -8,7 +8,6 @@
import java.util.List;
import java.util.Map;

import org.apache.ws.jaxme.js.JavaMethod;
import org.apache.ws.jaxme.js.JavaQName;
import org.apache.ws.jaxme.js.JavaQNameImpl;
import org.apache.ws.jaxme.js.JavaSource;
Expand Down Expand Up @@ -183,7 +182,7 @@ else if ( args < 0 )
type = JavaQNameImpl.getArray( type );
}

JavaMethod nm = js.newJavaMethod( GET_PREFIX + name, type );
/*JavaMethod nm =*/ js.newJavaMethod( GET_PREFIX + name, type );
}
}
}
Expand Down
Expand Up @@ -65,7 +65,7 @@ public void generate( GenerationRequest request )
}
}

@SuppressWarnings( { "unchecked", "deprecation" } )
@SuppressWarnings( "deprecation" )
private void editMxmlc( File mxmlcJar, File destination )
throws IOException, TargetLostException
{
Expand All @@ -83,7 +83,7 @@ private void editMxmlc( File mxmlcJar, File destination )

MethodGen mg = new MethodGen( method, jc.getClassName(), p );
InstructionList il = mg.getInstructionList();
for ( Iterator it = il.iterator(); it.hasNext(); )
for ( Iterator<?> it = il.iterator(); it.hasNext(); )
{
InstructionHandle ih = (InstructionHandle) it.next();
Instruction inst = ih.getInstruction();
Expand Down
@@ -1,4 +1,3 @@
import java.io.IOException;
import java.io.InputStream;

import org.apache.bcel.classfile.ClassParser;
Expand Down
Expand Up @@ -399,7 +399,6 @@ private ClassLoader initializeClassLoader()
}
}

@SuppressWarnings( "unchecked" )
private List<String> getClasspath()
throws MojoExecutionException
{
Expand Down
@@ -1,6 +1,7 @@
package org.sonatype.flexmojos.plugin;

import static ch.lambdaj.Lambda.*;
import static ch.lambdaj.Lambda.filter;
import static ch.lambdaj.Lambda.selectFirst;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.sonatype.flexmojos.matcher.artifact.ArtifactMatcher.artifactId;
Expand Down Expand Up @@ -50,6 +51,7 @@
import org.sonatype.flexmojos.plugin.common.flexbridge.MavenPathResolver;
import org.sonatype.flexmojos.plugin.compiler.attributes.MavenRuntimeException;
import org.sonatype.flexmojos.plugin.compiler.lazyload.Cacheable;
import org.sonatype.flexmojos.plugin.compiler.lazyload.NotCacheable;
import org.sonatype.flexmojos.util.PathUtil;

import flex2.compiler.Logger;
Expand Down Expand Up @@ -344,6 +346,7 @@ protected File getBasedir()
return basedir;
}

@NotCacheable
public Map<String, Object> getCache()
{
return cache;
Expand Down Expand Up @@ -407,6 +410,7 @@ public boolean getIsAirProject()
return getDependency( groupId( FRAMEWORK_GROUP_ID ), artifactId( AIR_GLOBAL ), type( SWC ) ) != null;
}

@NotCacheable
public Log getLog()
{
return this.log;
Expand Down
@@ -0,0 +1,10 @@
package org.sonatype.flexmojos.plugin;

import java.io.File;

public interface SourcePathAware
{

File[] getSourcePath();

}
Expand Up @@ -39,7 +39,7 @@ public interface FlexExtension
String SWF = "swf";

String SWZ = "swz";

String TAR_GZ = "tar.gz";

String XML = "xml";
Expand Down
Expand Up @@ -13,7 +13,6 @@
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import org.apache.maven.artifact.Artifact;
Expand All @@ -23,13 +22,8 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.doxia.sink.Sink;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import org.hamcrest.Matcher;
import org.sonatype.flexmojos.compatibilitykit.FlexCompatibility;
import org.sonatype.flexmojos.compiler.IASDocConfiguration;
Expand Down Expand Up @@ -57,28 +51,9 @@
*/
public class AsdocMojo
extends AbstractFlexCompilerMojo<IASDocConfiguration, AsdocMojo>
implements IASDocConfiguration, IPackagesConfiguration, Mojo, MavenReport
implements IASDocConfiguration, IPackagesConfiguration, Mojo
{

private static String getFileExtention( File file )
{
String path = file.getAbsolutePath();

String archiveExt = FileUtils.getExtension( path ).toLowerCase();

if ( "gz".equals( archiveExt ) || "bz2".equals( archiveExt ) )
{
String[] tokens = StringUtils.split( path, "." );

if ( tokens.length > 2 && "tar".equals( tokens[tokens.length - 2].toLowerCase() ) )
{
archiveExt = "tar." + archiveExt;
}
}

return archiveExt;
}

/**
* If true, will treat multi-modules projects as only one project otherwise will generate Asdoc per project
*
Expand All @@ -87,13 +62,11 @@ private static String getFileExtention( File file )
private boolean aggregate;

/**
* Specifies the destination directory where asdoc saves the generated HTML files.
*
* @parameter expression="${project.reporting.outputDirectory}/asdoc"
* @parameter expression="${project.build.directory}/asdoc"
* @readonly
* @required
*/
protected File asdocOutputDirectory;
private File asdocOutputDirectory;

/**
* If true, bundles the asdoc documentation for main code into a zip using the standard Asdoc Tool.
Expand All @@ -112,13 +85,6 @@ private static String getFileExtention( File file )
*/
private Boolean dateInFooter;

/**
* The description of the AsDoc report.
*
* @parameter expression="${flex.description}" default-value="ASDoc API documentation."
*/
private String description;

/**
* Automatically document all declared namespaces
*
Expand Down Expand Up @@ -275,13 +241,6 @@ private static String getFileExtention( File file )
*/
private String mainTitle;

/**
* The name of the AsDoc report.
*
* @parameter expression="${flex.name}" default-value="ASDocs"
*/
private String name;

/**
* The filename of bundled asdoc
*
Expand Down Expand Up @@ -342,12 +301,7 @@ private void attachAsdoc()
archiver.setDestFile( output );
archiver.createArchive();

projectHelper.attachArtifact( project, getFileExtention( output ), "asdoc", output );
}

public boolean canGenerateReport()
{
return PathUtil.existAny( getSourcePath() );
projectHelper.attachArtifact( project, PathUtil.getFileExtention( output ), "asdoc", output );
}

@Override
Expand Down Expand Up @@ -386,43 +340,11 @@ public void execute()
}
}

public void generate( Sink sink, Locale locale )
throws MavenReportException
{
// Not really sure why this class loader switching
// is necessary. But it is.
Thread currentThread = Thread.currentThread();
ClassLoader savedCL = currentThread.getContextClassLoader();
try
{
currentThread.setContextClassLoader( getClass().getClassLoader() );
execute();
}
catch ( Exception e )
{
throw new MavenReportException( "Unable to generate report", e );
}
finally
{
currentThread.setContextClassLoader( savedCL );
}
}

public String getCategoryName()
{
return CATEGORY_PROJECT_REPORTS;
}

public Boolean getDateInFooter()
{
return dateInFooter;
}

public String getDescription( Locale locale )
{
return description;
}

public List<String> getDocClasses()
{
if ( docClasses == null )
Expand Down Expand Up @@ -574,22 +496,12 @@ public String getMainTitle()
return mainTitle;
}

public String getName( Locale locale )
{
return name;
}

public String getOutput()
{
asdocOutputDirectory.mkdirs();
return PathUtil.getPath( asdocOutputDirectory );
}

public String getOutputName()
{
return "asdoc/index";
}

public String[] getPackage()
{
// TODO Auto-generated method stub
Expand All @@ -607,11 +519,6 @@ public IPackagesConfiguration getPackagesConfiguration()
return this;
}

public File getReportOutputDirectory()
{
return asdocOutputDirectory;
}

public Boolean getRestoreBuiltinClasses()
{
return restoreBuiltinClasses;
Expand Down Expand Up @@ -681,11 +588,6 @@ public String getWindowTitle()
return windowTitle;
}

public boolean isExternalReport()
{
return true;
}

@FlexCompatibility( maxVersion = "4.0.0.3127" )
private void makeAsdocExecutable( File templateOutput )
{
Expand Down Expand Up @@ -714,7 +616,4 @@ private void makeAsdocExecutable( File templateOutput )
}
}

public void setReportOutputDirectory( File outputDirectory )
{
}
}
Expand Up @@ -86,7 +86,6 @@ public void execute()

wait( executeCompiler( this, true ) );


ZipOutputStream out = null;
try
{
Expand Down
@@ -1,6 +1,5 @@
package org.sonatype.flexmojos.plugin.compiler;

import static org.sonatype.flexmojos.plugin.common.FlexExtension.AIR;
import static org.sonatype.flexmojos.plugin.common.FlexExtension.SWF;

import java.io.File;
Expand Down
Expand Up @@ -5,6 +5,7 @@
public interface Cacheable
{

@NotCacheable
public Map<String, Object> getCache();

}
Expand Up @@ -24,8 +24,7 @@ public aspect LazyLoadAspect

pointcut getters() :
target (AbstractMavenMojo) && ( execution( * get*() ) &&
!execution( * getLog() ) &&
!execution( * getCache() ) );
!execution(@NotCacheable * *() ) );

Object around() : getters() {
Map<String, Object> cachedValues = ( (AbstractMavenMojo) thisJoinPoint.getTarget() ).getCache();
Expand Down
@@ -0,0 +1,13 @@
package org.sonatype.flexmojos.plugin.compiler.lazyload;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.METHOD )
public @interface NotCacheable
{

}
Expand Up @@ -212,8 +212,7 @@ public String[] getKeepAs3Metadata()

public String[] getLoadConfig()
{
return PathUtil.getPaths( ConfigurationResolver.resolveConfiguration( loadConfigs, loadConfig,
configDirectory ) );
return PathUtil.getPaths( ConfigurationResolver.resolveConfiguration( loadConfigs, loadConfig, configDirectory ) );
}

public IOptimizerConfiguration getOptimizerConfiguration( File input, File output )
Expand Down

0 comments on commit 3e22a7a

Please sign in to comment.