Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellyrob99/2859928 to your computer and use it in GitHub Desktop.
Save kellyrob99/2859928 to your computer and use it in GitHub Desktop.
Patch file to enable building log4j with Gradle
Index: ntdll.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ntdll.gradle (revision )
+++ ntdll.gradle (revision )
@@ -0,0 +1,7 @@
+ant.'target.dir'='target'
+ant.'classes.dir'='target/classes'
+ant.'src.dir'='.'
+ant.'jni.include.dir'='${java.home}/../include'
+ant.importBuild('src/ntdll/build.xml')
+
+defaultTasks 'build'
\ No newline at end of file
Index: settings.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- settings.gradle (revision )
+++ settings.gradle (revision )
@@ -0,0 +1,2 @@
+rootProject.name = 'log4j'
+
\ No newline at end of file
Index: tests/src/java/org/apache/log4j/util/JunitTestRunnerFilter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tests/src/java/org/apache/log4j/util/JunitTestRunnerFilter.java (revision 1345443)
+++ tests/src/java/org/apache/log4j/util/JunitTestRunnerFilter.java (revision )
@@ -53,6 +53,13 @@
return null;
} else if(in.indexOf("JUnit4TestAdapter") >= 0) {
return null;
+ //BEGIN Gradle specific entries
+ } else if(in.indexOf("org.gradle") >= 0 || in.indexOf("$Proxy") >= 0 || in.indexOf("ThreadPoolExecutor") >= 0 ||
+ in.indexOf("java.lang.Thread.run") >= 0) {
+ return null;
+ } else if(in.indexOf("thread=\"Outgoing Connection") >= 0) {
+ return in.replaceAll("Outgoing Connection \\[.*worker", "main");
+ //END Gradle specific entries
} else if (util.match("/\\sat /", in)) {
return "\t" + in.trim();
} else {
Index: build.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- build.gradle (revision )
+++ build.gradle (revision )
@@ -0,0 +1,134 @@
+import static org.gradle.internal.os.OperatingSystem.*
+
+apply plugin: 'java'
+apply plugin: 'maven'
+apply plugin: 'findbugs'
+apply plugin: 'jdepend'
+apply plugin: 'pmd'
+apply plugin: 'project-report'
+
+group = 'log4j'
+version = '1.2.18-SNAPSHOT'
+description = 'Apache Log4j'
+
+sourceCompatibility = 1.4
+targetCompatibility = 1.4
+
+repositories {
+ maven {
+ url 'http://download.java.net/maven/2/'
+ }
+ maven {
+ url 'http://repo.maven.apache.org/maven2'
+ }
+}
+
+project.ext.'tools.jar' = current().isMacOsX() ? "${System.properties['java.home']}/../Classes/classes.jar" : "${System.properties['java.home']}/../lib/tools.jar"
+
+dependencies {
+ compile 'javax.mail:mail:1.4.3'
+ compile 'org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.0'
+ compile('org.apache.openejb:javaee-api:5.0-2') {
+ provided: true
+ }
+ testCompile 'oro:oro:2.0.8'
+ testCompile 'junit:junit:3.8.1'
+ testRuntime files(project.'tools.jar')
+}
+
+sourceSets {
+ test {
+ java {
+ srcDir 'tests'
+ }
+ resources {
+ srcDir 'tests/resources'
+ }
+ }
+}
+
+test {
+ doFirst {
+ mkdir('output/temp')
+ mkdir('witness')
+ }
+ forkEvery 1
+ workingDir 'tests'
+ include 'org/apache/log4j/LevelTest.class',
+ 'org/apache/log4j/PriorityTest.class',
+ 'org/apache/log4j/CategoryTest.class',
+ 'org/apache/log4j/FileAppenderTest.class',
+ 'org/apache/log4j/LogManagerTest.class',
+ 'org/apache/log4j/helpers.LogLogTest.class',
+ 'org/apache/log4j/LayoutTest.class',
+ 'org/apache/log4j/helpers.DateLayoutTest.class',
+ 'org/apache/log4j/TTCCLayoutTest.class',
+ 'org/apache/log4j/xml.XMLLayoutTest.class',
+ 'org/apache/log4j/HTMLLayoutTest.class',
+ 'org/apache/log4j/PatternLayoutTest.class',
+ 'org/apache/log4j/spi.LoggingEventTest.class',
+ 'org/apache/log4j/spi.ThrowableInformationTest.class',
+ 'org/apache/log4j/spi.LocationInfoTest.class',
+ 'org/apache/log4j/PropertyConfiguratorTest.class',
+ 'org/apache/log4j/MinimumTestCase.class',
+ 'org/apache/log4j/LoggerTestCase.class',
+ 'org/apache/log4j/PatternLayoutTestCase.class',
+ 'org/apache/log4j/HierarchyThresholdTestCase.class',
+ 'org/apache/log4j/xml/DOMTestCase.class',
+ 'org/apache/log4j/xml/CustomLevelTestCase.class',
+ 'org/apache/log4j/customLogger/XLoggerTestCase.class',
+ 'org/apache/log4j/xml/XMLLayoutTestCase.class',
+ 'org/apache/log4j/xml/AsyncAppenderTestCase.class',
+ 'org/apache/log4j/varia/LevelMatchFilterTestCase.class',
+ 'org/apache/log4j/helpers/BoundedFIFOTestCase.class',
+ 'org/apache/log4j/helpers/CyclicBufferTestCase.class',
+ 'org/apache/log4j/helpers/PatternParserTestCase.class',
+ 'org/apache/log4j/or/ORTestCase.class',
+ 'org/apache/log4j/DRFATestCase.class',
+ 'org/apache/log4j/RFATestCase.class',
+ 'org/apache/log4j/varia/ERFATestCase.class',
+ 'org/apache/log4j/net/SyslogAppenderTest.class',
+ 'org/apache/log4j/net/SocketAppenderTest.class'
+ if (current().isWindows()) {
+ include 'org/apache/log4j/nt/NTEventLogAppenderTest.class' //only works on Windows
+ }
+}
+
+final Closure manifestAttributes = {
+ attributes('Implementation-Title': 'log4j', 'Implementation-Version': version, 'Implementation-Vendor': "Apache Software Foundation")
+}
+
+jar {
+ manifest(manifestAttributes)
+}
+
+// custom tasks for creating source jar
+task sourcesJar(type: Jar, dependsOn: classes) {
+ manifest(manifestAttributes)
+ classifier = 'sources'
+ from sourceSets.main.allSource
+}
+// custom tasks for creating javadoc jar
+task javadocJar(type: Jar, dependsOn: javadoc) {
+ manifest(manifestAttributes)
+ classifier = 'javadoc'
+ from javadoc.destinationDir
+}
+
+// add the jars as artifacts
+artifacts {
+ archives sourcesJar
+ archives javadocJar
+}
+
+[findbugsMain, findbugsTest, pmdMain, pmdTest].each {
+ it.ignoreFailures = true
+ it.reports.html.enabled = true
+ it.reports.xml.enabled = false
+}
+
+task ntdll(type: GradleBuild, description: 'generate NTEventLogAppender.dll') {
+ buildFile 'ntdll.gradle'
+ startParameter.searchUpwards = false
+}
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment