added war filtering support
This commit is contained in:
parent
a6d993348c
commit
21c03c0f8a
@ -110,7 +110,6 @@ You can also use the plugin configuration to define standard `resources`. You w
|
||||
</plugin>
|
||||
```
|
||||
|
||||
> Currently supported `resource` configuration elements: `directory` and `targetPath`
|
||||
> `maven.war.skip` does not work in the default `maven-war-plugin` version.
|
||||
|
||||
### Wildfly Enterprise Application Deployment
|
||||
|
5
pom.xml
5
pom.xml
@ -52,6 +52,11 @@
|
||||
<version>${maven.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.shared</groupId>
|
||||
<artifactId>maven-filtering</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
<artifactId>maven-plugin-annotations</artifactId>
|
||||
|
@ -18,6 +18,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@ -28,7 +29,11 @@ import org.apache.maven.plugin.MojoExecutionException;
|
||||
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.shared.filtering.MavenFilteringException;
|
||||
import org.apache.maven.shared.filtering.MavenResourcesExecution;
|
||||
import org.apache.maven.shared.filtering.MavenResourcesFiltering;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.eclipse.aether.graph.Dependency;
|
||||
import org.eclipse.aether.graph.DependencyFilter;
|
||||
@ -52,6 +57,9 @@ public class WarGoal extends AbstractDeploymentGoal {
|
||||
@Parameter
|
||||
protected List<Resource> resources;
|
||||
|
||||
@Requirement
|
||||
private MavenResourcesFiltering filterer;
|
||||
|
||||
private DeploymentXmlBuilder deploymentXmlBuilder;
|
||||
private File webinfDirectory;
|
||||
private File libDirectory;
|
||||
@ -124,15 +132,21 @@ public class WarGoal extends AbstractDeploymentGoal {
|
||||
}
|
||||
|
||||
if (this.resources != null) {
|
||||
for (Resource resource : this.resources) {
|
||||
File sourceDirectory = new File(resource.getDirectory());
|
||||
File outputDirectory = resource.getTargetPath() == null ? this.outputDirectory : new File(this.outputDirectory, resource.getTargetPath());
|
||||
FileUtils.copyDirectoryStructure(sourceDirectory, outputDirectory);
|
||||
}
|
||||
MavenResourcesExecution execution = new MavenResourcesExecution(
|
||||
this.resources,
|
||||
this.outputDirectory,
|
||||
this.project,
|
||||
"utf-8",
|
||||
Collections.emptyList(),
|
||||
this.filterer.getDefaultNonFilteredFileExtensions(),
|
||||
this.session);
|
||||
this.filterer.filterResources(execution);
|
||||
}
|
||||
|
||||
if (this.webappDirectory.exists())
|
||||
FileUtils.copyDirectoryStructure(this.webappDirectory, this.outputDirectory);
|
||||
} catch (MavenFilteringException mfe) {
|
||||
throw new MojoExecutionException("A filtering issue occurred", mfe);
|
||||
} catch (IOException ie) {
|
||||
throw new MojoExecutionException("An I/O issue occurred", ie);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user