HubSpot / prettier-maven-plugin

Apache License 2.0
116 stars 23 forks source link

Code formatting issues found, please run prettier-java #52

Closed MarcosRibeiroJesus closed 2 years ago

MarcosRibeiroJesus commented 2 years ago

Hello guys, when I try to run mvn install in a Spring Boot starter project with the following config:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>realmeet</artifactId>
        <groupId>br.com.mrj</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>realmeet-service</artifactId>
    <properties>
        <java.version>11</java.version>
        <testcontainers.version>1.15.2</testcontainers.version>
        <mapstruct.version>1.4.2.Final</mapstruct.version>
        <jackson-databind-nullable.version>0.2.1</jackson-databind-nullable.version>
        <springdoc-openapi-ui.version>1.5.4</springdoc-openapi-ui.version>
        <mockito-junit-jupiter.version>3.7.7</mockito-junit-jupiter.version>
        <prettier-maven-plugin.version>0.10</prettier-maven-plugin.version>
    </properties>
    <dependencies>
        <!--  Data  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!--  MapStruct  -->
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>${mapstruct.version}</version>
        </dependency>
        <!--  Documentation  -->
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
            <version>${springdoc-openapi-ui.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openapitools</groupId>
            <artifactId>jackson-databind-nullable</artifactId>
            <version>${jackson-databind-nullable.version}</version>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>${swagger-annotations.version}</version>
        </dependency>
        <!--  Test  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mysql</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${mockito-junit-jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>br.com.mrj</groupId>
            <artifactId>realmeet-client</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>testcontainers-bom</artifactId>
                <version>${testcontainers.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <resources>
            <resource>
                <directory>target/generated-sources/openapi/src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.4.5</version>
                <configuration>
                    <mainClass>br.com.mrj.realmeet.Application</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${mapstruct.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.hubspot.maven.plugins</groupId>
                <artifactId>prettier-maven-plugin</artifactId>
                <version>0.14</version>
                <configuration>
                    <prettierJavaVersion>1.3.0</prettierJavaVersion>
                    <printWidth>90</printWidth>
                    <tabWidth>2</tabWidth>
                    <useTabs>false</useTabs>
                    <ignoreConfigFile>true</ignoreConfigFile>
                    <ignoreEditorConfig>true</ignoreEditorConfig>
                    <!-- Use <inputGlobs> to override the default input patterns -->
                    <inputGlobs>
                        <!-- These are the default patterns, you can omit <inputGlobs> entirely unless you want to override them -->
                        <inputGlob>src/main/java/**/*.java</inputGlob>
                        <inputGlob>src/test/java/**/*.java</inputGlob>
                    </inputGlobs>
                </configuration>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>${versions-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>display-property-updates</goal>
                        </goals>
                        <phase>validate</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>${openapi-generator-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${openapi-spec.file}</inputSpec>
                            <generatorName>spring</generatorName>
                            <modelPackage>${api.path}.api.model</modelPackage>
                            <apiPackage>${api.path}.api.facade</apiPackage>
                            <configOptions>
                                <interfaceOnly>true</interfaceOnly>
                                <dateLibrary>java8</dateLibrary>
                                <java8>true</java8>
                                <async>true</async>
                                <serializableModel>true</serializableModel>
                                <configPackage>${api.path}.api.config</configPackage>
                                <classpathTargetSpec>${openapi-spec.classpath}</classpathTargetSpec>
                                <isCorsEnabled>true</isCorsEnabled>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

It returns following error: Screenshot from 2021-09-04 00-22-31

I tried to search about this error but I couldn't find anything to solve...

MarcosRibeiroJesus commented 2 years ago

Omg I just solved this by accessing the plugins path inside maven and running prettier:write 🙈

Screenshot from 2021-09-04 00-53-37

tadeuespindolapalermo commented 2 years ago

Amazing solution, Marcos!

MateusDantas2 commented 1 year ago

Congratulations!