Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/it/skinny-wars-javaee5/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ String[] includedEntries = {
"META-INF/MANIFEST.MF"
};

String[] warModule1ExpectedClassPathElements = { "lib/commons-lang-commons-lang-2.6.jar" };
String[] warModule1ExpectedClassPathElements = { "commons-lang-2.6.jar" };

assertJar( earBaseDir + "org.apache.maven.its.ear.skinnywars-war-module1-1.0.war", includedEntries,
warModuleExcludedEntries, true, warModule1ExpectedClassPathElements );
Expand Down
72 changes: 33 additions & 39 deletions src/main/java/org/apache/maven/plugins/ear/EarMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
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());

Check warning on line 381 in src/main/java/org/apache/maven/plugins/ear/EarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-17-zulu 3.10.0-rc-1

addDirectory(java.io.File,java.lang.String[],java.lang.String[]) in org.codehaus.plexus.archiver.AbstractArchiver has been deprecated

Check warning on line 381 in src/main/java/org/apache/maven/plugins/ear/EarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-17-zulu 3.10.0-rc-1

addDirectory(java.io.File,java.lang.String[],java.lang.String[]) in org.codehaus.plexus.archiver.AbstractArchiver has been deprecated

archiver.createArchive(session, getProject(), archive);
} catch (ManifestException | IOException | DependencyResolutionRequiredException e) {
Expand All @@ -386,7 +386,7 @@
}

if (classifier != null) {
projectHelper.attachArtifact(getProject(), "ear", classifier, earFile);

Check warning on line 389 in src/main/java/org/apache/maven/plugins/ear/EarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-17-zulu 3.10.0-rc-1

addDirectory(java.io.File,java.lang.String[],java.lang.String[]) in org.codehaus.plexus.archiver.AbstractArchiver has been deprecated
} else {
getProject().getArtifact().setFile(earFile);
}
Expand Down Expand Up @@ -620,7 +620,7 @@
throws MavenFilteringException, IOException, MojoExecutionException {
createParentIfNecessary(target);
if (filtering && !isNonFilteredExtension(source.getName())) {
mavenFileFilter.copyFile(source, target, true, getFilterWrappers(), encoding);

Check warning on line 623 in src/main/java/org/apache/maven/plugins/ear/EarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-17-zulu 3.10.0-rc-1

copyFile(java.io.File,java.io.File,boolean,java.util.List<org.apache.maven.shared.filtering.FilterWrapper>,java.lang.String) in org.apache.maven.shared.filtering.MavenFileFilter has been deprecated

Check warning on line 623 in src/main/java/org/apache/maven/plugins/ear/EarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-17-zulu 3.10.0-rc-1

copyFile(java.io.File,java.io.File,boolean,java.util.List<org.apache.maven.shared.filtering.FilterWrapper>,java.lang.String) in org.apache.maven.shared.filtering.MavenFileFilter has been deprecated
} else {
Files.copy(
source.toPath(), target.toPath(), LinkOption.NOFOLLOW_LINKS, StandardCopyOption.REPLACE_EXISTING);
Expand All @@ -628,7 +628,7 @@
}

private void createParentIfNecessary(File target) throws IOException {
// Silly that we have to do this ourselves

Check warning on line 631 in src/main/java/org/apache/maven/plugins/ear/EarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-17-zulu 3.10.0-rc-1

copyFile(java.io.File,java.io.File,boolean,java.util.List<org.apache.maven.shared.filtering.FilterWrapper>,java.lang.String) in org.apache.maven.shared.filtering.MavenFileFilter has been deprecated
File parentDirectory = target.getParentFile();
if (parentDirectory != null && !parentDirectory.exists()) {
Files.createDirectories(parentDirectory.toPath());
Expand Down Expand Up @@ -665,7 +665,7 @@
EarModule module, File original, JavaEEVersion javaEEVersion, Collection<String> outdatedResources)
throws MojoFailureException {
final String moduleLibDir = module.getLibDir();
if (!((moduleLibDir == null) || skinnyModules || (skinnyWars && module instanceof WebModule))) {
if (!(skinnyModules || (skinnyWars && (module instanceof WebModule || moduleLibDir == null)))) {
return;
}

Expand Down Expand Up @@ -713,12 +713,9 @@
Attribute classPath = mf.getMainSection().getAttribute("Class-Path");
List<String> classPathElements = new ArrayList<>();

boolean classPathExists;
if (classPath != null) {
classPathExists = true;
classPathElements.addAll(Arrays.asList(classPath.getValue().split(" ")));
} else {
classPathExists = false;
classPath = new Attribute("Class-Path", "");
}

Expand Down Expand Up @@ -776,50 +773,47 @@
}

// Modify the classpath entries in the manifest
final boolean forceClassPathModification =
javaEEVersion.lt(JavaEEVersion.FIVE) || defaultLibBundleDir == null;
final boolean classPathExtension = !skipClassPathModification || forceClassPathModification;
for (EarModule otherModule : getModules()) {
if (module.equals(otherModule)) {
continue;
}
final int moduleClassPathIndex = findModuleInClassPathElements(classPathElements, otherModule);
if (moduleClassPathIndex != -1) {
if (otherModule.isClassPathItem()) {
classPathElements.set(moduleClassPathIndex, otherModule.getUri());
} else {
classPathElements.remove(moduleClassPathIndex);
if (!skipClassPathModification) {
for (EarModule otherModule : getModules()) {
if (module.equals(otherModule)) {
continue;
}
final int moduleClassPathIndex = findModuleInClassPathElements(classPathElements, otherModule);
if (moduleClassPathIndex != -1) {
if (otherModule.isClassPathItem()) {
classPathElements.set(moduleClassPathIndex, otherModule.getUri());
} else {
classPathElements.remove(moduleClassPathIndex);
}
} else if (otherModule.isClassPathItem()) {
classPathElements.add(otherModule.getUri());
}
} else if (otherModule.isClassPathItem() && classPathExtension) {
classPathElements.add(otherModule.getUri());
}
}

// Remove provided modules from classpath
for (EarModule otherModule : getProvidedEarModules()) {
final int moduleClassPathIndex = findModuleInClassPathElements(classPathElements, otherModule);
if (moduleClassPathIndex != -1) {
classPathElements.remove(moduleClassPathIndex);
// Remove provided modules from classpath
for (EarModule otherModule : getProvidedEarModules()) {
final int moduleClassPathIndex = findModuleInClassPathElements(classPathElements, otherModule);
if (moduleClassPathIndex != -1) {
classPathElements.remove(moduleClassPathIndex);
}
}
}

if (!skipClassPathModification || !classPathElements.isEmpty() || classPathExists) {
classPath.setValue(StringUtils.join(classPathElements.iterator(), " "));
mf.getMainSection().addConfiguredAttribute(classPath);
Comment on lines +776 to 802
}

// Write the manifest to disk, preserve timestamp
FileTime lastModifiedTime = Files.getLastModifiedTime(manifestFile);
try (BufferedWriter writer = Files.newBufferedWriter(
manifestFile,
StandardCharsets.UTF_8,
StandardOpenOption.WRITE,
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING)) {
mf.write(writer);
}
Files.setLastModifiedTime(manifestFile, lastModifiedTime);
removeFromOutdatedResources(manifestFile, outdatedResources);
// Write the manifest to disk, preserve timestamp
FileTime lastModifiedTime = Files.getLastModifiedTime(manifestFile);
try (BufferedWriter writer = Files.newBufferedWriter(
manifestFile,
StandardCharsets.UTF_8,
StandardOpenOption.WRITE,
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING)) {
mf.write(writer);
}
Files.setLastModifiedTime(manifestFile, lastModifiedTime);
removeFromOutdatedResources(manifestFile, outdatedResources);

if (fileSystem != null) {
fileSystem.close();
Expand Down
11 changes: 7 additions & 4 deletions src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,8 @@ void testProject089() throws Exception {
void testProject090() throws Exception {
final String warModule = "eartest-war-sample-three-1.0.war";
final String ejbModule = "eartest-ejb-sample-three-1.0.jar";
final String jarSampleTwo = "jar-sample-two-1.0.jar";
final String jarSampleThreeWithDeps = "jar-sample-three-with-deps-1.0.jar";
final String jarSampleTwoLibrary = "lib/eartest-jar-sample-two-1.0.jar";
final String jarSampleThreeLibrary = "lib/eartest-jar-sample-three-with-deps-1.0.jar";
doTestProject(
Expand All @@ -960,7 +962,7 @@ void testProject090() throws Exception {
new boolean[] {false, false, false, false},
new String[] {warModule, ejbModule},
new boolean[] {false, false},
new String[][] {{jarSampleTwoLibrary}, {jarSampleThreeLibrary, jarSampleTwoLibrary}},
new String[][] {{jarSampleTwo}, {jarSampleThreeWithDeps, jarSampleTwo}},
true);
}

Expand All @@ -976,6 +978,8 @@ void testProject090() throws Exception {
void testProject091() throws Exception {
final String warModule = "eartest-war-sample-three-1.0.war";
final String ejbModule = "eartest-ejb-sample-three-1.0.jar";
final String jarSampleTwo = "jar-sample-two-1.0.jar";
final String jarSampleThreeWithDeps = "jar-sample-three-with-deps-1.0.jar";
final String jarSampleTwoLibrary = "eartest-jar-sample-two-1.0.jar";
final String jarSampleThreeLibrary = "eartest-jar-sample-three-with-deps-1.0.jar";
doTestProject(
Expand All @@ -985,7 +989,7 @@ void testProject091() throws Exception {
new boolean[] {false, true, false, false},
new String[] {warModule, ejbModule},
new boolean[] {false, true},
new String[][] {{"jar-sample-two-1.0.jar"}, {jarSampleThreeLibrary, jarSampleTwoLibrary}},
new String[][] {{jarSampleTwo}, {jarSampleThreeWithDeps, jarSampleTwo}},
true);
}

Expand Down Expand Up @@ -1211,8 +1215,7 @@ void testProject094() throws Exception {
new boolean[] {false, false, false, false, false, false, false},
earModules,
earModuleDirectory,
new String[][] {null, null, null, null, new String[] {jarSampleThreeEarLibrary, jarSampleTwoEarLibrary}
},
new String[][] {null, null, null, null, new String[] {jarSampleThreeLibrary, jarSampleTwoLibrary}},
true);

assertEarModulesContent(
Expand Down
Loading