mfoo / libyear-maven-plugin

Maven implementation of the libyear dependency freshness measure
https://mfoo.github.io/libyear-maven-plugin
Apache License 2.0
15 stars 3 forks source link

Add happy announcement for the newborn #234

Open verhasi opened 1 month ago

verhasi commented 1 month ago

This maven plugin helps to reduce the lib years of a product so it is an anti age tool. The final goal is to get the result 0 libyears what I mean newborn. Actually this happy moment remains silent. Event not the fact that it is 0 libyears is not printed at all. I propose to provide a happy congratulation is something similar when a module reaches the newborn state. May be I will create a PR for this feature if @mfoo thinks it is a good idea.

mfoo commented 1 month ago

Heya! The library is heavily based on the MojoHaus Versions Maven Plugin, which doesn't have any kind of 'well done' message if you're on the latest versions. Do any of the other libyear plugins mentioned on https://libyear.com/ have a mention of congratulations if you hit zero? libyear-bundler doesn't.

I note that the oga-maven-plugin will print this though:

No problem detected. Good job! :-)

I think perhaps that my Maven builds are already noisy enough, more text when we hit zero years might not be super useful? What do you think?

verhasi commented 1 month ago

As I tried out the plugin alone and not as part of the build, I was unsure whether everything was ok or something had gone wrong when there was no output at all. My use case was to focus on the anti-ageing the project and finishing was silent. If executed as part of the build I believe 1 more line per module would not harm anyone. As the maven is generally opinionated, this feature also could be implemented as printing congratulation as default but could be configured to switch off.

verhasi commented 1 month ago

It could be an edge case but relates this discussion

mvn io.github.mfoo:libyear-maven-plugin:analyze 
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------< guru.mocker.maven:myfirst-maven-plugin >---------------
[INFO] Building My first Parameter-less Maven Plugin 1.0.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] ----------------------------[ maven-plugin ]----------------------------
[INFO] 
[INFO] --- libyear:1.1.0:analyze (default-cli) @ myfirst-maven-plugin ---
[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   org.apache.maven:maven-plugin-api ...................... 0.00 libyears
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.243 s
[INFO] Finished at: 2024-05-30T11:52:00+02:00
[INFO] ------------------------------------------------------------------------

and here is the simple pom.xml to produce

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>guru.mocker.maven</groupId>
  <artifactId>myfirst-maven-plugin</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>maven-plugin</packaging>

  <name>My first Parameter-less Maven Plugin</name>

  <properties>
    <maven-plugin-tools.version>3.13.0</maven-plugin-tools.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>3.9.7</version>
      <scope>provided</scope>
    </dependency>

    <!-- dependencies to annotations -->
    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <version>${maven-plugin-tools.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
     <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>${maven-plugin-tools.version}</version>
        <executions>
          <execution>
            <id>help-mojo</id>
            <goals>
              <!-- good practice is to generate help mojo for plugin -->
              <goal>helpmojo</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
    </pluginManagement>
  </build>
</project>

😄

verhasi commented 1 month ago

I tried the version maven plugin for the plugin versions mvn versions:display-plugin-updates and got he following

[INFO] 
[INFO] -----------------< guru.mocker.hamcrest:hamcrest-date >-----------------
[INFO] Building Hamcrest Date 3.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- versions:2.16.2:display-plugin-updates (default-cli) @ hamcrest-date ---
[INFO] 
[INFO] All plugins with a version specified are using the latest versions.
[INFO] 
[INFO] All plugins have a version specified.
[INFO] 
[INFO] Project requires minimum Maven version for build of: 3.6.3
[INFO] Plugins require minimum Maven version of: 3.6.3
[INFO] 
[INFO] No plugins require a newer version of Maven than specified by the pom.
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.276 s
[INFO] Finished at: 2024-05-31T12:46:44+02:00
[INFO] ------------------------------------------------------------------------

It is much more than nothing :) And even for the dependencies also there is one sentence mvn versions:display-dependency-updates

[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------< guru.mocker.hamcrest:hamcrest-date >-----------------
[INFO] Building Hamcrest Date 3.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- versions:2.16.2:display-dependency-updates (default-cli) @ hamcrest-date ---
[INFO] No dependencies in Dependencies have newer versions.
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.617 s
[INFO] Finished at: 2024-05-31T12:52:54+02:00
[INFO] ------------------------------------------------------------------------