Skip to content

Commit

Permalink
Add maven build support
Browse files Browse the repository at this point in the history
  • Loading branch information
dagnir committed Dec 15, 2021
1 parent 0db8aaf commit 5fb1998
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 2 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@ This is a tool which injects a Java agent into a running JVM process. The agent
This has been currently only tested with JDK 8, 11, 15 and 17 on Linux!

## Building
### Gradle
To build on linux, mac and Windows subsystem for linux
```
./gradlew build
```

To build on Windows
```
.\gradlew.bat build
```

Depending on the platform you are building. This will generate `build/libs/Log4jHotPatch.jar`

### Maven

To build using Maven use

```
mvn clean package
```

This will generate a `target/Log4jHotPatch.jar`.

## Running

JDK 8
Expand All @@ -35,9 +48,9 @@ java -classpath <class-path> -javaagent:Log4jHotPatch.jar <main-class> <argument
```

### Testing the agent
There are a set of tests that can be run outside gradle.
There are a set of tests that can be run outside Gradle or Maven.
```
build-tools/bin/run_tests.sh build/libs/Log4jHotPatch.jar <JDK_ROOT>
build-tools/bin/run_tests.sh Log4jHotPatch.jar <JDK_ROOT>
```

## Known issues
Expand Down
171 changes: 171 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?xml version="1.0"?>
<!--
~ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License").
~ You may not use this file except in compliance with the License.
~ A copy of the License is located at
~
~ http://aws.amazon.com/apache2.0
~
~ or in the "license" file accompanying this file. This file is distributed
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
~ express or implied. See the License for the specific language governing
~ permissions and limitations under the License.
-->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazon.corretto.hotpatch</groupId>
<artifactId>hotpatch-for-apache-log4j2</artifactId>
<version>1.2</version>
<packaging>jar</packaging>
<name>Hotpatch for Apache Log4j2</name>
<description>A hotpatch to address CVE-2021-44228.</description>

<url>https://aws.amazon.com/sdkforjava</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://aws.amazon.com/apache2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>amazonwebservices</id>
<organization>Amazon Web Services</organization>
<organizationUrl>https://aws.amazon.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>

<properties>
<jre.version>1.8</jre.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
</properties>

<profiles>
<profile>
<id>jdk8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<dependencies>
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>jdk1.8.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
<profile>
<id>publishing</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype-nexus-staging</serverId>
<nexusUrl>https://aws.oss.sonatype.org</nexusUrl>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${jre.version}</source>
<target>${jre.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifestEntries>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Title>Log4jHotPatch</Implementation-Title>
<Implementation-Vendor>Amazon Corretto Team</Implementation-Vendor>
<Created-by>Amazon Corretto Team</Created-by>
<Agent-Class>Log4jHotPatch</Agent-Class>
<Premain-Class>Log4jHotPatch</Premain-Class>
<Main-Class>Log4jHotPatch</Main-Class>
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<finalName>Log4jHotPatch</finalName>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>com.amazon.corretto.org.objectweb.asm</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.2</version>
</dependency>
</dependencies>

</project>

0 comments on commit 5fb1998

Please sign in to comment.