From 0b6a269147ed632d3cf999b882fc6774efa876fa Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Tue, 17 Dec 2024 19:03:33 +0100 Subject: [PATCH 1/3] refactor: simplify formatting pluging handling --- CONTRIBUTING.md | 8 +- analysis/pom.xml | 24 ++- build-tools/pom.xml | 15 -- .../eclipse-format.xml | 0 .../eclipse.importorder | 0 if-manifest-export/pom.xml | 10 +- measure/pom.xml | 24 ++- metadata/pom.xml | 12 +- pom.xml | 138 ++++++++++-------- server/pom.xml | 24 ++- 10 files changed, 117 insertions(+), 138 deletions(-) delete mode 100644 build-tools/pom.xml rename {build-tools/src/main/resources => contributing}/eclipse-format.xml (100%) rename {build-tools/src/main/resources => contributing}/eclipse.importorder (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f6e824..a0402a3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # IDE Config and Code Style This project has a strictly enforced code style. Code formatting is done by the Eclipse code -formatter, using the config files found in the `build-tools` directory. By +formatter, using the config files found in the `contributing` directory. By default when you run `mvn install` the code will be formatted automatically. When submitting a pull request the CI build will fail if running the formatter results in any code changes, so it is recommended that you always run a full Maven build before submitting a pull request. @@ -11,7 +11,7 @@ If you want to run the formatting without doing a full build, you can run `mvn p #### Eclipse Setup Open the *Preferences* window, and then navigate to _Java_ -> _Code Style_ -> _Formatter_. Click _ -Import_ and then select the `eclipse-format.xml` file in the `build-tools` +Import_ and then select the `eclipse-format.xml` file in the `contributing` directory. Next navigate to _Java_ -> _Code Style_ -> _Organize Imports_. Click _Import_ and select @@ -29,11 +29,11 @@ Settings_ -> _Eclipse Code Formatter_. Select _Use the Eclipse Code Formatter_, then change the _Eclipse Java Formatter Config File_ to point to the -`eclipse-format.xml` file in the `build-tools` directory. Make sure the _ +`eclipse-format.xml` file in the `contributing` directory. Make sure the _ Optimize Imports_ box is ticked, and select the `eclipse.importorder` file as the import order config file. Next, disable wildcard imports: navigate to _Editor_ -> _Code Style_ -> _Java_ -> _Imports_ and set _Class count to use import with '\*'_ to `999`. Do the same with _Names count to use static -import with '\*'_. \ No newline at end of file +import with '\*'_. diff --git a/analysis/pom.xml b/analysis/pom.xml index a1cce51..082155b 100644 --- a/analysis/pom.xml +++ b/analysis/pom.xml @@ -31,21 +31,15 @@ - - - - net.revelc.code.formatter - formatter-maven-plugin - - - net.laprun.sustainability - build-tools - 0.1.1-SNAPSHOT - - - - - + + + net.revelc.code.formatter + formatter-maven-plugin + + ../contributing/eclipse-format.xml + + + diff --git a/build-tools/pom.xml b/build-tools/pom.xml deleted file mode 100644 index 7ea253a..0000000 --- a/build-tools/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - - net.laprun.sustainability - power-server-parent - 0.1.1-SNAPSHOT - - - build-tools - power-server : code formatting support - Support to automatically format the code for the power-server project - - \ No newline at end of file diff --git a/build-tools/src/main/resources/eclipse-format.xml b/contributing/eclipse-format.xml similarity index 100% rename from build-tools/src/main/resources/eclipse-format.xml rename to contributing/eclipse-format.xml diff --git a/build-tools/src/main/resources/eclipse.importorder b/contributing/eclipse.importorder similarity index 100% rename from build-tools/src/main/resources/eclipse.importorder rename to contributing/eclipse.importorder diff --git a/if-manifest-export/pom.xml b/if-manifest-export/pom.xml index 8d68fcd..4b9a91f 100644 --- a/if-manifest-export/pom.xml +++ b/if-manifest-export/pom.xml @@ -30,13 +30,9 @@ net.revelc.code.formatter formatter-maven-plugin - - - net.laprun.sustainability - build-tools - ${project.version} - - + + ../contributing/eclipse-format.xml + diff --git a/measure/pom.xml b/measure/pom.xml index 7f4f255..b1c00ba 100644 --- a/measure/pom.xml +++ b/measure/pom.xml @@ -25,20 +25,14 @@ - - - - net.revelc.code.formatter - formatter-maven-plugin - - - net.laprun.sustainability - build-tools - 0.1.1-SNAPSHOT - - - - - + + + net.revelc.code.formatter + formatter-maven-plugin + + ../contributing/eclipse-format.xml + + + diff --git a/metadata/pom.xml b/metadata/pom.xml index ad00ee8..6d9e894 100644 --- a/metadata/pom.xml +++ b/metadata/pom.xml @@ -20,20 +20,14 @@ - net.revelc.code.formatter formatter-maven-plugin - - - net.laprun.sustainability - build-tools - 0.1.1-SNAPSHOT - - + + ../contributing/eclipse-format.xml + - diff --git a/pom.xml b/pom.xml index acf7fef..74b16d6 100644 --- a/pom.xml +++ b/pom.xml @@ -45,6 +45,7 @@ quarkus-bom io.quarkus true + false 3.17.4 3.26.3 @@ -68,7 +69,6 @@ - build-tools metadata measure server @@ -121,7 +121,7 @@ formatter-maven-plugin ${formatter-plugin.version} - eclipse-format.xml + contributing/eclipse-format.xml LF ${format.skip} @@ -137,84 +137,106 @@ ${format.skip} + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + ${quarkus.platform.group-id} + quarkus-maven-plugin + ${quarkus.platform.version} + true + + + + build + generate-code + generate-code-tests + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${compiler-plugin.version} + + + -parameters + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + me.fabriciorby + maven-surefire-junit5-tree-reporter + 1.4.0 + + + + plain + + true + + + UNICODE + + + org.jboss.logmanager.LogManager + ${maven.home} + + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven-failsafe-plugin.version} + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + + org.jboss.logmanager.LogManager + + ${maven.home} + + + + + org.apache.maven.plugins maven-deploy-plugin - ${maven-deploy-plugin.version} ${quarkus.platform.group-id} quarkus-maven-plugin - ${quarkus.platform.version} - true - - - - build - generate-code - generate-code-tests - - - org.apache.maven.plugins maven-compiler-plugin - ${compiler-plugin.version} - - - -parameters - - org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} - - - me.fabriciorby - maven-surefire-junit5-tree-reporter - 1.4.0 - - - - plain - - true - - - UNICODE - - - org.jboss.logmanager.LogManager - ${maven.home} - - org.apache.maven.plugins maven-failsafe-plugin - ${maven-failsafe-plugin.version} - - - - integration-test - verify - - - - ${project.build.directory}/${project.build.finalName}-runner - - org.jboss.logmanager.LogManager - ${maven.home} - - - - net.revelc.code.formatter diff --git a/server/pom.xml b/server/pom.xml index 6e8cd85..beed4ce 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -31,21 +31,15 @@ ${os-maven-plugin.version} - - - - net.revelc.code.formatter - formatter-maven-plugin - - - net.laprun.sustainability - build-tools - ${project.version} - - - - - + + + net.revelc.code.formatter + formatter-maven-plugin + + ../contributing/eclipse-format.xml + + + From e144457c0ae57e13dd7dc370c6fe36dae1748745 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Tue, 17 Dec 2024 19:06:50 +0100 Subject: [PATCH 2/3] fix: update README according to recent changes --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7abe133..6c4a486 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,9 @@ without further processing. This project uses [Quarkus](https://quarkus.io), the Supersonic Subatomic Java Framework and comprises 3 modules: -- `build-tools`, which contains formatting configuration that you can use to set your IDE up to contribute to this - project +- `analysis`, which contains utilities helpful to analyze power measures (computations, statistics, histograms, etc…) +- `if-manifest-export`, which provides a means to export a stopped measure as a [Green Software Foundation](https://greensoftware.foundation/) [Impact Framework](https://if.greensoftware.foundation/) manifest +- `measure`, which provides classes to help record and process measures in client applications - `metadata`, which contains the metadata API that the RESTful server uses to provide information about what is returned by the power sensors. This artifact contains classes that can be reused in client projects. - `server` contains the RESTful server, listening by default on port `20432` (as specified @@ -69,4 +70,4 @@ Once build, you can run the server as follows: - JVM mode: `sudo java -jar server/target/quarkus-app/quarkus-run.jar` from the project root - Dev mode: `cd server; sudo mvn quarkus:dev` or `cd server; sudo quarkus dev` (will only work if `root` has Java properly configured) -- Native mode: `sudo ./server/target/*-runner` \ No newline at end of file +- Native mode: `sudo ./server/target/*-runner` From be98cf4935b208c730348ad02254212b8f8496b6 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Tue, 17 Dec 2024 19:08:02 +0100 Subject: [PATCH 3/3] chore: removed unused class --- .../sustainability/power/measure/Compute.java | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 measure/src/main/java/net/laprun/sustainability/power/measure/Compute.java diff --git a/measure/src/main/java/net/laprun/sustainability/power/measure/Compute.java b/measure/src/main/java/net/laprun/sustainability/power/measure/Compute.java deleted file mode 100644 index c89d11a..0000000 --- a/measure/src/main/java/net/laprun/sustainability/power/measure/Compute.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.laprun.sustainability.power.measure; - -public enum Compute { - ; - - public static double sumOfComponents(double[] recorded) { - var componentSum = 0.0; - for (double value : recorded) { - componentSum += value; - } - return componentSum; - } - - public static double sumOfSelectedComponents(double[] recorded, int... indices) { - if (indices == null || indices.length == 0) { - return sumOfComponents(recorded); - } - var componentSum = 0.0; - for (int index : indices) { - componentSum += recorded[index]; - } - return componentSum; - } -}