Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5 Allow printing report to a JSON file #14

Open
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

paleloser
Copy link

@paleloser paleloser commented Feb 11, 2020

Motivation

As discussed in #5 , the purpose of this PR is to make the extension configurable in order to select wether to print the report via stdout or to a JSON file.

Plan

This feature accepts 2 maven properties:

  • <maven-buildtime-profiler.output>: optional, used to select between stdout, none or json output.
  • <maven-buildtime-profiler.directory>: optional, used to select the destination folder of the report.json file

By default, the extension works as it used to, printing the output to the console. If json output is set, the default destination folder is the project's base directory.

An example of the output would be:

{
  "download": {
    "size": 0,
    "time": 0
  },
  "metadata": {
    "download": {
      "size": 0,
      "time": 0
    },
    "install": {
      "com.soebes.maven.extensions:maven-buildtime-profiler:0.2.1-SNAPSHOT:maven-metadata.xml:SNAPSHOT": {
        "size": 0,
        "time": 2
      },
      "size": 0,
      "com.soebes.maven.extensions:maven-buildtime-profiler::maven-metadata.xml:RELEASE_OR_SNAPSHOT": {
        "size": 0,
        "time": 6
      },
      "time": 8
    },
    "deployment": {
      "size": 0,
      "time": 0
    }
  },
  "discovery-time": 188,
  "build": {
    "projects": {
      "maven-buildtime-profiler": {
        "package": 2024,
        "test": 8734,
        "clean": 551,
        "test-compile": 761,
        "process-test-resources": 13,
        "compile": 3941,
        "pre-integration-test": 988,
        "install": 322,
        "post-integration-test": 114,
        "verify": 614,
        "process-classes": 776,
        "process-resources": 175,
        "initialize": 2474,
        "generate-sources": 1116,
        "validate": 902
      }
    },
    "plugins": {
      "package": {
        "org.apache.maven.plugins:maven-site-plugin:3.7.1:attach-descriptor (attach-descriptor)": 1256,
        "org.apache.maven.plugins:maven-shade-plugin:3.1.1:shade (default)": 405,
        "org.apache.maven.plugins:maven-jar-plugin:3.1.0:jar (default-jar)": 363
      },
      "test": {
        "org.apache.maven.plugins:maven-surefire-plugin:2.22.0:test (default-test)": 8734
      },
      "clean": {
        "org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean (default-clean)": 551
      },
      "test-compile": {
        "org.apache.maven.plugins:maven-compiler-plugin:3.8.0:testCompile (default-testCompile)": 761
      },
      "process-test-resources": {
        "org.apache.maven.plugins:maven-resources-plugin:3.1.0:testResources (default-testResources)": 13
      },
      "compile": {
        "org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile)": 3941
      },
      "pre-integration-test": {
        "org.codehaus.mojo:mrm-maven-plugin:1.1.0:start (default)": 988
      },
      "install": {
        "org.apache.maven.plugins:maven-install-plugin:2.5.2:install (default-install)": 322
      },
      "post-integration-test": {
        "org.codehaus.mojo:mrm-maven-plugin:1.1.0:stop (default)": 114
      },
      "verify": {
        "org.jacoco:jacoco-maven-plugin:0.8.1:report (default)": 614
      },
      "process-classes": {
        "org.sonatype.plugins:sisu-maven-plugin:1.1:main-index (generate-index)": 776
      },
      "process-resources": {
        "org.apache.maven.plugins:maven-resources-plugin:3.1.0:resources (default-resources)": 175
      },
      "initialize": {
        "org.jacoco:jacoco-maven-plugin:0.8.1:prepare-agent (default)": 2474
      },
      "generate-sources": {
        "org.codehaus.mojo:templating-maven-plugin:1.0.0:filter-sources (default)": 1116
      },
      "validate": {
        "org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce (enforce-maven)": 902
      }
    },
    "phases": {
      "package": 2024,
      "test": 8734,
      "clean": 551,
      "test-compile": 761,
      "process-test-resources": 13,
      "compile": 3941,
      "pre-integration-test": 988,
      "install": 322,
      "post-integration-test": 114,
      "verify": 614,
      "process-classes": 776,
      "process-resources": 175,
      "initialize": 2474,
      "generate-sources": 1116,
      "validate": 902
    }
  },
  "install": {
    "size": 183397,
    "com.soebes.maven.extensions:maven-buildtime-profiler:0.2.1-SNAPSHOT:jar": {
      "size": 46308,
      "time": 31
    },
    "rate": 1.4454628810409673,
    "com.soebes.maven.extensions:maven-buildtime-profiler:0.2.1-SNAPSHOT:pom": {
      "size": 10756,
      "time": 41
    },
    "com.soebes.maven.extensions:maven-buildtime-profiler:0.2.1-SNAPSHOT:mvn311:jar": {
      "size": 126333,
      "time": 49
    },
    "time": 121
  },
  "fork-project": {},
  "fork-time": 0,
  "goals": {},
  "deploy": {
    "size": 0,
    "time": 0
  }
}

Note that te units are the same as the original report: milliseconds for time, mebibytes per second for rate and bytes for sizes.

Acceptance criteria

  • Output mode is selectable between json and stdout, being stdout the default one
  • Destination folder is configurable
  • Tests pass successfully

Pablo Caraballo Llorente added 30 commits February 11, 2020 09:29
@paleloser paleloser requested a review from khmarbaise February 11, 2020 16:55
the destination folder of the `report.json` file:

```xml
<properties>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paleloser Could we move these properties to extension parameters? Is that possible?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe maven extensions don't allow parameters, as they don't work with Mojos: http://maven.apache.org/examples/maven-3-lifecycle-extensions.html

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically you could use a system property ....?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved at 7e586f1.

@recena
Copy link
Contributor

recena commented Feb 11, 2020

I would wait for #15

@recena
Copy link
Contributor

recena commented Mar 4, 2020

@paleloser Since my PR #15 was recently merged, sync with master branch.

@khmarbaise
Copy link
Owner

PR#15 has been merged.

@recena
Copy link
Contributor

recena commented Mar 14, 2020

@paleloser Could you address the pending things here?

@paleloser
Copy link
Author

@khmarbaise PR is ready to be merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants