Skip to content

Commit

Permalink
Update parent
Browse files Browse the repository at this point in the history
This goes with source reformat, so next commit will fix blame
  • Loading branch information
cstamas committed Aug 23, 2024
1 parent 41bf316 commit b8f3751
Show file tree
Hide file tree
Showing 9 changed files with 498 additions and 508 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To generate a timeline for your project add this section to your `pom.xml`:
<extension>
<groupId>io.takari.maven</groupId>
<artifactId>maven-timeline</artifactId>
<version>1.8</version>
<version>2.0</version>
</extension>
</extensions>
```
Expand Down
45 changes: 30 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.takari</groupId>
<artifactId>takari</artifactId>
<version>50</version>
<version>55</version>
</parent>
<groupId>io.takari.maven</groupId>
<artifactId>maven-timeline</artifactId>
<version>1.9-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<packaging>takari-maven-component</packaging>

<name>Maven Timeline extension</name>
<description>Output the timeline of a build to am html file</description>
<url>https://github.com/dgageot/maven-timeline</url>
<url>https://github.com/takari/maven-timeline</url>

<licenses>
<license>
Expand All @@ -24,23 +25,28 @@
</licenses>

<properties>
<takari.lifecycleVersion>2.1.0</takari.lifecycleVersion>
<takari.javaSourceVersion>7</takari.javaSourceVersion>

<maven.version>3.2.5</maven.version>
<takari.javaSourceVersion>8</takari.javaSourceVersion>
<version.maven>3.6.3</version.maven>
<version.slf4j>1.7.36</version.slf4j>
</properties>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${version.slf4j}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven.version}</version>
<version>${version.maven}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
<version>${version.maven}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -49,15 +55,24 @@
<version>1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.12.2</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<version>2.11.0</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${version.slf4j}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
60 changes: 27 additions & 33 deletions src/main/java/io/takari/maven/timeline/BuildEventsExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,45 @@
*/
package io.takari.maven.timeline;

import javax.inject.Named;
import javax.inject.Singleton;

import io.takari.maven.timeline.buildevents.BuildEventListener;
import io.takari.maven.timeline.buildevents.ExecutionListenerChain;

import java.io.File;

import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.AbstractMavenLifecycleParticipant;
import org.apache.maven.execution.ExecutionListener;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

@Singleton
@Named("buildevents")
public class BuildEventsExtension extends AbstractMavenLifecycleParticipant {
private static final String OUTPUT_FILE = "execution.metrics.output.file";
private static final String DEFAULT_FILE_DESTINATION = "target/execution-metrics.json";

@Override
public void afterProjectsRead(MavenSession session) {
MavenExecutionRequest request = session.getRequest();
ExecutionListener original = request.getExecutionListener();
BuildEventListener listener = new BuildEventListener(logFile(session), mavenTimelineFile(session), session.getCurrentProject().getArtifactId(), session.getCurrentProject().getGroupId());
ExecutionListener chain = new ExecutionListenerChain(original, listener);
request.setExecutionListener(chain);
}

private File mavenTimelineFile(MavenSession session) {
return new File(session.getExecutionRootDirectory(), "target/timeline/maven-timeline.js");
}
private static final String OUTPUT_FILE = "execution.metrics.output.file";
private static final String DEFAULT_FILE_DESTINATION = "target/execution-metrics.json";

@Override
public void afterProjectsRead(MavenSession session) {
MavenExecutionRequest request = session.getRequest();
ExecutionListener original = request.getExecutionListener();
BuildEventListener listener = new BuildEventListener(
logFile(session),
mavenTimelineFile(session),
session.getCurrentProject().getArtifactId(),
session.getCurrentProject().getGroupId());
ExecutionListener chain = new ExecutionListenerChain(original, listener);
request.setExecutionListener(chain);
}

private File logFile(MavenSession session) {
String path = session.getUserProperties().getProperty(OUTPUT_FILE, DEFAULT_FILE_DESTINATION);
if (new File(path).isAbsolute()) {
return new File(path);
private File mavenTimelineFile(MavenSession session) {
return new File(session.getExecutionRootDirectory(), "target/timeline/maven-timeline.js");
}
String buildDir = session.getExecutionRootDirectory();
return new File(buildDir, path);
}

public static void main(String[] args) {
String output = new DateTime(DateTimeZone.UTC).toString();
System.out.println(output);
}
private File logFile(MavenSession session) {
String path = session.getUserProperties().getProperty(OUTPUT_FILE, DEFAULT_FILE_DESTINATION);
if (new File(path).isAbsolute()) {
return new File(path);
}
String buildDir = session.getExecutionRootDirectory();
return new File(buildDir, path);
}
}
54 changes: 24 additions & 30 deletions src/main/java/io/takari/maven/timeline/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,31 @@
@SuppressWarnings({"FieldCanBeLocal", "unused"}) // needed for serialization
public class Event {

private final long start;
private long end;
private long duration;
private final long trackNum;
private final String groupId;
private final String artifactId;
private final String phase;
private final String goal;
private final String id;
private final long start;
private long end;
private long duration;
private final long trackNum;
private final String groupId;
private final String artifactId;
private final String phase;
private final String goal;
private final String id;

public Event(long trackNum,
long start,
String groupId,
String artifactId,
String phase,
String goal,
String id) {
this.start = start;
this.trackNum = trackNum;
this.groupId = groupId;
this.artifactId = artifactId;
this.phase = phase;
this.goal = goal;
this.id = id;
}
public Event(long trackNum, long start, String groupId, String artifactId, String phase, String goal, String id) {
this.start = start;
this.trackNum = trackNum;
this.groupId = groupId;
this.artifactId = artifactId;
this.phase = phase;
this.goal = goal;
this.id = id;
}

public void setEnd(long end) {
this.end = end;
}
public void setEnd(long end) {
this.end = end;
}

public void setDuration(long duration) {
this.duration = duration;
}
public void setDuration(long duration) {
this.duration = duration;
}
}
24 changes: 12 additions & 12 deletions src/main/java/io/takari/maven/timeline/Timeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
@SuppressWarnings({"FieldCanBeLocal", "unused"}) // needed for serialization
public class Timeline {

private final long start;
private final long end;
private final String groupId;
private final String artifactId;
private final List<Event> events;
private final long start;
private final long end;
private final String groupId;
private final String artifactId;
private final List<Event> events;

public Timeline(long start, long end, String groupId, String artifactId, List<Event> events) {
this.start = start;
this.end = end;
this.groupId = groupId;
this.artifactId = artifactId;
this.events = events;
}
public Timeline(long start, long end, String groupId, String artifactId, List<Event> events) {
this.start = start;
this.end = end;
this.groupId = groupId;
this.artifactId = artifactId;
this.events = events;
}
}
13 changes: 6 additions & 7 deletions src/main/java/io/takari/maven/timeline/TimelineSerializer.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package io.takari.maven.timeline;

import java.io.Writer;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.Writer;

public class TimelineSerializer {

private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
public static void serialize(Writer writer, Timeline timeline) {
gson.toJson(timeline, writer);
}
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();

public static void serialize(Writer writer, Timeline timeline) {
gson.toJson(timeline, writer);
}
}
Loading

0 comments on commit b8f3751

Please sign in to comment.