-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete import{,-test}-sources goals, and instead include source roots in classpaths for gwt:compile and gwt:test, and the new gwt:package-lib.
- Loading branch information
Showing
11 changed files
with
212 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
src/main/java/net/ltgt/gwt/maven/AbstractImportSourcesMojo.java
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
src/main/java/net/ltgt/gwt/maven/AbstractSourcesAsResourcesMojo.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
src/main/java/net/ltgt/gwt/maven/ImportTestSourcesMojo.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package net.ltgt.gwt.maven; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import org.apache.maven.archiver.MavenArchiveConfiguration; | ||
import org.apache.maven.archiver.MavenArchiver; | ||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.plugins.annotations.Component; | ||
import org.apache.maven.plugins.annotations.LifecyclePhase; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.apache.maven.project.MavenProject; | ||
import org.apache.maven.project.MavenProjectHelper; | ||
import org.codehaus.plexus.archiver.Archiver; | ||
import org.codehaus.plexus.archiver.jar.JarArchiver; | ||
|
||
/** | ||
* Package the compiled GWT library into a JAR archive. | ||
*/ | ||
@Mojo(name = "package-lib", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true) | ||
public class JarMojo extends AbstractMojo { | ||
/** | ||
* Directory containing the classes and resource files that should be packaged into the JAR. | ||
*/ | ||
@Parameter(defaultValue = "${project.build.outputDirectory}", required = true) | ||
private File classesDirectory; | ||
|
||
/** | ||
* Directory containing the generated JAR. | ||
*/ | ||
@Parameter(defaultValue = "${project.build.directory}", required = true) | ||
private File outputDirectory; | ||
|
||
/** | ||
* Name of the generated JAR. | ||
*/ | ||
@Parameter(defaultValue = "${project.build.finalName}", readonly = true) | ||
private String finalName; | ||
|
||
/** | ||
* The Jar archiver. | ||
*/ | ||
@Component(role = Archiver.class, hint = "jar" ) | ||
private JarArchiver jarArchiver; | ||
|
||
/** | ||
* The {@link {MavenProject}. | ||
*/ | ||
@Parameter(defaultValue = "${project}", readonly = true, required = true) | ||
private MavenProject project; | ||
|
||
/** | ||
* The {@link MavenSession}. | ||
*/ | ||
@Parameter(defaultValue = "${session}", readonly = true, required = true) | ||
private MavenSession session; | ||
|
||
/** | ||
* The archive configuration to use. See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven | ||
* Archiver Reference</a>. | ||
*/ | ||
@Parameter | ||
private MavenArchiveConfiguration archive = new MavenArchiveConfiguration(); | ||
|
||
@Component | ||
private MavenProjectHelper projectHelper; | ||
|
||
/** | ||
* Require the GWT plugin to build a new JAR even if none of the contents appear to have changed. By default, this | ||
* plugin looks to see if the output jar exists and inputs have not changed. If these conditions are true, the | ||
* plugin skips creation of the jar. This does not work when other plugins, like the maven-shade-plugin, are | ||
* configured to post-process the jar. This plugin can not detect the post-processing, and so leaves the | ||
* post-processed jar in place. This can lead to failures when those plugins do not expect to find their own output | ||
* as an input. Set this parameter to <tt>true</tt> to avoid these problems by forcing this plugin to recreate the | ||
* jar every time.<br/> | ||
*/ | ||
@Parameter(property = "maven.jar.forceCreation", defaultValue = "false") | ||
private boolean forceCreation; | ||
|
||
@Override | ||
public void execute() throws MojoExecutionException, MojoFailureException { | ||
File jarFile = new File(outputDirectory, finalName + ".jar"); | ||
|
||
MavenArchiver archiver = new MavenArchiver(); | ||
archiver.setArchiver(jarArchiver); | ||
archiver.setOutputFile(jarFile); | ||
|
||
archive.setForced(forceCreation); | ||
|
||
List<String> sourceRoots = SourcesAsResourcesHelper.filterSourceRoots( | ||
getLog(), project.getResources(), project.getCompileSourceRoots()); | ||
|
||
try { | ||
for (String sourceRoot : sourceRoots) { | ||
File f = new File(sourceRoot); | ||
if (f.exists()) { | ||
jarArchiver.addDirectory(f); | ||
} | ||
} | ||
|
||
if (classesDirectory.exists()) { | ||
jarArchiver.addDirectory(classesDirectory); | ||
} | ||
|
||
archiver.createArchive(session, project, archive); | ||
} catch (Exception e) { | ||
throw new MojoExecutionException("Error packaging GWT library", e); | ||
} | ||
|
||
project.getArtifact().setFile(jarFile); | ||
} | ||
} |
Oops, something went wrong.