Skip to content

Commit

Permalink
fix: added additional scripts for both jar and shadowJar
Browse files Browse the repository at this point in the history
  • Loading branch information
gsidhwani-nr committed Oct 16, 2024
1 parent 479b0e5 commit fd13248
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 105 deletions.
94 changes: 94 additions & 0 deletions custom-log4j-appender/build-jar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
plugins {
id 'java'
id 'maven-publish'
}

repositories {
mavenCentral()
}

dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.1'
implementation 'org.apache.logging.log4j:log4j-core:2.14.1'
implementation 'org.apache.logging.log4j:log4j-api:2.14.1'
}

jar {
manifest {
attributes(
'Implementation-Title': 'Custom Log4j Appender',
'Implementation-Vendor': 'New Relic Labs',
'Implementation-Vendor-Id': 'com.newrelic.labs',
'Implementation-Version': '1.0.2'
)
}
}



tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from javadoc
}

task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}



publishing {
publications {
mavenJava(MavenPublication) {
from components.java // Include standard JAR

artifact javadocJar
artifact sourcesJar

groupId = 'io.github.newrelic-experimental'
artifactId = 'custom-log4j-appender'
version = '1.0.2'

pom {
name = 'Custom Log4j Appender'
description = 'A custom Log4j appender for New Relic.'
url = 'https://github.com/newrelic-experimental/newrelic-java-log4j-appender'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'newrelic'
name = 'New Relic'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/newrelic-experimental/newrelic-java-log4j-appender.git'
developerConnection = 'scm:git:ssh://github.com/newrelic-experimental/newrelic-java-log4j-appender.git'
url = 'https://github.com/newrelic-experimental/newrelic-java-log4j-appender'
}
}
}
}

repositories {
maven {
name = 'sonatype'
url = uri('https://oss.sonatype.org/service/local/staging/deploy/maven2/')
credentials {
username = project.findProperty("ossrhUsername") ?: ""
password = project.findProperty("ossrhPassword") ?: ""
}
}
}
}
91 changes: 91 additions & 0 deletions custom-log4j-appender/build-shadowJar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'maven-publish'
}

repositories {
mavenCentral()
}

dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.1'
implementation 'org.apache.logging.log4j:log4j-core:2.14.1'
implementation 'org.apache.logging.log4j:log4j-api:2.14.1'
}

jar {
enabled = false // Disable the standard JAR task
}

shadowJar {
archiveClassifier.set('') // Remove the 'all' classifier
mergeServiceFiles()
manifest {
attributes 'Main-Class': 'com.newrelic.labs.logforwarder.MAIN'
}
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from javadoc
}

task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

publishing {
publications {
mavenJava(MavenPublication) {
artifact shadowJar // Only include Shadow JAR
artifact javadocJar
artifact sourcesJar

groupId = 'io.github.newrelic-experimental'
artifactId = 'custom-log4j-appender'
version = '1.0.0'

pom {
name = 'Custom Log4j Appender'
description = 'A custom Log4j appender for New Relic Labs.'
url = 'https://github.com/newrelic-experimental/newrelic-java-log4j-appender'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'newrelic'
name = 'New Relic'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/newrelic-experimental/newrelic-java-log4j-appender.git'
developerConnection = 'scm:git:ssh://github.com/newrelic-experimental/newrelic-java-log4j-appender.git'
url = 'https://github.com/newrelic-experimental/newrelic-java-log4j-appender'
}
}
}
}

repositories {
maven {
name = 'sonatype'
url = uri('https://oss.sonatype.org/service/local/staging/deploy/maven2/')
credentials {
username = project.findProperty("ossrhUsername") ?: ""
password = project.findProperty("ossrhPassword") ?: ""
}
}
}
}
2 changes: 2 additions & 0 deletions custom-log4j-appender/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jar {
}
}



tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
Expand Down
4 changes: 4 additions & 0 deletions custom-log4j-appender/publish-jar.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# clean existing stuff
rm -rf build io
# copy correct build.gradle
cp build-jar.gradle build.gradle
# Set variables
GROUP_ID="io.github.newrelic-experimental"
ARTIFACT_ID="custom-log4j-appender"
Expand Down
105 changes: 0 additions & 105 deletions custom-log4j-appender/publish_shadowJar.sh

This file was deleted.

0 comments on commit fd13248

Please sign in to comment.