HubSpot / prettier-maven-plugin

Apache License 2.0
116 stars 23 forks source link

Cannot get plugin goals to execute in linked phase #54

Closed ZaLiTHkA closed 2 years ago

ZaLiTHkA commented 2 years ago

greetings..

first off, little disclaimer: I am a web dev, not too familiar with Java.. now my work colleagues do write Java apps, but they don't have much knowledge of Maven. if you think this sounds like a recipe for disaster, you're probably not wrong. but we do what we can with what we have. šŸ‘šŸ¼

we recently migrated some projects from a Netbeans-dependant Ant build process, over to Maven. I personally prefer to use VSCode with Prettier, but we have issue now with different code formatting rules in the different IDEs.

I've been trying to execute the check goal from the prettier-maven-plugin automatically, but I'm just not winning.

if I understand correctly, running mvn validate with the following in my pom.xml "plugins" node should execute the prettier:check goal as well:

<plugin>
  <groupId>com.hubspot.maven.plugins</groupId>
  <artifactId>prettier-maven-plugin</artifactId>
  <version>0.14</version>
  <configuration>
    <prettierJavaVersion>1.3.0</prettierJavaVersion>
  </configuration>
  <executions>
    <execution>
      <phase>validate</phase>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>

or am I missing something here?

ZaLiTHkA commented 2 years ago

now I'm starting to question my own reasoning here... so perhaps I'm actually missing the point of this exercise. šŸ¤”

in my local environment, I have VSCode to automatically format my code with Prettier on save.. so the optimal solution is simply to use a Prettier plugin for Netbeans, but I don't think there are any (at the moment).

on the Netbeans-specific side, I do know that I can customise the goals that are run through the project's "Actions" config.. so should I adjust the typical "run" and "build" actions in Netbeans to call prettier:check and prettier:write as we need and be done with it?

if someone else comes along later and decides they want to use IDEA (which does have Prettier support), then all our children should play nicely in the same sandpit, yes?

jhaber commented 2 years ago

In general, we configure our IDEs to reformat with prettier on file save, but if Netbeans doesn't have any sort of prettier plugin then telling it to run prettier:write on build seems like the next best thing. And then you'd generally run prettier:check inside your CI environment to ensure that the build fails if someone accidentally checks in mis-formatted code

ZaLiTHkA commented 2 years ago

I guess I'm just tired of having to think of code formatting for everyone in our "team", so maybe I'm subconsciously hoping for some magic solution that will make me not have to do that. just today I saw yet another commit that adds "fixes" that literally revert the code formatting I did about 2 or 3 weeks back, even with a comment of "this is from before the auto format". šŸ¤¦šŸ¼ā€ā™‚ļø I'm tired of it..

anyways, it is what it is.. let me leave it there and close off this issue before I digress into a rant about "the dangers of line based source control with people who don't give a shit about code quality"....