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

Property for skipping formatting in the README doesn't match the property in the code #365

Closed
wilkinsona opened this issue Feb 23, 2023 · 11 comments
Milestone

Comments

@wilkinsona
Copy link
Contributor

wilkinsona commented Feb 23, 2023

The README mentions -Dspring-javaformat.apply.skip=true but the code looks for -Dspring-javaformat.format.skip=true.

@lfvjimisola
Copy link

lfvjimisola commented Feb 23, 2023

None of the three (3) skip options seem to work:

  • -Dspring-javaformat.skip=true
  • -Dspring-javaformat.apply.skip=true
  • -Dspring-javaformat.validate.skip=true

All of them fill a purpose.

@lfvjimisola
Copy link

@wilkinsona
Copy link
Contributor Author

I think you may be misinterpreting Maven's output. When a goal is skipped, Maven will still call it and that fact that it has been called will appear in Maven's output. It is up to the goal to perform no processing when skipped. The apply and validate goals output some debug logging indicating that they have been skipped. For example:

$ mvn validate -X -Dspring-javaformat.validate.skip=true
…
[INFO] --- spring-javaformat-maven-plugin:0.0.38:validate (default) @ test ---
[DEBUG] Configuring mojo io.spring.javaformat:spring-javaformat-maven-plugin:0.0.38:validate from plugin realm ClassRealm[plugin>io.spring.javaformat:spring-javaformat-maven-plugin:0.0.38, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@531d72ca]
[DEBUG] Configuring mojo 'io.spring.javaformat:spring-javaformat-maven-plugin:0.0.38:validate' with basic configurator -->
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) excludes = []
[DEBUG]   (f) includeGeneratedSource = false
[DEBUG]   (f) includes = []
[DEBUG]   (f) project = MavenProject: test:test:0.1-SNAPSHOT @ /Users/awilkinson/Downloads/test-4/pom.xml
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@6d467c87
[DEBUG]   (f) skip = true
[DEBUG]   (f) sourceDirectories = [/Users/awilkinson/Downloads/test-4/src/main/java]
[DEBUG]   (f) testSourceDirectories = [/Users/awilkinson/Downloads/test-4/src/test/java]
[DEBUG] -- end configuration --
[DEBUG] skipping format validate as per configuration.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.022 s
[INFO] Finished at: 2023-02-23T09:45:51Z
[INFO] ------------------------------------------------------------------------

@wilkinsona
Copy link
Contributor Author

We should consider logging the skip message at info level. That's what Surefire does for example.

@lfvjimisola
Copy link

lfvjimisola commented Feb 23, 2023

@wilkinsona Yes, I understand. But, the skip is not set true correctly in all cases from what I can see. Do you get [DEBUG] (f) skip = true when you try to skip apply?

That is, mvn validate -X -Dspring-javaformat.apply.skip=true

I don't get [DEBUG] (f) skip = true

for

  • -Dspring-javaformat.skip=true
  • -Dspring-javaformat.apply.skip=true

only for

  • -Dspring-javaformat.validate.skip=true

@lfvjimisola
Copy link

We should consider logging the skip message at info level. That's what Surefire does for example.

Yes, agreed.

@wilkinsona
Copy link
Contributor Author

As I said in #360 (comment), you need to use -Dspring-javaformat.format.skip=true. You will then see skipping format apply as per configuration logged at debug level.

You'll see both skipping format apply as per configuration and skipping format validate as per configuration logged when using -Dspring-javaformat.skip=true. You won't see [DEBUG] (f) skip = true when setting spring-javaformat.skip as that's showing the value of the parameter to which spring-javaformat.format.skip and spring-javaformat.validate.skip are mapped.

@jimisola
Copy link

jimisola commented Feb 23, 2023

Ok. Got a bit confused there. So, -Dspring-javaformat.format.skip=true will only skip apply?

@wilkinsona
Copy link
Contributor Author

Yes. spring-javaformat.format.skip skips apply, spring-javaformat.validate.skip skips validation, and spring-javaformat.skip skips both. Other than the mistake with the name of the property to skip apply, this is described in the README:

You can use -Dspring-javaformat.validate.skip=true or -Dspring-javaformat.apply.skip=true command line arguments to temporarily skip the validation or format goals. If you want to skip both, you can use -Dspring-javaformat.skip=true.

@lfvjimisola
Copy link

@wilkinsona Sorry for the confusion and for you having the explain several times. Have a very hectic week and it became now that I rushed things. I totally missed that apply was replaced with format although I did a cut-n-paste from your text.

I would +1 to allow spring-javaformat.apply.skip as it makes sense to be consistent with the naming of skip variables and maven goal.

@philwebb philwebb modified the milestones: 0.0.x, 0.0.39 Feb 23, 2023
@philwebb
Copy link
Contributor

I messed up the property name in the code.

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

No branches or pull requests

4 participants