Skip to content

Commit

Permalink
commit name (idk what to put here lol)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnAwesomGuy committed Aug 28, 2024
0 parents commit 8b6a09b
Show file tree
Hide file tree
Showing 13 changed files with 615 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and Test

on: [pull_request, push]

jobs:
build_latest:
runs-on: ubuntu-latest
steps:
- name: Checkout Sources
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Test
run: ./gradlew runMainTest
build_5:
runs-on: ubuntu-latest
steps:
- name: Checkout Sources
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Test
run: ./gradlew runJava5Test
upload:
runs-on: ubuntu-latest
steps:
- name: Upload build artifacts
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: artifacts
path: build/libs/*.jar
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 AnAwesomGuy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Class Dump

A tiny Java agent to dump all classes loaded by the JVM, made using the instrumentation API.

There are two "version" of this project: one is the normal one (can be compiled with Java 7+, uses NIO),
and the other one, which is compatible with all Java versions 5 and above.

To use, simply add `-javaagent:path/to/classdump-version.jar` as a JVM arg. (adding `=debug` at the end enables logging each class dumped)

### Building

This project builds like any normal Gradle project, just run `./gradlew build`.

However, to compile the Java 5 version (`./gradlew java5Jar`), you will need to use Java 8 or below, as Java 9+ does not support compiling with compatibility for Java 5.

There are also GitHub Actions setup for this repo, allowing you to get a jar for every commit!
52 changes: 52 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
plugins {
id 'java'
}

group = 'net.anawesomguy'
version = '1.0'

sourceSets {
java5
}

compileJava5Java {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_5
}

tasks.register('java5Jar', Jar) {
dependsOn compileJava5Java, processJava5Resources
from sourceSets.java5.output
archiveClassifier = 'java5'
}

tasks.withType(Jar).configureEach {
manifest.attributes(['Premain-Class': 'net.anawesomguy.clsdump.Dumper'])
from 'LICENSE'
}

tasks.register('runMainTest', JavaExec) {
dependsOn jar
group 'verification'
classpath sourceSets.test.runtimeClasspath
jvmArgs '-javaagent:' + jar.archiveFile.get() + '=debug'
mainClass = 'net.anawesomguy.clsdump.test.Main'
workingDir 'build/test-main/'
workingDir.deleteDir()
workingDir.mkdirs()
}

tasks.register('runJava5Test', JavaExec) {
dependsOn java5Jar
group 'verification'
classpath sourceSets.test.runtimeClasspath
jvmArgs '-javaagent:' + java5Jar.archiveFile.get() + '=debug'
mainClass = 'net.anawesomguy.clsdump.test.Main'
workingDir 'build/test-java5/'
workingDir.deleteDir()
workingDir.mkdirs()
}

tasks.register('runAllTests') {
group 'verification'
dependsOn runMainTest, runJava5Test
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Mon Aug 26 21:00:50 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 8b6a09b

Please sign in to comment.