use of org.apache.maven.plugins.ear.util.EarMavenArchiver in project maven-plugins by apache.
the class EarMavenArchiverTest method testSimpleJarModuleWithCustomBundleDir.
@Test
public void testSimpleJarModuleWithCustomBundleDir() {
final List<EarModule> modules = new ArrayList<EarModule>();
final EarModule module = new EjbModule(createArtifact("foo", "jar"));
setUri(module, "libs/foo-1.0.jar");
modules.add(module);
final EarMavenArchiver archiver = new EarMavenArchiver(modules);
assertEquals("libs/foo-1.0.jar", archiver.generateClassPathEntry(""));
}
use of org.apache.maven.plugins.ear.util.EarMavenArchiver in project maven-plugins by apache.
the class EarMavenArchiverTest method testSimpleEjbModule.
@Test
public void testSimpleEjbModule() {
final List<EarModule> modules = new ArrayList<EarModule>();
final EarModule module = new EjbModule(createArtifact("foo", "ejb"));
setUri(module, "foo-1.0.jar");
modules.add(module);
final EarMavenArchiver archiver = new EarMavenArchiver(modules);
assertEquals("foo-1.0.jar", archiver.generateClassPathEntry(""));
}
use of org.apache.maven.plugins.ear.util.EarMavenArchiver in project maven-plugins by apache.
the class EarMojo method execute.
/** {@inheritDoc} */
public void execute() throws MojoExecutionException, MojoFailureException {
// Initializes ear modules
super.execute();
zipArchiver.setUseJvmChmod(useJvmChmod);
zipUnArchiver.setUseJvmChmod(useJvmChmod);
final JavaEEVersion javaEEVersion = JavaEEVersion.getJavaEEVersion(version);
// Initializes unpack types
List<String> unpackTypesList = createUnpackList();
// Copy modules
copyModules(javaEEVersion, unpackTypesList);
// Copy source files
try {
File earSourceDir = earSourceDirectory;
if (earSourceDir.exists()) {
getLog().info("Copy ear sources to " + getWorkDirectory().getAbsolutePath());
String[] fileNames = getEarFiles(earSourceDir);
for (String fileName : fileNames) {
copyFile(new File(earSourceDir, fileName), new File(getWorkDirectory(), fileName));
}
}
if (applicationXml != null && !"".equals(applicationXml)) {
// rename to application.xml
getLog().info("Including custom application.xml[" + applicationXml + "]");
File metaInfDir = new File(getWorkDirectory(), META_INF);
copyFile(new File(applicationXml), new File(metaInfDir, "/application.xml"));
}
} catch (IOException e) {
throw new MojoExecutionException("Error copying EAR sources", e);
} catch (MavenFilteringException e) {
throw new MojoExecutionException("Error filtering EAR sources", e);
}
// Check if deployment descriptor is there
File ddFile = new File(getWorkDirectory(), APPLICATION_XML_URI);
if (!ddFile.exists() && (javaEEVersion.lt(JavaEEVersion.FIVE))) {
// CHECKSTYLE_OFF: LineLength
throw new MojoExecutionException("Deployment descriptor: " + ddFile.getAbsolutePath() + " does not exist.");
// CHECKSTYLE_ON: LineLength
}
try {
File earFile = getEarFile(outputDirectory, finalName, classifier);
final MavenArchiver archiver = new EarMavenArchiver(getModules());
final JarArchiver theJarArchiver = getJarArchiver();
getLog().debug("Jar archiver implementation [" + theJarArchiver.getClass().getName() + "]");
archiver.setArchiver(theJarArchiver);
archiver.setOutputFile(earFile);
getLog().debug("Excluding " + Arrays.asList(getPackagingExcludes()) + " from the generated EAR.");
getLog().debug("Including " + Arrays.asList(getPackagingIncludes()) + " in the generated EAR.");
archiver.getArchiver().addDirectory(getWorkDirectory(), getPackagingIncludes(), getPackagingExcludes());
archiver.createArchive(session, getProject(), archive);
if (classifier != null) {
projectHelper.attachArtifact(getProject(), "ear", classifier, earFile);
} else {
getProject().getArtifact().setFile(earFile);
}
} catch (Exception e) {
throw new MojoExecutionException("Error assembling EAR", e);
}
}
use of org.apache.maven.plugins.ear.util.EarMavenArchiver in project maven-plugins by apache.
the class EarMavenArchiverTest method testTwoModules.
@Test
public void testTwoModules() {
final List<EarModule> modules = new ArrayList<EarModule>();
final EarModule module = new EjbModule(createArtifact("foo", "ejb"));
setUri(module, "foo-1.0.jar");
modules.add(module);
final EarModule module2 = new EjbModule(createArtifact("bar", "war"));
setUri(module2, "bar-2.0.1.war");
modules.add(module2);
final EarMavenArchiver archiver = new EarMavenArchiver(modules);
assertEquals("foo-1.0.jar bar-2.0.1.war", archiver.generateClassPathEntry(""));
}
Aggregations