From 9db5583d0d4c0638fe55d835eaac83678e844a05 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 09:29:38 +0100 Subject: [PATCH 01/46] feat: add .idea folder to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 32dfb8e..43bf9c0 100755 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ target .project .classpath .settings +# IDEA generated +.idea # Release plugin release.properties # TestNG within Eclipse. From ad5e24df0765204367b642d919ad6f946b43d1f1 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 09:31:22 +0100 Subject: [PATCH 02/46] feat: add org.json dependency to pom.xml --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 9eaff51..cc941a7 100755 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,11 @@ + + org.json + json + 20190722 + org.testng testng From d8cb1535e34edc0929d9289af0bb335668fe02fa Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 09:48:02 +0100 Subject: [PATCH 03/46] feat: add toJSON function in DiscoveryTimer --- .../java/com/soebes/maven/extensions/DiscoveryTimer.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java index e57d85b..a60fd46 100644 --- a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java +++ b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java @@ -19,6 +19,7 @@ * under the License. */ +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,4 +53,9 @@ public void report() LOGGER.info( "------------------------------------------------------------------------" ); } + public JSONObject toJSON() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("discoveryTime", String.format( "%8d", time.getElapsedTime() )); + return jsonObject; + } } From 8d5fed8962fb5cfe2e9c55dd86891971b149919c Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:09:26 +0100 Subject: [PATCH 04/46] feat: add toJSON function in MojoTimer --- .../soebes/maven/extensions/MojoTimer.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/com/soebes/maven/extensions/MojoTimer.java b/src/main/java/com/soebes/maven/extensions/MojoTimer.java index 2e539ae..e4833b3 100644 --- a/src/main/java/com/soebes/maven/extensions/MojoTimer.java +++ b/src/main/java/com/soebes/maven/extensions/MojoTimer.java @@ -27,6 +27,7 @@ import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -142,4 +143,24 @@ public void report() LOGGER.info( "{} : {}", item.getKey().getId(), item.getValue().getElapsedTime() ); } } + + public JSONObject toJSON() { + JSONObject jsonObject = new JSONObject(); + + for ( Entry item : this.timerEvents.entrySet() ) + { + String artifactId = item.getKey().getProject().getArtifactId(); + String phase = item.getKey().getMojo().getPhase(); + + JSONObject artifactObject = jsonObject.has(artifactId) ? jsonObject.getJSONObject(artifactId) : new JSONObject(); + long phaseResult = artifactObject.has(phase) ? (long) artifactObject.get(phase) : 0; + + phaseResult += item.getValue().getElapsedTime(); + + artifactObject.put(phase, phaseResult); + jsonObject.put(artifactId, artifactObject); + } + + return jsonObject; + } } From acb3946cf2b66be973d4231d983492d24d2f790a Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:11:19 +0100 Subject: [PATCH 05/46] fix: move opening braces to next line --- .../java/com/soebes/maven/extensions/DiscoveryTimer.java | 3 ++- src/main/java/com/soebes/maven/extensions/GoalTimer.java | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java index a60fd46..1ae0691 100644 --- a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java +++ b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java @@ -53,7 +53,8 @@ public void report() LOGGER.info( "------------------------------------------------------------------------" ); } - public JSONObject toJSON() { + public JSONObject toJSON() + { JSONObject jsonObject = new JSONObject(); jsonObject.put("discoveryTime", String.format( "%8d", time.getElapsedTime() )); return jsonObject; diff --git a/src/main/java/com/soebes/maven/extensions/GoalTimer.java b/src/main/java/com/soebes/maven/extensions/GoalTimer.java index 83f9242..e609873 100644 --- a/src/main/java/com/soebes/maven/extensions/GoalTimer.java +++ b/src/main/java/com/soebes/maven/extensions/GoalTimer.java @@ -7,6 +7,7 @@ import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,4 +67,9 @@ public void report() item.getKey().getId() ); } } + + public JSONObject toJSON() + { + + } } From 8eef35f392d740e77c5d5933bae52f807a0e3171 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:15:10 +0100 Subject: [PATCH 06/46] fix: move opening braces to next line in MojoTimer --- src/main/java/com/soebes/maven/extensions/MojoTimer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/MojoTimer.java b/src/main/java/com/soebes/maven/extensions/MojoTimer.java index e4833b3..2c02d66 100644 --- a/src/main/java/com/soebes/maven/extensions/MojoTimer.java +++ b/src/main/java/com/soebes/maven/extensions/MojoTimer.java @@ -144,7 +144,8 @@ public void report() } } - public JSONObject toJSON() { + public JSONObject toJSON() + { JSONObject jsonObject = new JSONObject(); for ( Entry item : this.timerEvents.entrySet() ) From 7d90ac421048ab1ccc6952d7aa4249bc7997eaa8 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:16:27 +0100 Subject: [PATCH 07/46] fix: change discoveryTime type from String to long --- src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java index 1ae0691..fa94cf2 100644 --- a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java +++ b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java @@ -56,7 +56,7 @@ public void report() public JSONObject toJSON() { JSONObject jsonObject = new JSONObject(); - jsonObject.put("discoveryTime", String.format( "%8d", time.getElapsedTime() )); + jsonObject.put("discoveryTime", time.getElapsedTime()); return jsonObject; } } From 3c5c5095e24f211af3325d485171dd8a38b07e9e Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:17:02 +0100 Subject: [PATCH 08/46] feat: add toJSON function in GoalTimer --- src/main/java/com/soebes/maven/extensions/GoalTimer.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/soebes/maven/extensions/GoalTimer.java b/src/main/java/com/soebes/maven/extensions/GoalTimer.java index e609873..0e922c1 100644 --- a/src/main/java/com/soebes/maven/extensions/GoalTimer.java +++ b/src/main/java/com/soebes/maven/extensions/GoalTimer.java @@ -70,6 +70,13 @@ public void report() public JSONObject toJSON() { + JSONObject jsonObject = new JSONObject(); + for ( Entry item : this.timerEvents.entrySet() ) + { + jsonObject.put(item.getKey().getId(), item.getValue().getElapsedTime()); + } + + return jsonObject; } } From 8bd0f7bf91d7ac882528a57ef2fccd8aacbc5838 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:23:49 +0100 Subject: [PATCH 09/46] feat: add toJSON function in InstallTimer --- .../extensions/artifact/InstallTimer.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java index 9a6a0bc..0c48e1f 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java @@ -21,7 +21,7 @@ import java.text.NumberFormat; import java.util.Map.Entry; - +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,4 +63,28 @@ public void report() LOGGER.info( "------------------------------------------------------------------------" ); } + public JSONObject toJSON() + { + JSONObject jsonObject = new JSONObject(); + + long totalInstallationTime = 0; + long totalInstallationSize = 0; + + for ( Entry item : this.getTimerEvents().entrySet() ) + { + totalInstallationTime += item.getValue().getElapsedTime(); + totalInstallationSize += item.getValue().getSize(); + + jsonObject.put(item.getKey(), item.getValue().getElapsedTime()); + } + + double mibPerSeconds = calculateMegabytesPerSeconds( totalInstallationTime, totalInstallationSize ); + + jsonObject.put("installaionTime", totalInstallationTime); + jsonObject.put("installaionSize", totalInstallationSize); + jsonObject.put("installaionRate", mibPerSeconds); + + return jsonObject; + } + } From 5369904048e41239624790ae117ef07be5b76c25 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:32:15 +0100 Subject: [PATCH 10/46] fix: refactor JSON output in InstallTimer --- .../maven/extensions/artifact/InstallTimer.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java index 0c48e1f..7f705ca 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java @@ -75,14 +75,18 @@ public JSONObject toJSON() totalInstallationTime += item.getValue().getElapsedTime(); totalInstallationSize += item.getValue().getSize(); - jsonObject.put(item.getKey(), item.getValue().getElapsedTime()); + JSONObject jsonItem = new JSONObject(); + jsonItem.put("time", item.getValue().getElapsedTime()); + jsonItem.put("size", item.getValue().getSize()); + + jsonObject.put(item.getKey(), jsonItem); } double mibPerSeconds = calculateMegabytesPerSeconds( totalInstallationTime, totalInstallationSize ); - jsonObject.put("installaionTime", totalInstallationTime); - jsonObject.put("installaionSize", totalInstallationSize); - jsonObject.put("installaionRate", mibPerSeconds); + jsonObject.put("time", totalInstallationTime); + jsonObject.put("size", totalInstallationSize); + jsonObject.put("rate", mibPerSeconds); return jsonObject; } From 52493af50a88e89f355db923383adbe28a4d553a Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:33:06 +0100 Subject: [PATCH 11/46] feat: add toJSON function in DownloadTimer --- .../extensions/artifact/DownloadTimer.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java index 0542365..70816c6 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java @@ -21,7 +21,7 @@ import java.text.NumberFormat; import java.util.Map.Entry; - +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,4 +63,31 @@ public void report() } + public JSONObject toJSON() + { + JSONObject jsonObject = new JSONObject(); + + long totalInstallationTime = 0; + long totalInstallationSize = 0; + + for ( Entry item : this.getTimerEvents().entrySet() ) + { + totalInstallationTime += item.getValue().getElapsedTime(); + totalInstallationSize += item.getValue().getSize(); + + JSONObject jsonItem = new JSONObject(); + jsonItem.put("time", item.getValue().getElapsedTime()); + jsonItem.put("size", item.getValue().getSize()); + + jsonObject.put(item.getKey(), jsonItem); + } + + double mibPerSeconds = calculateMegabytesPerSeconds( totalInstallationTime, totalInstallationSize ); + + jsonObject.put("time", totalInstallationTime); + jsonObject.put("size", totalInstallationSize); + jsonObject.put("rate", mibPerSeconds); + + return jsonObject; + } } From 7daeaed3d8bc02184b7853e81da357cac87eee35 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:35:55 +0100 Subject: [PATCH 12/46] feat: add toJSON function in DeployTimer --- .../extensions/artifact/DeployTimer.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java index 68a8deb..0b857c4 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java @@ -21,7 +21,7 @@ import java.text.NumberFormat; import java.util.Map.Entry; - +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,4 +62,32 @@ public void report() LOGGER.info( "------------------------------------------------------------------------" ); } + public JSONObject toJSON() + { + JSONObject jsonObject = new JSONObject(); + + long totalInstallationTime = 0; + long totalInstallationSize = 0; + + for ( Entry item : this.getTimerEvents().entrySet() ) + { + totalInstallationTime += item.getValue().getElapsedTime(); + totalInstallationSize += item.getValue().getSize(); + + JSONObject jsonItem = new JSONObject(); + jsonItem.put("time", item.getValue().getElapsedTime()); + jsonItem.put("size", item.getValue().getSize()); + + jsonObject.put(item.getKey(), jsonItem); + } + + double mibPerSeconds = calculateMegabytesPerSeconds( totalInstallationTime, totalInstallationSize ); + + jsonObject.put("time", totalInstallationTime); + jsonObject.put("size", totalInstallationSize); + jsonObject.put("rate", mibPerSeconds); + + return jsonObject; + } + } From 8f0b3a3fe3e39ab05360f72d2920cbd3f8f4d8a0 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:37:48 +0100 Subject: [PATCH 13/46] feat: add toJSON function in MetadataInstallTimer --- .../metadata/MetadataInstallTimer.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java b/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java index 1957b16..c953aaf 100644 --- a/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java +++ b/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java @@ -21,7 +21,7 @@ import java.text.NumberFormat; import java.util.Map.Entry; - +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,4 +62,27 @@ public void report() LOGGER.info( "------------------------------------------------------------------------" ); } + public JSONObject toJSON() { + JSONObject jsonObject = new JSONObject(); + + long totalInstallationTime = 0; + long totalInstallationSize = 0; + + for ( Entry item : this.getTimerEvents().entrySet() ) + { + totalInstallationTime += item.getValue().getElapsedTime(); + totalInstallationSize += item.getValue().getSize(); + + JSONObject jsonItem = new JSONObject(); + jsonItem.put("time", item.getValue().getElapsedTime()); + jsonItem.put("size", item.getValue().getSize()); + + jsonObject.put(item.getKey(), jsonItem); + } + + jsonObject.put("time", totalInstallationTime); + jsonObject.put("size", totalInstallationSize); + + return jsonObject; + } } From f71fb70a0abf89317c2c603c77de33c5bbb7f4e4 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:41:23 +0100 Subject: [PATCH 14/46] refactor: move all toJSON in AbstractMetadataTimer classes to parent class --- .../artifact/AbstractArtifactTimer.java | 29 +++++++++++++++++++ .../extensions/artifact/DeployTimer.java | 29 ------------------- .../extensions/artifact/DownloadTimer.java | 28 ------------------ .../extensions/artifact/InstallTimer.java | 29 ------------------- 4 files changed, 29 insertions(+), 86 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java index 2cf94c8..e79fcc8 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java @@ -20,10 +20,12 @@ */ import java.util.Map; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.artifact.Artifact; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -98,4 +100,31 @@ protected double calculateMegabytesPerSeconds( long timeInMilliseconds, long siz return (double) sizeInBytes / dividerTime / MiB; } + public JSONObject toJSON() + { + JSONObject jsonObject = new JSONObject(); + + long totalInstallationTime = 0; + long totalInstallationSize = 0; + + for ( Entry item : this.getTimerEvents().entrySet() ) + { + totalInstallationTime += item.getValue().getElapsedTime(); + totalInstallationSize += item.getValue().getSize(); + + JSONObject jsonItem = new JSONObject(); + jsonItem.put("time", item.getValue().getElapsedTime()); + jsonItem.put("size", item.getValue().getSize()); + + jsonObject.put(item.getKey(), jsonItem); + } + + double mibPerSeconds = calculateMegabytesPerSeconds( totalInstallationTime, totalInstallationSize ); + + jsonObject.put("time", totalInstallationTime); + jsonObject.put("size", totalInstallationSize); + jsonObject.put("rate", mibPerSeconds); + + return jsonObject; + } } diff --git a/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java index 0b857c4..2623cf5 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java @@ -61,33 +61,4 @@ public void report() NumberFormat.getNumberInstance().format( mibPerSeconds ) ); LOGGER.info( "------------------------------------------------------------------------" ); } - - public JSONObject toJSON() - { - JSONObject jsonObject = new JSONObject(); - - long totalInstallationTime = 0; - long totalInstallationSize = 0; - - for ( Entry item : this.getTimerEvents().entrySet() ) - { - totalInstallationTime += item.getValue().getElapsedTime(); - totalInstallationSize += item.getValue().getSize(); - - JSONObject jsonItem = new JSONObject(); - jsonItem.put("time", item.getValue().getElapsedTime()); - jsonItem.put("size", item.getValue().getSize()); - - jsonObject.put(item.getKey(), jsonItem); - } - - double mibPerSeconds = calculateMegabytesPerSeconds( totalInstallationTime, totalInstallationSize ); - - jsonObject.put("time", totalInstallationTime); - jsonObject.put("size", totalInstallationSize); - jsonObject.put("rate", mibPerSeconds); - - return jsonObject; - } - } diff --git a/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java index 70816c6..a81272d 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java @@ -62,32 +62,4 @@ public void report() NumberFormat.getNumberInstance().format( mibPerSeconds ) ); } - - public JSONObject toJSON() - { - JSONObject jsonObject = new JSONObject(); - - long totalInstallationTime = 0; - long totalInstallationSize = 0; - - for ( Entry item : this.getTimerEvents().entrySet() ) - { - totalInstallationTime += item.getValue().getElapsedTime(); - totalInstallationSize += item.getValue().getSize(); - - JSONObject jsonItem = new JSONObject(); - jsonItem.put("time", item.getValue().getElapsedTime()); - jsonItem.put("size", item.getValue().getSize()); - - jsonObject.put(item.getKey(), jsonItem); - } - - double mibPerSeconds = calculateMegabytesPerSeconds( totalInstallationTime, totalInstallationSize ); - - jsonObject.put("time", totalInstallationTime); - jsonObject.put("size", totalInstallationSize); - jsonObject.put("rate", mibPerSeconds); - - return jsonObject; - } } diff --git a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java index 7f705ca..6899a80 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java @@ -62,33 +62,4 @@ public void report() NumberFormat.getNumberInstance().format( mibPerSeconds ) ); LOGGER.info( "------------------------------------------------------------------------" ); } - - public JSONObject toJSON() - { - JSONObject jsonObject = new JSONObject(); - - long totalInstallationTime = 0; - long totalInstallationSize = 0; - - for ( Entry item : this.getTimerEvents().entrySet() ) - { - totalInstallationTime += item.getValue().getElapsedTime(); - totalInstallationSize += item.getValue().getSize(); - - JSONObject jsonItem = new JSONObject(); - jsonItem.put("time", item.getValue().getElapsedTime()); - jsonItem.put("size", item.getValue().getSize()); - - jsonObject.put(item.getKey(), jsonItem); - } - - double mibPerSeconds = calculateMegabytesPerSeconds( totalInstallationTime, totalInstallationSize ); - - jsonObject.put("time", totalInstallationTime); - jsonObject.put("size", totalInstallationSize); - jsonObject.put("rate", mibPerSeconds); - - return jsonObject; - } - } From d95e096b9150f58dbfe9cf2e6be2797ca3c5a13b Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:43:03 +0100 Subject: [PATCH 15/46] fix: remove toJSON function from MetadataInstallTimer --- .../metadata/MetadataInstallTimer.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java b/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java index c953aaf..b5b91b2 100644 --- a/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java +++ b/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java @@ -61,28 +61,4 @@ public void report() // NumberFormat.getIntegerInstance().format( totalInstallationSize ) ); LOGGER.info( "------------------------------------------------------------------------" ); } - - public JSONObject toJSON() { - JSONObject jsonObject = new JSONObject(); - - long totalInstallationTime = 0; - long totalInstallationSize = 0; - - for ( Entry item : this.getTimerEvents().entrySet() ) - { - totalInstallationTime += item.getValue().getElapsedTime(); - totalInstallationSize += item.getValue().getSize(); - - JSONObject jsonItem = new JSONObject(); - jsonItem.put("time", item.getValue().getElapsedTime()); - jsonItem.put("size", item.getValue().getSize()); - - jsonObject.put(item.getKey(), jsonItem); - } - - jsonObject.put("time", totalInstallationTime); - jsonObject.put("size", totalInstallationSize); - - return jsonObject; - } } From d5ddc8b4e03a1060966bdd15323821d517ae1e4e Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:43:20 +0100 Subject: [PATCH 16/46] feat: add toJSON function in AbstractMetadataTimer --- .../metadata/AbstractMetadataTimer.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/com/soebes/maven/extensions/metadata/AbstractMetadataTimer.java b/src/main/java/com/soebes/maven/extensions/metadata/AbstractMetadataTimer.java index ee01ab5..a0eb813 100644 --- a/src/main/java/com/soebes/maven/extensions/metadata/AbstractMetadataTimer.java +++ b/src/main/java/com/soebes/maven/extensions/metadata/AbstractMetadataTimer.java @@ -20,12 +20,14 @@ */ import java.util.Map; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.metadata.Metadata; import com.soebes.maven.extensions.TimePlusSize; +import org.json.JSONObject; /** * @author Karl Heinz Marbaise kama@soebes.de @@ -81,4 +83,27 @@ public void stop( RepositoryEvent event ) getTimerEvents().get( metadataId ).setSize( size ); } + public JSONObject toJSON() { + JSONObject jsonObject = new JSONObject(); + + long totalInstallationTime = 0; + long totalInstallationSize = 0; + + for ( Entry item : this.getTimerEvents().entrySet() ) + { + totalInstallationTime += item.getValue().getElapsedTime(); + totalInstallationSize += item.getValue().getSize(); + + JSONObject jsonItem = new JSONObject(); + jsonItem.put("time", item.getValue().getElapsedTime()); + jsonItem.put("size", item.getValue().getSize()); + + jsonObject.put(item.getKey(), jsonItem); + } + + jsonObject.put("time", totalInstallationTime); + jsonObject.put("size", totalInstallationSize); + + return jsonObject; + } } From 763770706b42bcb8d968f3400fa3cd331e26e07f Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:45:45 +0100 Subject: [PATCH 17/46] feat: add toJSON function in ProjectTimer --- .../com/soebes/maven/extensions/ProjectTimer.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/soebes/maven/extensions/ProjectTimer.java b/src/main/java/com/soebes/maven/extensions/ProjectTimer.java index 76be126..c619844 100644 --- a/src/main/java/com/soebes/maven/extensions/ProjectTimer.java +++ b/src/main/java/com/soebes/maven/extensions/ProjectTimer.java @@ -25,6 +25,7 @@ import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.project.MavenProject; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,4 +81,16 @@ public void report() LOGGER.info( "ProjectTimer: {} : {}", item.getKey(), item.getValue().getElapsedTime() ); } } + + public JSONObject toJSON() + { + JSONObject jsonObject = new JSONObject(); + + for ( Entry item : this.timerEvents.entrySet() ) + { + jsonObject.put(item.getKey(), item.getValue().getElapsedTime()); + } + + return jsonObject; + } } From cda691453ceebd5e404b1322f748fa364e98dab7 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:47:24 +0100 Subject: [PATCH 18/46] refactor: move stdout report to report function --- .../com/soebes/maven/extensions/BuildTimeProfiler.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index c239f61..4063859 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -391,6 +391,11 @@ private void executionRequestEventHandler( MavenExecutionRequest event ) } private void executionResultEventHandler( MavenExecutionResult event ) + { + report(event); + } + + private void report(MavenExecutionResult event) { orderLifeCycleOnPreparedOrder( lifeCyclePhases ); @@ -445,7 +450,7 @@ private void executionResultEventHandler( MavenExecutionResult event ) for ( Entry pluginInPhase : plugisInPhase.entrySet() ) { LOGGER.info( "{} ms: {}", String.format( "%8d", pluginInPhase.getValue().getElapsedTime() ), - pluginInPhase.getKey().getMojo().getFullId() ); + pluginInPhase.getKey().getMojo().getFullId() ); } } From 39b61b76a235001416f4154dcdc995df7959390d Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:49:44 +0100 Subject: [PATCH 19/46] feat: use getters when the report is not a JSONObject --- src/main/java/com/soebes/maven/extensions/ForkTimer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/soebes/maven/extensions/ForkTimer.java b/src/main/java/com/soebes/maven/extensions/ForkTimer.java index 1eb279c..817a7a5 100644 --- a/src/main/java/com/soebes/maven/extensions/ForkTimer.java +++ b/src/main/java/com/soebes/maven/extensions/ForkTimer.java @@ -53,4 +53,7 @@ public void report() LOGGER.info( "ForkTime: {}", this.time.getElapsedTime() ); } + public long getTime() { + return this.time.getElapsedTime(); + } } From b71d4795e54782a684e5b6c939048f61d619d3dd Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:50:07 +0100 Subject: [PATCH 20/46] feat: use getters when the report is not a JSONObject --- .../java/com/soebes/maven/extensions/DiscoveryTimer.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java index fa94cf2..fa98fa2 100644 --- a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java +++ b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java @@ -53,10 +53,8 @@ public void report() LOGGER.info( "------------------------------------------------------------------------" ); } - public JSONObject toJSON() + public long getTime() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("discoveryTime", time.getElapsedTime()); - return jsonObject; + return this.time.getElapsedTime(); } } From f27c9ed3f306a48fdb645a476fc67fc80fbc51f9 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 10:55:36 +0100 Subject: [PATCH 21/46] feat: add toJSON function in BuildTimeProfiler --- .../maven/extensions/BuildTimeProfiler.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index 4063859..d0907cf 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -37,6 +37,7 @@ import org.apache.maven.project.MavenProject; import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.RepositoryEvent.EventType; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -476,6 +477,25 @@ private void report(MavenExecutionResult event) forkProject.report(); } + private JSONObject toJSON() + { + JSONObject jsonObject = new JSONObject(); + + jsonObject.put("discoveryTime", discoveryTimer.getTime()); + jsonObject.put("mojos", mojoTimer.toJSON()); + jsonObject.put("goals", goalTimer.toJSON()); + jsonObject.put("install", installTimer.toJSON()); + jsonObject.put("download", downloadTimer.toJSON()); + jsonObject.put("deploy", deployTimer.toJSON()); + jsonObject.put("metadataInstall", metadataInstallTimer.toJSON()); + jsonObject.put("metadataDownload", metadataDownloadTimer.toJSON()); + jsonObject.put("metadataDeployment", metadataDeploymentTimer.toJSON()); + jsonObject.put("forkTime", forkTimer.getTime()); + jsonObject.put("forkProject", forkProject.toJSON()); + + return jsonObject; + } + private ProjectKey mavenProjectToProjectKey( MavenProject project ) { return new ProjectKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ); From 7cedd23d1c3f71fe0231f76ad868f996198267d9 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 11:42:09 +0100 Subject: [PATCH 22/46] fix: handle infinite values in AbstractArtifactTimer --- .../soebes/maven/extensions/artifact/AbstractArtifactTimer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java index e79fcc8..fabcfcf 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java @@ -123,7 +123,7 @@ public JSONObject toJSON() jsonObject.put("time", totalInstallationTime); jsonObject.put("size", totalInstallationSize); - jsonObject.put("rate", mibPerSeconds); + jsonObject.put("rate", ("" + mibPerSeconds).equals("NaN") ? null : mibPerSeconds); return jsonObject; } From 541855ff83d60647c6b64228ad8e89661171a448 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 11:43:05 +0100 Subject: [PATCH 23/46] feat: temporary feature to print JSON result --- .../com/soebes/maven/extensions/BuildTimeProfiler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index d0907cf..eabe146 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -19,6 +19,8 @@ * under the License. */ +import java.io.FileWriter; +import java.io.IOException; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -394,6 +396,12 @@ private void executionRequestEventHandler( MavenExecutionRequest event ) private void executionResultEventHandler( MavenExecutionResult event ) { report(event); + + try (FileWriter file = new FileWriter("report.json")) { + file.write(toJSON().toString()); + } catch (IOException e) { + LOGGER.error(e.getMessage()); + } } private void report(MavenExecutionResult event) @@ -482,7 +490,7 @@ private JSONObject toJSON() JSONObject jsonObject = new JSONObject(); jsonObject.put("discoveryTime", discoveryTimer.getTime()); - jsonObject.put("mojos", mojoTimer.toJSON()); + jsonObject.put("build", mojoTimer.toJSON()); jsonObject.put("goals", goalTimer.toJSON()); jsonObject.put("install", installTimer.toJSON()); jsonObject.put("download", downloadTimer.toJSON()); From 57b6adf63c12008e7fab48ace90f2586219e31da Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 11:43:30 +0100 Subject: [PATCH 24/46] feat: define plugins and phases sections in JSON output --- .../com/soebes/maven/extensions/MojoTimer.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/MojoTimer.java b/src/main/java/com/soebes/maven/extensions/MojoTimer.java index 2c02d66..11f4d46 100644 --- a/src/main/java/com/soebes/maven/extensions/MojoTimer.java +++ b/src/main/java/com/soebes/maven/extensions/MojoTimer.java @@ -147,6 +147,9 @@ public void report() public JSONObject toJSON() { JSONObject jsonObject = new JSONObject(); + JSONObject projectObject = new JSONObject(); + JSONObject phaseObject = new JSONObject(); + JSONObject pluginsObject = new JSONObject(); for ( Entry item : this.timerEvents.entrySet() ) { @@ -159,9 +162,20 @@ public JSONObject toJSON() phaseResult += item.getValue().getElapsedTime(); artifactObject.put(phase, phaseResult); - jsonObject.put(artifactId, artifactObject); + projectObject.put(artifactId, artifactObject); + + phaseObject.put(phase, phaseObject.has(phase) ? (long) phaseObject.get(phase) + phaseResult : phaseResult); + + if (!pluginsObject.has(phase)) + pluginsObject.put(phase, new JSONObject()); + + ((JSONObject) pluginsObject.get(phase)).put(item.getKey().getMojo().getFullId(), item.getValue().getElapsedTime()); } + jsonObject.put("projects", projectObject); + jsonObject.put("phases", phaseObject); + jsonObject.put("plugins", pluginsObject); + return jsonObject; } } From 2a1bbb3bbce3fb45a981f9941e91bfab07da90aa Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 12:29:47 +0100 Subject: [PATCH 25/46] fix: error in plugins section JSON structure --- .../soebes/maven/extensions/MojoTimer.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/MojoTimer.java b/src/main/java/com/soebes/maven/extensions/MojoTimer.java index 11f4d46..f59004a 100644 --- a/src/main/java/com/soebes/maven/extensions/MojoTimer.java +++ b/src/main/java/com/soebes/maven/extensions/MojoTimer.java @@ -155,21 +155,34 @@ public JSONObject toJSON() { String artifactId = item.getKey().getProject().getArtifactId(); String phase = item.getKey().getMojo().getPhase(); + String plugin = item.getKey().getMojo().getFullId(); + long time = item.getValue().getElapsedTime(); - JSONObject artifactObject = jsonObject.has(artifactId) ? jsonObject.getJSONObject(artifactId) : new JSONObject(); + // Projects section + + JSONObject artifactObject = projectObject.has(artifactId) ? projectObject.getJSONObject(artifactId) : new JSONObject(); long phaseResult = artifactObject.has(phase) ? (long) artifactObject.get(phase) : 0; - phaseResult += item.getValue().getElapsedTime(); + phaseResult += time; artifactObject.put(phase, phaseResult); projectObject.put(artifactId, artifactObject); + // Phases section + phaseObject.put(phase, phaseObject.has(phase) ? (long) phaseObject.get(phase) + phaseResult : phaseResult); + // Plugins section + if (!pluginsObject.has(phase)) pluginsObject.put(phase, new JSONObject()); - ((JSONObject) pluginsObject.get(phase)).put(item.getKey().getMojo().getFullId(), item.getValue().getElapsedTime()); + long pluginResult = ((JSONObject) pluginsObject.get(phase)).has(plugin) ? + (long) ((JSONObject) pluginsObject.get(phase)).get(plugin) : 0; + + pluginResult += time; + + ((JSONObject) pluginsObject.get(phase)).put(plugin, pluginResult); } jsonObject.put("projects", projectObject); From 33dd5a7eac8a67d4072708f7d2d339805c84cc53 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 13:03:35 +0100 Subject: [PATCH 26/46] feat: make output report selectable via maven-buildtime-profiler-output property --- .../maven/extensions/BuildTimeProfiler.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index eabe146..5970542 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -395,13 +395,29 @@ private void executionRequestEventHandler( MavenExecutionRequest event ) private void executionResultEventHandler( MavenExecutionResult event ) { - report(event); - try (FileWriter file = new FileWriter("report.json")) { - file.write(toJSON().toString()); - } catch (IOException e) { - LOGGER.error(e.getMessage()); + String output = event.getProject().getProperties().getProperty("maven-buildtime-profiler"); + + if (output != null) + { + switch (output.toLowerCase()) + { + case "json": + try (FileWriter file = new FileWriter("report.json")) + { + file.write(toJSON().toString()); + } catch (IOException e) { + LOGGER.error(e.getMessage()); + } + return; + case "stdout": + default: + report(event); + return; + } } + + report(event); } private void report(MavenExecutionResult event) From 8cfae643e9b8ff7690e15e90a639028cddb6fdaf Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 13:33:05 +0100 Subject: [PATCH 27/46] feat: make output file selectable via maven-buildtime-profiler-directory property --- .../maven/extensions/BuildTimeProfiler.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index 5970542..f53473b 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -19,6 +19,7 @@ * under the License. */ +import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Collections; @@ -395,26 +396,34 @@ private void executionRequestEventHandler( MavenExecutionRequest event ) private void executionResultEventHandler( MavenExecutionResult event ) { - String output = event.getProject().getProperties().getProperty("maven-buildtime-profiler"); + String filename = ""; + String body = ""; if (output != null) { switch (output.toLowerCase()) { case "json": - try (FileWriter file = new FileWriter("report.json")) - { - file.write(toJSON().toString()); - } catch (IOException e) { - LOGGER.error(e.getMessage()); - } - return; + body = toJSON().toString(); + filename = "report.json"; + break; case "stdout": default: report(event); return; } + + File dest = event.getProject().getProperties().containsKey("maven-buildtime-profiler-directory") ? + new File(event.getProject().getProperties().getProperty("maven-buildtime-profiler-directory"), filename) : + new File(event.getProject().getBasedir(), filename); + + try (FileWriter file = new FileWriter(dest)) + { + file.write(body); + } catch (IOException e) { + e.printStackTrace(); + } } report(event); From 61f14a453fb43ecb7540baca41c804661b794b9f Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 13:38:04 +0100 Subject: [PATCH 28/46] fix: read maven-buildtime-profiler-output instead of maven-buildtime-profiler --- .../java/com/soebes/maven/extensions/BuildTimeProfiler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index f53473b..fc11cf3 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -396,7 +396,7 @@ private void executionRequestEventHandler( MavenExecutionRequest event ) private void executionResultEventHandler( MavenExecutionResult event ) { - String output = event.getProject().getProperties().getProperty("maven-buildtime-profiler"); + String output = event.getProject().getProperties().getProperty("maven-buildtime-profiler-output"); String filename = ""; String body = ""; From 3c64d04696d0759d10a9d4fc8e7e123f317eb4da Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 13:49:03 +0100 Subject: [PATCH 29/46] fix: missing return after printing report to file --- src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index fc11cf3..a23480f 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -421,6 +421,7 @@ private void executionResultEventHandler( MavenExecutionResult event ) try (FileWriter file = new FileWriter(dest)) { file.write(body); + return; } catch (IOException e) { e.printStackTrace(); } From 9d43be82b8baeefce78d675c4aa34b8e849d8492 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 16:28:17 +0100 Subject: [PATCH 30/46] fix: time in phase subgroup incrementing badly --- src/main/java/com/soebes/maven/extensions/MojoTimer.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/MojoTimer.java b/src/main/java/com/soebes/maven/extensions/MojoTimer.java index f59004a..484e479 100644 --- a/src/main/java/com/soebes/maven/extensions/MojoTimer.java +++ b/src/main/java/com/soebes/maven/extensions/MojoTimer.java @@ -161,16 +161,13 @@ public JSONObject toJSON() // Projects section JSONObject artifactObject = projectObject.has(artifactId) ? projectObject.getJSONObject(artifactId) : new JSONObject(); - long phaseResult = artifactObject.has(phase) ? (long) artifactObject.get(phase) : 0; - phaseResult += time; - - artifactObject.put(phase, phaseResult); + artifactObject.put(phase, artifactObject.has(phase) ? (long) artifactObject.get(phase) + time : time); projectObject.put(artifactId, artifactObject); // Phases section - phaseObject.put(phase, phaseObject.has(phase) ? (long) phaseObject.get(phase) + phaseResult : phaseResult); + phaseObject.put(phase, phaseObject.has(phase) ? (long) phaseObject.get(phase) + time : time); // Plugins section From 37fa1abf2d0c10c46eedd9797a5f988539fb0df5 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 16:57:44 +0100 Subject: [PATCH 31/46] feat: improve IOException catch when writing to file --- .../com/soebes/maven/extensions/BuildTimeProfiler.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index a23480f..27edd9b 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -422,8 +422,11 @@ private void executionResultEventHandler( MavenExecutionResult event ) { file.write(body); return; - } catch (IOException e) { - e.printStackTrace(); + } + catch (IOException e) + { + LOGGER.error("Couldn't write to file at {}: {}", dest, e.getMessage()); + return; } } From 3ed233b070dc152f94d5deceb10d81fc542eca72 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 11 Feb 2020 17:08:02 +0100 Subject: [PATCH 32/46] feat: update README --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index aae9f4b..8fe7472 100755 --- a/README.md +++ b/README.md @@ -36,6 +36,23 @@ have to define the following `.mvn/extensions.xml` file: The download from Maven Central will be done by Maven itself. +This extension allows printing the report to a JSON file instead of the stdout. To enable this you +simply have to set the property `` with value `json` +under `` section in your project's pom. + +Additionally, you can set the property `` to indicate +the destination folder of the `report.json` file: + +```xml + + json + ${maven-buildtime-profiler} + ignore/ + +``` + +Note that in this example we can also set the output mode adding `-Dmaven-buildtime-profiler=stdout` to the maven command. + Here's an example of what the output will look like: ``` From 34a2dc741ad50ee7a9e68f1e7fd42293f880c7f6 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Wed, 12 Feb 2020 13:11:38 +0100 Subject: [PATCH 33/46] fix: use target/ as the default output directory --- .../java/com/soebes/maven/extensions/BuildTimeProfiler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index 27edd9b..ff57a24 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -416,7 +416,7 @@ private void executionResultEventHandler( MavenExecutionResult event ) File dest = event.getProject().getProperties().containsKey("maven-buildtime-profiler-directory") ? new File(event.getProject().getProperties().getProperty("maven-buildtime-profiler-directory"), filename) : - new File(event.getProject().getBasedir(), filename); + new File("target/", filename); try (FileWriter file = new FileWriter(dest)) { From f2f940bff83022ba29f67febc10ece8a018f23eb Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Tue, 18 Feb 2020 09:21:19 +0100 Subject: [PATCH 34/46] fix: JSON metadata field structure and use hyphen separated names --- .../soebes/maven/extensions/BuildTimeProfiler.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index ff57a24..60ef339 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -518,17 +518,19 @@ private JSONObject toJSON() { JSONObject jsonObject = new JSONObject(); - jsonObject.put("discoveryTime", discoveryTimer.getTime()); + jsonObject.put("discovery-time", discoveryTimer.getTime()); jsonObject.put("build", mojoTimer.toJSON()); jsonObject.put("goals", goalTimer.toJSON()); jsonObject.put("install", installTimer.toJSON()); jsonObject.put("download", downloadTimer.toJSON()); jsonObject.put("deploy", deployTimer.toJSON()); - jsonObject.put("metadataInstall", metadataInstallTimer.toJSON()); - jsonObject.put("metadataDownload", metadataDownloadTimer.toJSON()); - jsonObject.put("metadataDeployment", metadataDeploymentTimer.toJSON()); - jsonObject.put("forkTime", forkTimer.getTime()); - jsonObject.put("forkProject", forkProject.toJSON()); + JSONObject metadata = new JSONObject(); + metadata.put("install", metadataInstallTimer.toJSON()); + metadata.put("download", metadataDownloadTimer.toJSON()); + metadata.put("deployment", metadataDeploymentTimer.toJSON()); + jsonObject.put("metadata", metadata); + jsonObject.put("fork-time", forkTimer.getTime()); + jsonObject.put("fork-project", forkProject.toJSON()); return jsonObject; } From 0fbd4464766bf5245498b18cf67a5040f3e5968b Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Wed, 19 Feb 2020 09:41:44 +0100 Subject: [PATCH 35/46] feat: add none output mode --- .../maven/extensions/BuildTimeProfiler.java | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index 60ef339..dd7ff48 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -396,41 +396,40 @@ private void executionRequestEventHandler( MavenExecutionRequest event ) private void executionResultEventHandler( MavenExecutionResult event ) { - String output = event.getProject().getProperties().getProperty("maven-buildtime-profiler-output"); - String filename = ""; - String body = ""; + String output = event.getProject().getProperties().containsKey("maven-buildtime-profiler-output") ? + event.getProject().getProperties().getProperty("maven-buildtime-profiler-output") : + "stdout"; + String filename = null; + String body = null; - if (output != null) - { switch (output.toLowerCase()) { case "json": body = toJSON().toString(); filename = "report.json"; break; + case "none": + break; case "stdout": default: report(event); - return; } - File dest = event.getProject().getProperties().containsKey("maven-buildtime-profiler-directory") ? - new File(event.getProject().getProperties().getProperty("maven-buildtime-profiler-directory"), filename) : - new File("target/", filename); - - try (FileWriter file = new FileWriter(dest)) + if (filename != null && body != null) { - file.write(body); - return; - } - catch (IOException e) - { - LOGGER.error("Couldn't write to file at {}: {}", dest, e.getMessage()); - return; - } - } + File dest = event.getProject().getProperties().containsKey("maven-buildtime-profiler-directory") ? + new File(event.getProject().getProperties().getProperty("maven-buildtime-profiler-directory"), filename) : + new File("target/", filename); - report(event); + try (FileWriter file = new FileWriter(dest)) + { + file.write(body); + } + catch (IOException e) + { + LOGGER.warn("Couldn't write to file at {}: {}", dest, e.getMessage()); + } + } } private void report(MavenExecutionResult event) From a63a74c66924f5515fc85b3038b869951fff234d Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Wed, 19 Feb 2020 09:43:50 +0100 Subject: [PATCH 36/46] feat: update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8fe7472..6dae2b4 100755 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ the destination folder of the `report.json` file: Note that in this example we can also set the output mode adding `-Dmaven-buildtime-profiler=stdout` to the maven command. +Also, if somehow you don't want to export the profiling result you can set `` to `none`. + Here's an example of what the output will look like: ``` From f0ef6172fecc5036e89a7319c6ea6908610f0dc1 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Wed, 19 Feb 2020 10:10:56 +0100 Subject: [PATCH 37/46] feat: add total build time metric to the JSON output --- src/main/java/com/soebes/maven/extensions/MojoTimer.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/soebes/maven/extensions/MojoTimer.java b/src/main/java/com/soebes/maven/extensions/MojoTimer.java index 484e479..b9ca009 100644 --- a/src/main/java/com/soebes/maven/extensions/MojoTimer.java +++ b/src/main/java/com/soebes/maven/extensions/MojoTimer.java @@ -151,6 +151,8 @@ public JSONObject toJSON() JSONObject phaseObject = new JSONObject(); JSONObject pluginsObject = new JSONObject(); + long totalTime = 0; + for ( Entry item : this.timerEvents.entrySet() ) { String artifactId = item.getKey().getProject().getArtifactId(); @@ -180,11 +182,14 @@ public JSONObject toJSON() pluginResult += time; ((JSONObject) pluginsObject.get(phase)).put(plugin, pluginResult); + + totalTime += time; } jsonObject.put("projects", projectObject); jsonObject.put("phases", phaseObject); jsonObject.put("plugins", pluginsObject); + jsonObject.put("time", totalTime); return jsonObject; } From eb7086b00233141798009a9b8b9a1a055dff04e7 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Thu, 20 Feb 2020 09:42:42 +0100 Subject: [PATCH 38/46] feat: use .name properties instead of -name --- .../com/soebes/maven/extensions/BuildTimeProfiler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index dd7ff48..dfb1042 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -396,8 +396,8 @@ private void executionRequestEventHandler( MavenExecutionRequest event ) private void executionResultEventHandler( MavenExecutionResult event ) { - String output = event.getProject().getProperties().containsKey("maven-buildtime-profiler-output") ? - event.getProject().getProperties().getProperty("maven-buildtime-profiler-output") : + String output = event.getProject().getProperties().containsKey("maven-buildtime-profiler.output") ? + event.getProject().getProperties().getProperty("maven-buildtime-profiler.output") : "stdout"; String filename = null; String body = null; @@ -417,8 +417,8 @@ private void executionResultEventHandler( MavenExecutionResult event ) if (filename != null && body != null) { - File dest = event.getProject().getProperties().containsKey("maven-buildtime-profiler-directory") ? - new File(event.getProject().getProperties().getProperty("maven-buildtime-profiler-directory"), filename) : + File dest = event.getProject().getProperties().containsKey("maven-buildtime-profiler.directory") ? + new File(event.getProject().getProperties().getProperty("maven-buildtime-profiler.directory"), filename) : new File("target/", filename); try (FileWriter file = new FileWriter(dest)) From 0af801c6ccf484c76b5eea6ff79723da21a91e07 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Thu, 20 Feb 2020 09:44:59 +0100 Subject: [PATCH 39/46] feat: update README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6dae2b4..aa70eba 100755 --- a/README.md +++ b/README.md @@ -37,23 +37,23 @@ have to define the following `.mvn/extensions.xml` file: The download from Maven Central will be done by Maven itself. This extension allows printing the report to a JSON file instead of the stdout. To enable this you -simply have to set the property `` with value `json` +simply have to set the property `` with value `json` under `` section in your project's pom. -Additionally, you can set the property `` to indicate +Additionally, you can set the property `` to indicate the destination folder of the `report.json` file: ```xml json - ${maven-buildtime-profiler} - ignore/ + ${maven-buildtime-profiler} + ignore/ ``` Note that in this example we can also set the output mode adding `-Dmaven-buildtime-profiler=stdout` to the maven command. -Also, if somehow you don't want to export the profiling result you can set `` to `none`. +Also, if somehow you don't want to export the profiling result you can set `` to `none`. Here's an example of what the output will look like: From 9db829d7cdd726f6fcbefd324d1cac88b2e09fca Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Thu, 20 Feb 2020 10:02:20 +0100 Subject: [PATCH 40/46] fix: remove unused imports --- .../java/com/soebes/maven/extensions/artifact/DeployTimer.java | 1 - .../java/com/soebes/maven/extensions/artifact/DownloadTimer.java | 1 - .../java/com/soebes/maven/extensions/artifact/InstallTimer.java | 1 - .../soebes/maven/extensions/metadata/MetadataInstallTimer.java | 1 - 4 files changed, 4 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java index 2623cf5..983cd32 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java @@ -21,7 +21,6 @@ import java.text.NumberFormat; import java.util.Map.Entry; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java index a81272d..8bd22fb 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java @@ -21,7 +21,6 @@ import java.text.NumberFormat; import java.util.Map.Entry; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java index 6899a80..906d6c2 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java @@ -21,7 +21,6 @@ import java.text.NumberFormat; import java.util.Map.Entry; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java b/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java index b5b91b2..293bcc0 100644 --- a/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java +++ b/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java @@ -21,7 +21,6 @@ import java.text.NumberFormat; import java.util.Map.Entry; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; From 192b5fcbaf688b82becfdaa1caa1377eb0449b59 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Thu, 20 Feb 2020 10:08:08 +0100 Subject: [PATCH 41/46] fix: remove more unused imports and leave untouched files equal --- src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java | 1 - .../java/com/soebes/maven/extensions/artifact/DeployTimer.java | 2 ++ .../com/soebes/maven/extensions/artifact/DownloadTimer.java | 2 ++ .../java/com/soebes/maven/extensions/artifact/InstallTimer.java | 2 ++ .../soebes/maven/extensions/metadata/MetadataInstallTimer.java | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java index fa98fa2..7a81202 100644 --- a/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java +++ b/src/main/java/com/soebes/maven/extensions/DiscoveryTimer.java @@ -19,7 +19,6 @@ * under the License. */ -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java index 983cd32..68a8deb 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java @@ -21,6 +21,7 @@ import java.text.NumberFormat; import java.util.Map.Entry; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,4 +61,5 @@ public void report() NumberFormat.getNumberInstance().format( mibPerSeconds ) ); LOGGER.info( "------------------------------------------------------------------------" ); } + } diff --git a/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java index 8bd22fb..0542365 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java @@ -21,6 +21,7 @@ import java.text.NumberFormat; import java.util.Map.Entry; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,4 +62,5 @@ public void report() NumberFormat.getNumberInstance().format( mibPerSeconds ) ); } + } diff --git a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java index 906d6c2..9a6a0bc 100644 --- a/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java +++ b/src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java @@ -21,6 +21,7 @@ import java.text.NumberFormat; import java.util.Map.Entry; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,4 +62,5 @@ public void report() NumberFormat.getNumberInstance().format( mibPerSeconds ) ); LOGGER.info( "------------------------------------------------------------------------" ); } + } diff --git a/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java b/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java index 293bcc0..1957b16 100644 --- a/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java +++ b/src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java @@ -21,6 +21,7 @@ import java.text.NumberFormat; import java.util.Map.Entry; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,4 +61,5 @@ public void report() // NumberFormat.getIntegerInstance().format( totalInstallationSize ) ); LOGGER.info( "------------------------------------------------------------------------" ); } + } From 54eb3f7e4ed2a600d5611c38108d2d3f1f430584 Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Mon, 2 Mar 2020 14:22:58 +0100 Subject: [PATCH 42/46] feat: bump target jvm version to 1.8 --- pom.xml | 8 ++++++++ src/main/java/com/soebes/maven/extensions/Execution.java | 5 +++++ 2 files changed, 13 insertions(+) create mode 100644 src/main/java/com/soebes/maven/extensions/Execution.java diff --git a/pom.xml b/pom.xml index cc941a7..54e058e 100755 --- a/pom.xml +++ b/pom.xml @@ -198,6 +198,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + diff --git a/src/main/java/com/soebes/maven/extensions/Execution.java b/src/main/java/com/soebes/maven/extensions/Execution.java new file mode 100644 index 0000000..72db137 --- /dev/null +++ b/src/main/java/com/soebes/maven/extensions/Execution.java @@ -0,0 +1,5 @@ +package com.soebes.maven.extensions; + +public class Execution { + +} From 8c46177d0e06b8d89dfd223e0e316f90b6fb193f Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Mon, 2 Mar 2020 14:24:04 +0100 Subject: [PATCH 43/46] feat: add maven execution info to final report --- .../maven/extensions/BuildTimeProfiler.java | 6 +- .../soebes/maven/extensions/Execution.java | 80 ++++++++++++++++++- 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java index dfb1042..9bc35b6 100644 --- a/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java +++ b/src/main/java/com/soebes/maven/extensions/BuildTimeProfiler.java @@ -89,6 +89,8 @@ public class BuildTimeProfiler private final ProjectTimer forkProject; + private final Execution execution; + public BuildTimeProfiler() { LOGGER.debug( "LifeCycleProfiler ctor called." ); @@ -107,7 +109,7 @@ public BuildTimeProfiler() this.metadataInstallTimer = new MetadataInstallTimer(); this.forkTimer = new ForkTimer(); this.forkProject = new ProjectTimer(); - + this.execution = new Execution(); } @Override @@ -391,6 +393,7 @@ private void executionRequestEventHandler( MavenExecutionRequest event ) // event.getUserProperties().put( "revision", "1.2.3-SNAPSHOT" ); // event.getSystemProperties().put( "revision", "1.2.3-SNAPSHOT" ); // Can we do something more useful here? + this.execution.setExecutionRequest(event); LOGGER.debug( "MBTP: executionRequestEventHandler: {}", event.getExecutionListener() ); } @@ -530,6 +533,7 @@ private JSONObject toJSON() jsonObject.put("metadata", metadata); jsonObject.put("fork-time", forkTimer.getTime()); jsonObject.put("fork-project", forkProject.toJSON()); + jsonObject.put("maven-execution", execution.toJSON()); return jsonObject; } diff --git a/src/main/java/com/soebes/maven/extensions/Execution.java b/src/main/java/com/soebes/maven/extensions/Execution.java index 72db137..af0458a 100644 --- a/src/main/java/com/soebes/maven/extensions/Execution.java +++ b/src/main/java/com/soebes/maven/extensions/Execution.java @@ -1,5 +1,83 @@ package com.soebes.maven.extensions; -public class Execution { +import org.apache.maven.execution.MavenExecutionRequest; +import org.json.JSONArray; +import org.json.JSONObject; +public class Execution +{ + + private MavenExecutionRequest execution; + + private String command; + + public Execution() + { + + } + + public Execution(MavenExecutionRequest executionRequest) + { + setExecutionRequest(executionRequest); + } + + public void setExecutionRequest(MavenExecutionRequest executionRequest) + { + this.execution = executionRequest; + initCommand(); + } + + private void initCommand() { + StringBuilder cmd = new StringBuilder("mvn"); + + if (this.execution.isUpdateSnapshots()) + { + cmd.append(" ").append("-U"); + } + + if (this.execution.isThreadConfigurationPresent()) + { + cmd.append(" ").append("-T").append(this.execution.getThreadCount()); + } + + if (this.execution.isRecursive()) + { + cmd.append(" ").append("-N"); + } + + this.execution.getUserProperties() + .keySet() + .forEach(prop -> cmd.append(" -D").append(prop.toString())); + + this.execution.getGoals().forEach(goal -> cmd.append(" ").append(goal)); + + this.command = cmd.toString(); + } + + public JSONObject toJSON() + { + JSONObject execution = new JSONObject(); + + JSONArray goals = new JSONArray(); + goals.put(this.execution.getGoals()); + + JSONObject userProperties = new JSONObject(); + this.execution.getUserProperties() + .keySet() + .forEach(key -> userProperties.put((String) key, this.execution.getUserProperties().get(key))); + + JSONArray selectedProjects = new JSONArray(); + selectedProjects.put(this.execution.getSelectedProjects()); + + JSONArray profiles = new JSONArray(); + this.execution.getActiveProfiles().forEach(profiles::put); + + execution.put("goals", goals); + execution.put("user-properties", userProperties); + execution.put("selected-projects", selectedProjects); + execution.put("active-profiles", profiles); + execution.put("command", this.command); + + return execution; + } } From d2592cbc5fb1639f96599a675b5537f76aacda8c Mon Sep 17 00:00:00 2001 From: Pablo Caraballo Llorente Date: Mon, 2 Mar 2020 17:24:33 +0100 Subject: [PATCH 44/46] fix: bump jvm to 1.8 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 54e058e..038d0d0 100755 --- a/pom.xml +++ b/pom.xml @@ -13,8 +13,8 @@ Maven :: Build Time Profiler 3.1.1 - 1.7 - 1.7 + 1.8 + 1.8 maven-buildtime-profiler