generated from newrelic-experimental/java-instrumentation-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added publishing jar with depedencies
- Loading branch information
1 parent
77aacb5
commit 479b0e5
Showing
3 changed files
with
203 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>{{GROUP_ID}}</groupId> | ||
<artifactId>{{ARTIFACT_ID}}</artifactId> | ||
<version>{{VERSION}}</version> | ||
<name>Custom Log4j Appender</name> | ||
<description>A custom Log4j appender for New Relic Labs.</description> | ||
<url>https://github.com/newrelic-experimental/newrelic-java-log4j-appender</url> | ||
<licenses> | ||
<license> | ||
<name>The Apache License, Version 2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
</license> | ||
</licenses> | ||
<developers> | ||
<developer> | ||
<id>newrelic</id> | ||
<name>New Relic</name> | ||
<email>[email protected]</email> | ||
</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> | ||
</scm> | ||
<dependencies> | ||
{{DEPENDENCIES}} | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
#!/bin/bash | ||
|
||
# Set variables | ||
GROUP_ID="io.github.newrelic-experimental" | ||
ARTIFACT_ID="custom-log4j-appender" | ||
VERSION="1.0.2" | ||
KEY_ID="0ED9FD74E81E6D83FAE25F235640EA0B1C631C6F" # Replace with your actual key ID | ||
|
||
# Get the current directory (assuming the script is run from the custom-log4j-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-log4j-appender.jar" | ||
JAVADOC_FILE="custom-log4j-appender-javadoc.jar" | ||
SOURCES_FILE="custom-log4j-appender-sources.jar" | ||
POM_FILE="custom-log4j-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/io/github/newrelic-experimental/custom-log4j-appender/$VERSION" | ||
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-log4j-appender-$VERSION.jar | ||
cp $JAVADOC_FILE $TARGET_DIR/custom-log4j-appender-$VERSION-javadoc.jar | ||
cp $SOURCES_FILE $TARGET_DIR/custom-log4j-appender-$VERSION-sources.jar | ||
|
||
# Navigate to the target directory | ||
cd $TARGET_DIR | ||
|
||
# Generate checksums for the copied files | ||
for file in custom-log4j-appender-$VERSION.jar custom-log4j-appender-$VERSION-javadoc.jar custom-log4j-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-log4j-appender-$VERSION.jar custom-log4j-appender-$VERSION-javadoc.jar custom-log4j-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 | ||
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 | ||
echo "Verifying checksums" | ||
for file in custom-log4j-appender-$VERSION.jar custom-log4j-appender-$VERSION-javadoc.jar custom-log4j-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-log4j-appender directory | ||
cd "$CURRENT_DIR" | ||
|
||
# Create a ZIP file containing the entire directory structure | ||
echo "Creating ZIP file custom-log4j-appender-$VERSION.zip" | ||
zip -r custom-log4j-appender-$VERSION.zip io | ||
|
||
echo "Artifacts prepared and zipped successfully. You can now upload custom-log4j-appender-$VERSION.zip to Sonatype OSSRH." |