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

Cannot use multiple sourceDirectories #52

Open
jvicens19 opened this issue Jun 12, 2020 · 6 comments
Open

Cannot use multiple sourceDirectories #52

jvicens19 opened this issue Jun 12, 2020 · 6 comments

Comments

@jvicens19
Copy link

I have this config on my pom.xml:
..

src/main/groovy,src/main/java
...

However, only *.java files of src/main/groovy source directory are getting formatted

@reda-alaoui
Copy link
Member

You have to provide me a way to reproduce the issue. A public git repository for example.

@jvicens19
Copy link
Author

On any project with multiple sourceDirectories (src/main/java, src/main/java2)
with only first one configured and second one imported with:

org.codehaus.mojo
build-helper-maven-plugin


initialize

add-source



src/main/java2




Executing hook with "initialize" phase before "on-pre-commit" goal would fix it because second directory is configured when "build-helper-maven-plugin" is executed . (It is the workaround we use on manual execution formating). However, I don't know how to work with precommit hook in order to ensure "hook" format on both source directories.

@reda-alaoui
Copy link
Member

@jvicens19 I maintain this library on my free time. If you want me to solve the issue quickly, make my life easy by providing a git repository reproducing it.
If you can’t, don’t expect the issue to be solved soon.

@reda-alaoui
Copy link
Member

reda-alaoui commented Jun 13, 2020

@jvicens19 , as explained in #27 (comment), all plugin goals (including on-pre-commit goal) process all *.java files provided by MavenProject#getCompileSourceRoots and MavenProject#getTestCompileSourceRoots.

Comment this issue with a link to a git repository demonstrating the problem if you want me to take a look at it.

@jvicens19
Copy link
Author

Hi, I am sorry that the project that reproduces it is not sharable. I will try to reproduce it in a small project and let you see that.
Now I am going to explain better the issue:

  1. MavenProject#getCompileSourceRoots initially includes one source directory defined in ${project.build.sourceDirectory}
  2. Using multiple source directories is possible using a mvn plugin: https://www.mojohaus.org/build-helper-maven-plugin/usage.html
  3. That build-helper-maven-plugin runs on "initialize" maven fase. That means that MavenProject#getCompileSourceRoots is not updated with additional directories after initialize phase
  4. Pre commit hook runs: com.cosium.code:git-code-format-maven-plugin:on-pre-commit.
    that goal "on-pre-commit" runs independently and obviously not include "inititalize" phase that would add additional directories.
  5. Running "mvn initialize git-code-format:format-code -Dgcf.globPattern=**/*" solves the issue and do format all directories sources.

It is possible to include initialize phase on the hook *.sh to solve this issue?

@reda-alaoui reda-alaoui reopened this Jun 24, 2020
@reda-alaoui
Copy link
Member

@jvicens19 , when I add initialize to the pre commit hook shell, tests fail.

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

No branches or pull requests

2 participants