Skip to content

Commit

Permalink
unwoven test classes are now copied under unwovenClassesDir + -test
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Jun 16, 2016
1 parent d964718 commit 93d3567
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/main/java/com/jcabi/maven/plugin/AjcMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
Expand Down Expand Up @@ -108,6 +109,12 @@ public final class AjcMojo extends AbstractMojo implements Contextualizable {
@Component
private transient MavenProject project;

/**
* Maven execution.
*/
@Component
private transient MojoExecution execution;

/**
* Maven session.
*/
Expand Down Expand Up @@ -536,12 +543,27 @@ private static Collection<File> files(final File dir) {
*/
private void copyUnwovenClasses()
throws MojoFailureException {
this.unwovenClassesDir.mkdirs();
Logger.info(
this, "Unwoven classes will be copied to %s",
this.unwovenClassesDir
);
if (this.hasClasses()) {
final String phase = this.execution.getLifecyclePhase();
if ("process-classes".equals(phase)) {
this.unwovenClassesDir.mkdirs();
Logger.info(
this, "Unwoven classes will be copied to %s",
this.unwovenClassesDir
);
} else if ("process-test-classes".equals(phase)) {
final String testsuf = "-test";
final StringBuilder fpb = new StringBuilder();
fpb.append(this.unwovenClassesDir.getPath()).append(testsuf);
this.unwovenClassesDir = new File(fpb.toString());
this.unwovenClassesDir.mkdirs();
Logger.info(
this, "Unwoven test classes will be copied to %s",
this.unwovenClassesDir
);
} else {
return;
}
try {
this.copyClasses(this.unwovenClassesDir);
} catch (final IOException ex) {
Expand Down

0 comments on commit 93d3567

Please sign in to comment.