Git Product home page Git Product logo

Comments (8)

ctubbsii avatar ctubbsii commented on June 22, 2024

I think you actually need to have your config file look like this to include a single file:

 <includes>
   <include>${formatter.includes}</include>
 </includes>

Also, you don't need to specify the <executions> piece to configure it for formatting from the command-line. <executions> is for configuring executions of the plugin automatically during a mvn build.

from formatter-maven-plugin.

zhujiajun917 avatar zhujiajun917 commented on June 22, 2024

with

${formatter.includes}

in pom.xml
And then run mvn formatter:format -Dformatter.includes=src/main/java/com/GitTest.java , it will not format the GitTest.java. @ctubbsii

from formatter-maven-plugin.

zhujiajun917 avatar zhujiajun917 commented on June 22, 2024

@ctubbsii as your mentioned, I used <include>${formatter.includes}</include> instead of <includes>${formatter.includes}</includes>, the result keep the same as before

from formatter-maven-plugin.

ctubbsii avatar ctubbsii commented on June 22, 2024

I tried this with a wildcard pattern, mvn formatter:format -Dformatter.includes='**/MyFileName.java' and that seems to have worked. However, I get the same behavior as you do for specifying the exact path to a file. It's very strange. I'm not sure what the problem is.

from formatter-maven-plugin.

ctubbsii avatar ctubbsii commented on June 22, 2024

Ah, I figured it out. Apparently, the base directory the formatter is processing files relative to is src/main/java/ or src/test/java/ by default.

If you need a different directory, you can set something like:

            <directories>
              <directory>${project.basedir}</directory>
            </directories>
            <includes>
              <include>${formatter.includes}</include>
            </includes>

from formatter-maven-plugin.

ctubbsii avatar ctubbsii commented on June 22, 2024

Information has been provided. Closing this.

from formatter-maven-plugin.

zhujiajun917 avatar zhujiajun917 commented on June 22, 2024

@ctubbsii Thanks a lot, it works. with pom.xml as:

  <configuration>
    <configFile>${project.basedir}/eclipse-codestyle.xml</configFile>
    <directories>
      <directory>${project.basedir}</directory>
    </directories>
    <includes>
      <include>${formatter.includes}</include>
    </includes>
  </configuration>

and then run mvn formatter:format -Dformatter.includes=src/main/java/com/GitTest.java, it will format only GitTest.java.

Perfect! Thanks again.

from formatter-maven-plugin.

ctubbsii avatar ctubbsii commented on June 22, 2024

@zhujiajun917 No problem. Also, I edited your comment to format the XML correctly. In the future, GitHub users will appreciate you learning to use proper GitHub-flavored Markdown syntax for code blocks: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks

from formatter-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.