diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-06-24 13:49:56 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-06-24 13:49:56 +0200 |
commit | 9ef4dd059567e7ba2108e50fd0c851178982006c (patch) | |
tree | b9cbd8c9a63a0ed4df47b904f94f6118c8e4d5ed /bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/AssembleTestBundleMojo.java | |
parent | 1f1876624de0ca909a366fa16db97a34a686ae42 (diff) |
Implement goal for assembling test bundles
Introduce an abstract class containing behaviour that is shared with
existing bundle assemble goal.
Add abstract
Diffstat (limited to 'bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/AssembleTestBundleMojo.java')
-rw-r--r-- | bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/AssembleTestBundleMojo.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/AssembleTestBundleMojo.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/AssembleTestBundleMojo.java new file mode 100644 index 00000000000..ab827275f53 --- /dev/null +++ b/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/AssembleTestBundleMojo.java @@ -0,0 +1,38 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.container.plugin.mojo; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.codehaus.plexus.archiver.jar.JarArchiver; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import static com.yahoo.container.plugin.mojo.TestBundleUtils.archiveFile; +import static com.yahoo.container.plugin.mojo.TestBundleUtils.manifestFile; + +/** + * @author bjorncs + */ +@Mojo(name = "assemble-test-bundle", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) +public class AssembleTestBundleMojo extends AbstractAssembleBundleMojo { + + @Parameter + private String testProvidedArtifacts; + + @Override + public void execute() throws MojoExecutionException { + Artifacts.ArtifactSet artifacts = Artifacts.getArtifacts(project, true, testProvidedArtifacts); + JarArchiver archiver = new JarArchiver(); + addDirectory(archiver, Paths.get(project.getBuild().getOutputDirectory())); + addDirectory(archiver, Paths.get(project.getBuild().getTestOutputDirectory())); + addArtifacts(archiver, artifacts.getJarArtifactsToInclude()); + Path archiveFile = archiveFile(project); + createArchive(archiver, archiveFile, manifestFile(project)); + project.getArtifact().setFile(archiveFile.toFile()); + } + + +} |