Skip to content

Commit b9e0df2

Browse files
committed
Merge remote-tracking branch 'apache/main' into feature/main/2229_mongodb_docker
2 parents bd9042c + 354e779 commit b9e0df2

File tree

8 files changed

+90
-6
lines changed

8 files changed

+90
-6
lines changed

log4j-core/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
java.xml;transitive=false,
6767
jdk.unsupported;transitive=false,
6868
org.fusesource.jansi;transitive=false,
69+
org.jspecify;transitive=false
6970
</bnd-extra-module-options>
7071

7172
<log4j.docgen.pluginDescriptorsDir>${log4j.docgen.pluginDescriptorsDir.phase1}</log4j.docgen.pluginDescriptorsDir>

log4j-jul/pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@
2929
<description>The Apache Log4j implementation of java.util.logging</description>
3030

3131
<properties>
32-
<log4jParentDir>${basedir}/..</log4jParentDir>
33-
3432
<!--
3533
~ OSGi and JPMS options
3634
-->
3735
<bnd-extra-package-options>
3836
<!-- Log4j Core is optional -->
3937
org.apache.logging.log4j.core.*;resolution:=optional
4038
</bnd-extra-package-options>
39+
<bnd-extra-module-options>
40+
<!-- Optional dependencies can not be transitive -->
41+
org.apache.logging.log4j.core;transitive=false
42+
</bnd-extra-module-options>
4143

4244
<!-- PTS requires using the JUnit Platform, which interferes with JUL initialization -->
4345
<predictive.test.selection.enabled>false</predictive.test.selection.enabled>

log4j-kit/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
<!-- JSpecify is optional at runtime -->
3636
org.jspecify.annotations.*;resolution:=optional
3737
</bnd-extra-package-options>
38-
<bnd-extra-module-options>org.jspecify;transitive:=false</bnd-extra-module-options>
38+
<bnd-extra-module-options>
39+
<!-- Optional dependencies should not be `static` -->
40+
org.jspecify;transitive=false
41+
</bnd-extra-module-options>
3942
</properties>
4043

4144
<dependencies>

log4j-parent/pom.xml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<asciidoctor-maven-plugin.version>2.2.4</asciidoctor-maven-plugin.version>
8888
<docker-maven-plugin.version>0.43.4</docker-maven-plugin.version>
8989
<exam-maven-plugin.version>4.13.5</exam-maven-plugin.version>
90+
<gmavenplus-plugin.version>3.0.2</gmavenplus-plugin.version>
9091
<!-- `surefire.version` property used in `apache.org:apache`: -->
9192
<surefire.version>3.5.0</surefire.version>
9293

@@ -805,6 +806,68 @@
805806
</executions>
806807
</plugin>
807808

809+
<plugin>
810+
<groupId>org.codehaus.gmavenplus</groupId>
811+
<artifactId>gmavenplus-plugin</artifactId>
812+
<version>${gmavenplus-plugin.version}</version>
813+
<dependencies>
814+
<dependency>
815+
<groupId>org.apache.groovy</groupId>
816+
<artifactId>groovy-ant</artifactId>
817+
<version>${groovy.version}</version>
818+
<scope>runtime</scope>
819+
</dependency>
820+
<dependency>
821+
<groupId>org.apache.groovy</groupId>
822+
<artifactId>groovy</artifactId>
823+
<version>${groovy.version}</version>
824+
<scope>runtime</scope>
825+
</dependency>
826+
</dependencies>
827+
<executions>
828+
<execution>
829+
<id>ban-static-transitive</id>
830+
<goals>
831+
<goal>execute</goal>
832+
</goals>
833+
<phase>verify</phase>
834+
<configuration>
835+
<continueExecuting>false</continueExecuting>
836+
<scripts>
837+
<script><![CDATA[
838+
import java.io.StringWriter
839+
import java.util.spi.ToolProvider
840+
841+
if ("jar" != project.packaging) {
842+
log.info("Skipping module descriptor check, since the project type is not `jar`.")
843+
return
844+
}
845+
String jarFile = project.build.directory + "/" + project.build.finalName + ".jar";
846+
if (!new File(jarFile).exists()) {
847+
log.info("Skipping module descriptor check, since `" + jarFile + "` is missing.")
848+
return
849+
}
850+
StringWriter out = new StringWriter()
851+
StringWriter err = new StringWriter()
852+
ToolProvider jar = ToolProvider.findFirst("jar").orElseThrow()
853+
int result = jar.run(new PrintWriter(out), new PrintWriter(err), "-d", "-f", jarFile)
854+
if (result != 0) {
855+
throw new RuntimeException("Failed to decompile the module descriptor in `" + jarFile + "`:\n" + err)
856+
}
857+
log.debug("Module descriptor: " + out)
858+
for (String line : out.toString().split("\r?\n", -1)) {
859+
if (line.contains("static") && line.contains("transitive")) {
860+
throw new RuntimeException("The `static` and `transitive` modifiers should not be use together: " + line)
861+
}
862+
}
863+
log.info("Successfully verified module descriptor in `" + jarFile + "`.")
864+
]]></script>
865+
</scripts>
866+
</configuration>
867+
</execution>
868+
</executions>
869+
</plugin>
870+
808871
</plugins>
809872
</build>
810873

log4j-plugins/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
com.google.errorprone.annotations.concurrent;resolution:=optional,
3838
org.jspecify.annotations.*;resolution:=optional
3939
</bnd-extra-package-options>
40+
<bnd-extra-module-options>
41+
<!-- Optional dependencies should not be `static` -->
42+
org.jspecify;transitive=false
43+
</bnd-extra-module-options>
4044
</properties>
4145

4246
<dependencies>

log4j-script/src/test/java/org/apache/logging/log4j/script/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818

1919
import static org.apache.logging.log4j.core.test.TestConstants.setSystemProperty;
2020
import static org.assertj.core.api.Assertions.assertThat;
21+
import static org.junit.Assume.assumeFalse;
2122

2223
import java.io.IOException;
2324
import java.io.UncheckedIOException;
2425
import java.nio.file.Files;
2526
import java.nio.file.Path;
27+
import java.time.DayOfWeek;
28+
import java.time.LocalDate;
2629
import java.util.concurrent.TimeUnit;
2730
import java.util.concurrent.atomic.AtomicLong;
2831
import java.util.concurrent.locks.LockSupport;
@@ -37,9 +40,6 @@
3740
import org.junit.Test;
3841
import org.junit.rules.RuleChain;
3942

40-
/**
41-
*
42-
*/
4343
public class RollingAppenderDeleteScriptFri13thTest {
4444

4545
private static final String CONFIG = "log4j-rolling-with-custom-delete-script-fri13th.xml";
@@ -58,6 +58,9 @@ public static void beforeClass() {
5858

5959
@Test
6060
public void testAppender() throws Exception {
61+
LocalDate now = LocalDate.now();
62+
// Ignore on Friday 13th
63+
assumeFalse(now.getDayOfWeek() == DayOfWeek.FRIDAY && now.getDayOfMonth() == 13);
6164
final var dir = Path.of(DIR);
6265
Files.createDirectories(dir);
6366
for (int i = 1; i <= 30; i++) {

log4j-to-jul/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
<!-- Annotations only -->
3535
org.jspecify.*;resolution:=optional
3636
</bnd-extra-package-options>
37+
<bnd-extra-module-options>
38+
<!-- Remove `transitive` for optional dependencies -->
39+
org.jspecify;transitive=false
40+
</bnd-extra-module-options>
3741
</properties>
3842

3943
<dependencies>

log4j-to-slf4j/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
<!-- This bridge also support SLF4J 2.x -->
4646
org.slf4j.*;version="${slf4j.support.range}"
4747
</bnd-extra-package-options>
48+
<bnd-extra-module-options>
49+
<!-- Remove `transitive` for optional dependencies -->
50+
org.jspecify;transitive=false
51+
</bnd-extra-module-options>
4852
</properties>
4953
<dependencies>
5054
<dependency>

0 commit comments

Comments
 (0)