Permalink
Browse files

-DenableArtemisPlugin on-off parameter.

  • Loading branch information...
1 parent 4931b20 commit a0e9c05d9adce13694b2f70e5a550fbf0f6d0a16 @junkdog committed Dec 11, 2013
View
@@ -7,6 +7,8 @@
happy after transformations. Defaults to false.
- `-DenablePooledWeaving`: Enables weaving of pooled components (more viable on
Android than JVM). Defaults to true.
+- `-DenableArtemisPlugin`: If set to false, no weaving will take place (useful
+ for debugging).
## Version: 0.5.0 - 2013-11-24
- Changed artemis to a multi-module project (the `artemis` folder is the old root).
@@ -10,6 +10,7 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
@@ -18,60 +19,73 @@
import com.artemis.meta.ClassMetadata;
/**
- * The artemis plugin does bytecode-weaving on annotated components.
+ * The artemis plugin does bytecode-weaving on annotated components
+ * and related classes.
*/
@Mojo(name="artemis", defaultPhase=PROCESS_CLASSES)
public class ArtemisMaven extends AbstractMojo {
/**
* Root folder for class files.
*/
- @Parameter(property="project.build.outputDirectory")
+ @Parameter(property="project.build.outputDirectory", readonly=true)
private File outputDirectory;
/**
* Root source folder.
*/
- @Parameter(property="project.build.sourceDirectory")
+ @Parameter(property="project.build.sourceDirectory", readonly=true)
private File sourceDirectory;
/**
* If true, will leave field stubs to keep IDE:s happy after transformations.
*/
- @Parameter
+ @Parameter(property="ideFriendlyPacking")
private boolean ideFriendlyPacking;
/**
* Enabled weaving of pooled components (more viable on Android than JVM).
*/
- @Parameter(defaultValue="true")
+ @Parameter(defaultValue="true", property="enablePooledWeaving")
private boolean enablePooledWeaving;
+ /**
+ * If false, no weaving will take place (useful for debugging).
+ */
+ @Parameter(defaultValue="true", property="enableArtemisPlugin")
+ private boolean enableArtemisPlugin;
+
@Component
private BuildContext context;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
+ if (!enableArtemisPlugin) {
+ getLog().info("Plugin disabled via 'enableArtemisPlugin' set to false.");
+ return;
+ }
+
long start = System.currentTimeMillis();
if (context != null && !context.hasDelta(sourceDirectory))
return;
- getLog().info(String.format("Configuration:\n\tideFriendlyPacking=%b \n\tenablePooledWeaving=%b ",
- ideFriendlyPacking, enablePooledWeaving));
+ Log log = getLog();
+ log.info("Configuration:");
+ log.info("\t ideFriendlyPacking=" + ideFriendlyPacking);
+ log.info("\tenablePooledWeaving=" + enablePooledWeaving);
Weaver.retainFieldsWhenPacking(ideFriendlyPacking);
Weaver.enablePooledWeaving(enablePooledWeaving);
Weaver weaver = new Weaver(outputDirectory);
List<ClassMetadata> processed = weaver.execute();
- getLog().info(getSummary(processed, start));
+ log.info(getSummary(processed, start));
}
private static CharSequence getSummary(List<ClassMetadata> processed, long start) {
int pooled = 0, packed = 0;
- for (ClassMetadata meta : processed)
- {
+ for (ClassMetadata meta : processed) {
if (PACKED == meta.annotation) packed++;
else if (POOLED == meta.annotation) pooled++;
}
@@ -41,7 +41,6 @@ public ClassReader transform() {
if (!meta.foundEntityFor)
injectForEntity();
-
// inject sizeof
Set<String> types = instanceFieldTypes(meta);
if (types.size() > 1) {

0 comments on commit a0e9c05

Please sign in to comment.