Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement customattr #4

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: updated scripts as per legacy maven way
  • Loading branch information
gsidhwani-nr committed Oct 28, 2024
commit b206390257895f5915a942467311b11a082488b0
12 changes: 6 additions & 6 deletions custom-log4j2-appender/build-jar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jar {
'Implementation-Title': 'Custom Log4j2 Appender',
'Implementation-Vendor': 'New Relic Labs',
'Implementation-Vendor-Id': 'com.newrelic.labs',
'Implementation-Version': '0.0.7'
'Implementation-Version': '0.0.9'
)
}
}
Expand Down Expand Up @@ -53,12 +53,12 @@ publishing {

groupId = 'com.newrelic.labs'
artifactId = 'custom-log4j2-appender'
version = '0.0.7'
version = '0.0.9'

pom {
name = 'Custom Log4j2 Appender'
description = 'A custom Log4j2 appender for New Relic.'
url = 'https://github.com/newrelic-experimental/newrelic-java-log4j-appender'
url = 'https://github.com/newrelic/newrelic-java-log4j-appender'
licenses {
license {
name = 'The Apache License, Version 2.0'
Expand All @@ -73,9 +73,9 @@ publishing {
}
}
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'
connection = 'scm:git:git://github.com/newrelic/newrelic-java-log4j-appender.git'
developerConnection = 'scm:git:ssh://github.com/newrelic/newrelic-java-log4j-appender.git'
url = 'https://github.com/newrelic/newrelic-java-log4j-appender'
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions custom-log4j2-appender/build-shadowJar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ shadowJar {
'Implementation-Title': 'Custom Log4j2 Appender',
'Implementation-Vendor': 'New Relic Labs',
'Implementation-Vendor-Id': 'com.newrelic.labs',
'Implementation-Version': '0.0.7'
'Implementation-Version': '0.0.9'
)
}
}
Expand Down Expand Up @@ -55,12 +55,12 @@ publishing {

groupId = 'com.newrelic.labs'
artifactId = 'custom-log4j2-appender'
version = '0.0.7'
version = '0.0.9'

pom {
name = 'Custom Log4j2 Appender'
description = 'A custom Log4j2 appender for New Relic.'
url = 'https://github.com/newrelic-experimental/newrelic-java-log4j-appender'
url = 'https://github.com/newrelic/newrelic-java-log4j-appender'
licenses {
license {
name = 'The Apache License, Version 2.0'
Expand All @@ -75,9 +75,9 @@ publishing {
}
}
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'
connection = 'scm:git:git://github.com/newrelic/newrelic-java-log4j-appender.git'
developerConnection = 'scm:git:ssh://github.com/newrelic/newrelic-java-log4j-appender.git'
url = 'https://github.com/newrelic/newrelic-java-log4j-appender'
}
}
}
Expand Down
26 changes: 12 additions & 14 deletions custom-log4j2-appender/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'maven-publish'
}

Expand All @@ -16,22 +15,18 @@ dependencies {
}

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

shadowJar {
archiveClassifier.set('') // Remove the 'all' classifier
mergeServiceFiles()
manifest {
attributes(
'Implementation-Title': 'Custom Log4j2 Appender',
'Implementation-Vendor': 'New Relic Labs',
'Implementation-Vendor-Id': 'com.newrelic.labs',
'Implementation-Version': '0.0.7'
'Implementation-Version': '0.0.9'
)
}
}



tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
Expand All @@ -46,21 +41,24 @@ task sourcesJar(type: Jar) {
from sourceSets.main.allSource
}



publishing {
publications {
mavenJava(MavenPublication) {
artifact shadowJar // Only include Shadow JAR
from components.java // Include standard JAR

artifact javadocJar
artifact sourcesJar

groupId = 'com.newrelic.labs'
artifactId = 'custom-log4j2-appender'
version = '0.0.7'
version = '0.0.9'

pom {
name = 'Custom Log4j2 Appender'
description = 'A custom Log4j2 appender for New Relic.'
url = 'https://github.com/newrelic-experimental/newrelic-java-log4j-appender'
url = 'https://github.com/newrelic/newrelic-java-log4j-appender'
licenses {
license {
name = 'The Apache License, Version 2.0'
Expand All @@ -75,9 +73,9 @@ publishing {
}
}
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'
connection = 'scm:git:git://github.com/newrelic/newrelic-java-log4j-appender.git'
developerConnection = 'scm:git:ssh://github.com/newrelic/newrelic-java-log4j-appender.git'
url = 'https://github.com/newrelic/newrelic-java-log4j-appender'
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions custom-log4j2-appender/pom-template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>{{VERSION}}</version>
<name>Custom Log4j2 Appender</name>
<description>A custom Log4j2 appender for New Relic.</description>
<url>https://github.com/newrelic-experimental/newrelic-java-log4j-appender</url>
<url>https://github.com/newrelic/newrelic-java-log4j-appender</url>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
Expand All @@ -21,9 +21,9 @@
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/newrelic-experimental/newrelic-java-log4j-appender.git</connection>
<developerConnection>scm:git:ssh://github.com/newrelic-experimental/newrelic-java-log4j-appender.git</developerConnection>
<url>https://github.com/newrelic-experimental/newrelic-java-log4j-appender</url>
<connection>scm:git:git://github.com/newrelic/newrelic-java-log4j-appender.git</connection>
<developerConnection>scm:git:ssh://github.com/newrelic/newrelic-java-log4j-appender.git</developerConnection>
<url>https://github.com/newrelic/newrelic-java-log4j-appender</url>
</scm>
<dependencies>
{{DEPENDENCIES}}
Expand Down
166 changes: 166 additions & 0 deletions custom-log4j2-appender/publish-jar-legacy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
#!/bin/bash

# clean existing stuff
rm -rf build bundle
# copy correct build.gradle
cp build-jar.gradle build.gradle
# Set variables
GROUP_ID="com.newrelic.labs"
ARTIFACT_ID="custom-log4j2-appender"
VERSION="0.0.9"
KEY_ID="0ED9FD74E81E6D83FAE25F235640EA0B1C631C6F" # Replace with your actual key ID

# Get the current directory (assuming the script is run from the custom-log4j2-appender directory)
CURRENT_DIR=$(pwd)
PROJECT_ROOT=$(dirname "$CURRENT_DIR")

echo "Current Directory: $CURRENT_DIR"
echo "Project Root: $PROJECT_ROOT"

# Clean and build the project
cd "$PROJECT_ROOT"
./gradlew clean build jar javadocJar sourcesJar generatePomFileForMavenJavaPublication

# Navigate to the directory containing the artifacts
cd "$CURRENT_DIR/build/libs"

# List the contents of the build/libs directory for debugging
echo "Contents of build/libs:"
ls -la

# Find the files without version numbers
JAR_FILE="custom-log4j2-appender.jar"
JAVADOC_FILE="custom-log4j2-appender-javadoc.jar"
SOURCES_FILE="custom-log4j2-appender-sources.jar"
POM_FILE="custom-log4j2-appender-$VERSION.pom"

echo "JAR File: $JAR_FILE"
echo "Javadoc File: $JAVADOC_FILE"
echo "Sources File: $SOURCES_FILE"
echo "POM File: $POM_FILE"

# Check if the files exist before proceeding
if [ ! -f "$JAR_FILE" ] || [ ! -f "$JAVADOC_FILE" ] || [ ! -f "$SOURCES_FILE" ]; then
echo "One or more expected files are missing in build/libs"
ls -la
exit 1
fi

# Prepare the directory structure
TARGET_DIR="$CURRENT_DIR/bundle"
mkdir -p $TARGET_DIR

# Copy the built artifacts to the appropriate directory with version numbers
echo "Copying artifacts to $TARGET_DIR"
cp $JAR_FILE $TARGET_DIR/custom-log4j2-appender-$VERSION.jar
cp $JAVADOC_FILE $TARGET_DIR/custom-log4j2-appender-$VERSION-javadoc.jar
cp $SOURCES_FILE $TARGET_DIR/custom-log4j2-appender-$VERSION-sources.jar

# Navigate to the target directory
cd $TARGET_DIR

# Generate checksums for the copied files
# for legacy checkusum is not needed and hence commenting
# for file in custom-log4j2-appender-$VERSION.jar custom-log4j2-appender-$VERSION-javadoc.jar custom-log4j2-appender-$VERSION-sources.jar; do
# echo "Generating checksums for $file"
# md5sum $file | awk '{ print $1 }' > $file.md5
# sha1sum $file | awk '{ print $1 }' > $file.sha1
# done

# Generate GPG signatures using the specific key ID
for file in custom-log4j2-appender-$VERSION.jar custom-log4j2-appender-$VERSION-javadoc.jar custom-log4j2-appender-$VERSION-sources.jar; do
echo "Generating GPG signature for $file"
gpg --local-user $KEY_ID --armor --detach-sign $file
done

# Generate the dependencies section for the POM file
DEPENDENCIES=$(cat <<EOF
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.1</version>
<scope>runtime</scope>
</dependency>
EOF
)

# Read the POM template, replace placeholders, and save the final POM file
POM_TEMPLATE=$(<"$CURRENT_DIR/pom-template.xml")
POM_CONTENT="${POM_TEMPLATE//\{\{GROUP_ID\}\}/$GROUP_ID}"
POM_CONTENT="${POM_CONTENT//\{\{ARTIFACT_ID\}\}/$ARTIFACT_ID}"
POM_CONTENT="${POM_CONTENT//\{\{VERSION\}\}/$VERSION}"
POM_CONTENT="${POM_CONTENT//\{\{DEPENDENCIES\}\}/$DEPENDENCIES}"

echo "$POM_CONTENT" > "$TARGET_DIR/$POM_FILE"

# Generate checksums and signatures for the POM file
# for legacy checkusum is not needed and hence commenting
# echo "Generating checksums and GPG signature for $POM_FILE"
# md5sum $POM_FILE | awk '{ print $1 }' > $POM_FILE.md5
# sha1sum $POM_FILE | awk '{ print $1 }' > $POM_FILE.sha1
gpg --local-user $KEY_ID --armor --detach-sign $POM_FILE

# Verify checksums
# for legacy checkusum is not needed and hence commenting
echo "Verifying checksums"
# for file in custom-log4j2-appender-$VERSION.jar custom-log4j2-appender-$VERSION-javadoc.jar custom-log4j2-appender-$VERSION-sources.jar $POM_FILE; do
# if [ -f "$file" ]; then
# echo "Verifying checksum for $file"
# md5sum -c <(echo "$(cat $file.md5) $file")
# sha1sum -c <(echo "$(cat $file.sha1) $file")
# else
# echo "File $file does not exist in the target directory $TARGET_DIR."
# ls -la $TARGET_DIR
# fi
# done

# Navigate back to the custom-log4j2-appender directory
cd "$CURRENT_DIR/bundle"

# Create a ZIP file containing the entire directory structure
echo "Creating jar bundle-$VERSION.jar"
jar -cvf ../bundle-$VERSION.jar *
cd ..
echo "Artifacts prepared and zipped successfully. You can now upload bundle-$VERSION.jar to Sonatype OSSRH."
18 changes: 9 additions & 9 deletions custom-log4j2-appender/publish-jar.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

# clean existing stuff
rm -rf build bundle
rm -rf build io
# copy correct build.gradle
cp build-jar.gradle build.gradle
# Set variables
GROUP_ID="com.newrelic.labs"
GROUP_ID="io.github.newrelic-experimental"
ARTIFACT_ID="custom-log4j2-appender"
VERSION="0.0.7"
VERSION="0.0.9"
KEY_ID="0ED9FD74E81E6D83FAE25F235640EA0B1C631C6F" # Replace with your actual key ID

# Get the current directory (assuming the script is run from the custom-log4j2-appender directory)
Expand Down Expand Up @@ -47,7 +47,7 @@ if [ ! -f "$JAR_FILE" ] || [ ! -f "$JAVADOC_FILE" ] || [ ! -f "$SOURCES_FILE" ];
fi

# Prepare the directory structure
TARGET_DIR="$CURRENT_DIR/bundle"
TARGET_DIR="$CURRENT_DIR/io/github/newrelic-experimental/custom-log4j2-appender/$VERSION"
mkdir -p $TARGET_DIR

# Copy the built artifacts to the appropriate directory with version numbers
Expand Down Expand Up @@ -154,10 +154,10 @@ for file in custom-log4j2-appender-$VERSION.jar custom-log4j2-appender-$VERSION-
done

# Navigate back to the custom-log4j2-appender directory
cd "$CURRENT_DIR/bundle"
cd "$CURRENT_DIR"

# Create a ZIP file containing the entire directory structure
echo "Creating jar file custom-log4j2-appender-$VERSION.zip"
jar -cvf ../bundle-$VERSION.jar *
cd ..
echo "Artifacts prepared and zipped successfully. You can now upload bundle-$VERSION.jar to Sonatype OSSRH."
echo "Creating ZIP file custom-log4j2-appender-$VERSION.zip"
zip -r custom-log4j2-appender-$VERSION.zip io

echo "Artifacts prepared and zipped successfully. You can now upload custom-log4j2-appender-$VERSION.zip to Sonatype OSSRH."
2 changes: 1 addition & 1 deletion custom-log4j2-appender/publish-shadowJar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cp build-shadowJar.gradle build.gradle
# Set variables
GROUP_ID="io.github.newrelic-experimental"
ARTIFACT_ID="custom-log4j2-appender"
VERSION="1.0.0"
VERSION="0.0.9"
KEY_ID="0ED9FD74E81E6D83FAE25F235640EA0B1C631C6F" # Replace with your actual key ID

# Get the current directory (assuming the script is run from the custom-log4j2-appender directory)
Expand Down