Skip to content

Commit

Permalink
Reshuffle building projects
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik committed Dec 13, 2024
1 parent 1743437 commit 2967495
Show file tree
Hide file tree
Showing 27 changed files with 93 additions and 202 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ jobs:
- name: Publish
run: |
./gradlew publish
cd jafar-gradle-plugin
./gradlew publish
9 changes: 8 additions & 1 deletion demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ tasks.build {
dependencies {
implementation project(':parser')
implementation 'org.jctools:jctools-core:4.0.1'
implementation 'com.github.ben-manes.caffeine:caffeine:3.1.5'
implementation 'org.openjdk.jmc:flightrecorder:8.3.1'
}

test {
useJUnitPlatform()
}

generateJafarTypes {
overwrite = false
eventTypeFilter {
it == 'jdk.ExecutionSample'
}
targetPackage = 'io.jafar.demo.types'
}
15 changes: 0 additions & 15 deletions demo/src/main/java/io/jafar/demo/ExecutionSampleEvent.java

This file was deleted.

3 changes: 2 additions & 1 deletion demo/src/main/java/io/jafar/demo/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jafar.demo;

import io.jafar.demo.types.JFRExecutionSample;
import io.jafar.parser.api.HandlerRegistration;
import io.jafar.parser.api.JafarParser;
import jdk.jfr.consumer.EventStream;
Expand Down Expand Up @@ -61,7 +62,7 @@ private static void runWithJmc(File file, LongAccumulator sum, AtomicInteger cnt

private static void runWithJafar(File file, LongAccumulator sum, AtomicInteger cnt) throws Exception {
try (JafarParser p = JafarParser.open(file.getPath())) {
HandlerRegistration<ExecutionSampleEvent> h1 = p.handle(ExecutionSampleEvent.class, (event, ctl) -> {
HandlerRegistration<JFRExecutionSample> h1 = p.handle(JFRExecutionSample.class, (event, ctl) -> {
if (event.sampledThread() == null) {
throw new RuntimeException();
}
Expand Down
12 changes: 11 additions & 1 deletion gradle-plugin/build.gradle → jafar-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ plugins {
id 'java-gradle-plugin'
id 'groovy'
id 'maven-publish'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
}

group = "io.btrace"
version = project.hasProperty("jafar_version") ? project.jafar_version : rootProject.version
version = "0.0.1-SNAPSHOT"

repositories {
mavenLocal()
Expand Down Expand Up @@ -67,3 +68,12 @@ publishing {
}
}

nexusPublishing {
repositories {
sonatype {
username = project.hasProperty("sonatype.user") ? project.property("sonatype.user") : System.getenv("SONATYPE_USERNAME")
password = project.hasProperty("sonatype.password") ? project.property("sonatype.password") : System.getenv("SONATYPE_PASSWORD")
}
}
}

2 changes: 2 additions & 0 deletions jafar-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sonatype.user=XXSEjG1P
sonatype.password=P5w7F2tDqHdOO5CDCbyK66t1dV93Owtudyaibs2k30mL
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import io.jafar.utils.TypeGenerator
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.provider.Property
import org.gradle.api.file.DirectoryProperty

import java.util.function.Predicate

class TypeGeneratorPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
def extension = project.extensions.create('generateSources', GenerateSourcesExtension, project)
def extension = project.extensions.create('generateJafarTypes', GenerateJafarTypesExtension, project)

project.afterEvaluate {
if (project.hasProperty('jafar.input')) {
Expand All @@ -26,7 +29,7 @@ class TypeGeneratorPlugin implements Plugin<Project> {

// Define inputs and outputs for task up-to-date checks
inputs.file(extension.inputFile).optional(true)
outputs.dir(generatedSourcesDir)
outputs.dir(extension.outputDir.orElse(project.layout.buildDirectory.dir("generated/sources/jafar/src/main")))

doLast {
if (!extension.inputFile.isPresent()) {
Expand All @@ -36,13 +39,22 @@ class TypeGeneratorPlugin implements Plugin<Project> {
}

def input = extension.inputFile.isPresent() ? extension.inputFile.get() : null
def output = generatedSourcesDir
def output = extension.outputDir.orElse(project.layout.buildDirectory.dir("generated/sources/jafar/src/main")).get().asFile
def overwrite = extension.overwrite.getOrElse(false)
def targetPackage = extension.targetPackage.getOrElse("io.jafar.parser.api.types")


// Ensure output directory exists
output.mkdirs()

Predicate<String> predicate = null
if (extension.eventTypeFilter.isPresent()) {
def filterClosure = extension.eventTypeFilter.get()
predicate = filterClosure as Predicate<String> // Convert Closure to Predicate
}

// Instantiate and execute TypeGenerator
def generator = new TypeGenerator(input?.toPath(), output.toPath())
def generator = new TypeGenerator(input?.toPath(), output.toPath(), targetPackage, overwrite, predicate)
generator.generate()
}
}
Expand All @@ -57,11 +69,23 @@ class TypeGeneratorPlugin implements Plugin<Project> {
}

// Extension to configure the input file
static class GenerateSourcesExtension {
static class GenerateJafarTypesExtension {
final Property<File> inputFile
final DirectoryProperty outputDir
final Property<String> targetPackage
final Property<Boolean> overwrite
final Property<Closure<Boolean>> eventTypeFilter

GenerateSourcesExtension(Project project) {
GenerateJafarTypesExtension(Project project) {
inputFile = project.objects.property(File)
outputDir = project.objects.directoryProperty()
targetPackage = project.objects.property(String)
overwrite = project.objects.property(Boolean)
eventTypeFilter = project.objects.property(Closure)
}

void eventTypeFilter(Closure<Boolean> eventTypeFilterClosure) {
this.eventTypeFilter.set(eventTypeFilterClosure)
}
}
}
24 changes: 0 additions & 24 deletions parser/src/main/java/io/jafar/parser/api/types/JFRClass.java

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions parser/src/main/java/io/jafar/parser/api/types/JFREvent.java

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions parser/src/main/java/io/jafar/parser/api/types/JFRMethod.java

This file was deleted.

11 changes: 0 additions & 11 deletions parser/src/main/java/io/jafar/parser/api/types/JFRModule.java

This file was deleted.

16 changes: 0 additions & 16 deletions parser/src/main/java/io/jafar/parser/api/types/JFRPackage.java

This file was deleted.

17 changes: 0 additions & 17 deletions parser/src/main/java/io/jafar/parser/api/types/JFRStackFrame.java

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions parser/src/main/java/io/jafar/parser/api/types/JFRSymbol.java

This file was deleted.

12 changes: 0 additions & 12 deletions parser/src/main/java/io/jafar/parser/api/types/JFRThread.java

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2967495

Please sign in to comment.