Git Product home page Git Product logo

formatter-maven-plugin's Introduction

formatter-maven-plugin

mvn verify Maven Central Apache License

This project provides a mechanism to automatically (re)format your Maven project during a Maven build, or to verify its formatting, so that your project can converge on consistent code style regardless of user preferences, IDE settings, etc.

It began following a post on the topic (which can be found here; thanks to John for writing such a helpful article). It now uses the Eclipse code formatter for Java, and has grown to support formatting of other file types as well.

For a companion m2e project configurator, see formatter-m2e-configurator.

This software is provided WITHOUT ANY WARRANTY, and is available under the Apache License, Version 2. Any code loss caused by using this plugin is not the responsibility of the author(s). Be sure to use some source repository management system such as GIT before using this plugin.

Contributions are welcome.

How to use

View the Maven plugin documentation for the latest release here.

Eclipse Compatibility

The primary use case of this plugin is to ensure consistent formatting for a project, regardless of differences between IDE preferences or IDE versions that developers use. Nevertheless, some users may find it useful to correlate versions of this plugin to the version of Eclipse whose code is used as the basis for this plugin's formatting. See the project website for a list of recent versions of this plugin and their corresponding Eclipse versions.

Integration Tests

mvn clean verify

JDK Requirements

  • 2.16.x requires jdk 8 as required by Eclipse binaries
  • 2.17.x and later requires jdk 11 as required by Eclipse binaries
  • 2.24.x and later requires jdk 17 as required by Eclipse binaries

formatter-maven-plugin's People

Contributors

arlol avatar blzsaa avatar brun-nico avatar ctubbsii avatar davsclaus avatar delanym avatar dependabot-preview[bot] avatar dependabot[bot] avatar dmasyukov avatar dwalluck avatar elrodro83 avatar etondoze avatar geoand avatar gnodet avatar hazendaz avatar jam01 avatar jamezp avatar kshchepanovskyi avatar lumnitzf avatar matteobaccan avatar mblanchette avatar mdaloia avatar pit3k avatar rultor avatar sgandon avatar tisoft avatar tpontz avatar velo avatar xenoamess avatar zeeshanasghar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

formatter-maven-plugin's Issues

Add an ability to skip the goal

Add an ability to skip execution of the goal.
This is useful when programmatically turn the formatting ON/OFF. Also useful in 
changing the behavior across inheritance. 
e.g. 
<plugin>
    <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
    <artifactId>maven-java-formatter-plugin</artifactId>
    <version>0.3.1</version>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>

mvn java-formatter:format -Dskip=true

Expected output:

Actual output:

Steps to reproduce:
1.
2.
3.

Plugin version:
Maven version:
Java version:
Eclipse version:
OS:

Additional details:
See attached debug build output...

Original issue reported on code.google.com by [email protected] on 6 Mar 2013 at 5:38

velo-merge branch

This branch is now on master. I'm going to remove it as merged. Please advise if there is any reason to retain it.

Project to github

Can this project get migrated to github?  It would make contributions much 
easier.

Original issue reported on code.google.com by [email protected] on 18 Sep 2014 at 3:01

use_on_off_tags to true

Hi guys,

Does your useful plugin support  
"org.eclipse.jdt.core.formatter.use_on_off_tags" with true value ? it is about 
@formatter:off - @formatter:on flags..

I'm not able having this working ... may it is my error or ... ?

Expected output: code between @formatter:off and @formatter:on not formatted

Actual output: code between @formatter:off and @formatter:on not formatted

Steps to reproduce:
1. add use_on_off_tags to true in formatter.xml
2. put // @formatter:off and // @formatter:on before a bad formatted portion of 
code
3. mvn java-formatter:format
4. check code in flags is not formatted 

Plugin version: 0.3.1
Maven version:3.0.4
Java version:1.7.0_05, vendor: Oracle
Eclipse version:Juno
OS:Linux Ubuntu

Additional details

here my formatter.xml

Original issue reported on code.google.com by [email protected] on 24 Jun 2013 at 2:28

Attachments:

Change plugin artifactId to conform to maven standards

Artifact Ids of the format maven-__-plugin are reserved for
plugins in the Group Id org.apache.maven.plugins
Please change your artifactId to the format __-maven-plugin
In the future this error will break the build.

Enhancement request: XML Formatting

Eclipse stores its XML format preferences in a separate config file. 
Export->preferences

This is configured from XML->XML Files->Editor

Could you please update this plugin to support XML formatting using Eclipse's 
XML format config?

Original issue reported on code.google.com by [email protected] on 27 Mar 2013 at 7:15

Support filtering out non-writable source files for Perforce compatibility.

The plugin is awesome - just what I needed - except for the fact that it 
expects all the .java source files to be writable.  Unfortunately, perforce 
(scm) manages file permissions (read-only vs read-write) based on state 
(checked-out, etc).  So for a normal use case only the files you've modified 
and are submitting will be writable.  

You can see where this is going… The formatter plugin expects all the files 
in the PlexusIoFileResourceCollection to be writable.  This results in an 
exception being logged for every non-writable file.

Sooo…. It would be awesome to have a way to skip non-writable files in a 
fairly silent manner.  I've downloaded the source code and made a couple of 
very minor edits (see below) to expose a new <configuration> flag called 
<writePermissionCheck> to indicate whether to skip non-writable files.  This is 
just meant as an aid in describing the idea of what I'm looking for - feel free 
to modify : )

I can build/run my local copy, but it would be great if such an enhancement 
could be rolled into an official version so that other perforce users could 
take advantage of the plugin.   Thanks again for creating this useful utility!

Expected output:
 - Non writable source files are "silently" skipped.

Actual output:
 - Non writable source files cause an exception in the build.

Steps to reproduce:
1.  Change a source .java file permissions to read-only and run the formatter.
2.  Notice that an exception is written to the console because the file could 
not be modified.


Plugin version: 0.5-SNAPSHOT (trunk 127)
Maven version: 2.2.1
Java version: 1.7.0_10
Eclipse version: 4.2 (Juno) & 4.3 (Kepler)
OS:  OSX & Windows7

Additional details:

Change the FormatterMojo class as follows…

  1.  Added a new permission check flag, defaults to false for backwards compatibility…

    /**
     * Perform a permissions check on all candidate files,
     * excluding files that are not writable.
     * 
     * @parameter default-value="false"
     * @since 0.5
     */
    private Boolean writePermissionCheck;


  2. Implement the new check if specified…

    /**
     * Format individual file.
     * 
     * @param file
     * @param rc
     * @param hashCache
     * @param basedirPath
     * @throws IOException
     * @throws BadLocationException
     */
    private void doFormatFile(File file, ResultCollector rc,
            Properties hashCache, String basedirPath) throws IOException,
            BadLocationException {
        Log log = getLog();
        log.debug("Processing file: " + file);

        // If Requested Perform Writable Check & Skip If Not Writable
        if(writePermissionCheck && !Files.isWritable(file.toPath()))
        {   
            rc.skippedCount++;
            log.debug("File is not writable.");
            return;
        }
        …

Original issue reported on code.google.com by [email protected] on 12 Sep 2013 at 5:04

Upload artifacts to Maven central repository

What steps will reproduce the problem?
1. Use the plugin in a project and need to specify the google code svn 
repository

What is the expected output? What do you see instead?
Ideally, expect to be able to use plugin without needing to include any extra 
repositories.

Please use labels and text to provide additional information.
Plan is to upload to the Sonatype repository, which syncs to Maven central.
Pom and possibly code need to be updated to conform to requirements.

Original issue reported on code.google.com by [email protected] on 16 Sep 2010 at 3:39

Changing the size of the indentaton

So I got the Google java style from here:
https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml

And added to the formatter plugin. The outputs seemed like it is doing 2-space indentation. But I want 4-space indentation. I think I found the like which controls the indentation:

<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>

Changed to:

<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="4"/>

Ran the formatter:format again, but nothing changed. Am I doing something wrong?

Let's cut the luna release

I don't have much time to work on this currently. Now that things have been rearranged and under new guidence, I don't know that we need to wait to cut the luna release. I'd prefer to get this released so we have something solid there then move on to Mars. If no issues and you have time, cut the release. Or I can later this week.

Add Maven site

What steps will reproduce the problem?
1. Run the mvn site command to produce a site for the project

What is the expected output? What do you see instead?
Expect to include documentation on the goals and usage of the plugin

Please use labels and text to provide additional information.
Comments on the plugin mojo should also be improved

Original issue reported on code.google.com by [email protected] on 23 Sep 2010 at 1:28

Allow the compiler version properties to override those in the config file

What steps will reproduce the problem?
1. Run the plugin with a config file and compiler version properties different 
from those defined in the config file. For example, config file specifies 1.5, 
while the properties specify 1.6.

What is the expected output? What do you see instead?
Currently, the compiler version in the config file is always used despite 
entering compiler properties.
It would be nice to be able to override the config file compiler version using 
the properties. This would allow specifying and updating the version in the 
pom, without also needing to maintain the compiler version in config file.

Please use labels and text to provide additional information.


Original issue reported on code.google.com by [email protected] on 15 Sep 2010 at 8:54

[patch] Update to Eclipse 3.7.1 Service Release 1

Version 0.4-SNAPSHOT (as of rev 117) uses Eclipse 3.3. This causes difficulty 
for people wanting to achieve identical code formatting results in newer 
Eclipse versions and using the plugin.

I have forked maven-java-formatter-plugin at 
https://github.com/benalexau/maven-java-formatter-plugin/ and made the 
following three changes:

1. I have obtained from an Eclipse 3.7.1 SR 1 download all Eclipse JARs used by 
maven-java-formatter-plugin and updated their POMs. These are published in the 
above GitHub repository.

2. The pom.xml has been amended to refer to the new versions.

3. The FormatterMojo was modified to use CodeFormatter.K_COMPILATION_UNIT + 
CodeFormatter.F_INCLUDE_COMMENTS.

This tested fine both via the unit tests and in practical testing against 
actual code. Importantly, the same formatting results were available from 
within the IDE and via the plugin.

While I have published the GitHub fork in a manner that enables end users to 
use the plugin immediately, I would greatly prefer this update was folded into 
the official project and I can take down the forked copy. I put it up to prove 
it worked, and to provide an immediate solution to my own project's needs.

If you have any questions/queries please don't hesitate.

Thanks for taking the time to share this very useful plugin.

Original issue reported on code.google.com by [email protected] on 18 Dec 2011 at 5:19

plugin ignores line wrapping settings

Expected output:
    private static EntityManagerFactory emf = Persistence.createEntityManagerFactory("myHappyService", Collections.emptyMap());

Actual output:
       private static EntityManagerFactory emf = Persistence
                       .createEntityManagerFactory("myHappyService",
                                       Collections.emptyMap());

Steps to reproduce:
1. have a java file with more than 80 characters in one line
2. run maven-java-formatter-plugin 

Plugin version: 0.4
Maven version: 3.1.1
Java version: 1.7.51
Eclipse version: jee, 4.3.1
OS: ubuntu linux

Additional details:
$ grep 140 ~/CodeFormat.xml 
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="140"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="140"/>

When I use the format file within eclipse, it see the expected, non wrapped 
output, but the maven-plugin seems to ignore the wrap settings. I've tried 120, 
140, 200 and even 400, nothing happens. I tried number lower than 80 and that 
did not work as well. So, my guess is, the line wrapping is completely ignored.

Original issue reported on code.google.com by [email protected] on 14 Feb 2014 at 5:23

mars formatting - Align fields in columns

This option seems broken with mars. It doesn't work as advertised within eclipse and broken with mars version of formatter as well.

Expectation...

    int[]  myArray    = { 1, 2, 3, 4, 5, 6 };
    int    theInt     = 1;
    String someString = "Hello";
    double aDouble    = 3.0;

What we are getting...

    int[] myArray = { 1, 2, 3, 4, 5, 6 };
    int theInt = 1;
    String someString = "Hello";
    double aDouble = 3.0;

[feature] Provide a way to exclude paths

I'd like to have a way to exclude some packages/classes under a specific path.

For instance I want to format all .java files under the folder 
src/main/java 
but excluding all files in the folder 
src/main/java/com/mydomain/managed 


Thanks for the plugin.


Original issue reported on code.google.com by manuel.carrasco.m on 11 Nov 2010 at 9:41

Checks for central updates for Eclipse artifacts

What steps will reproduce the problem?
1. Run the build for the plugin or a build using the plugin

What is the expected output? What do you see instead?
Don't expect to see checking for updates from central.
Will see the following:
[INFO] artifact org.eclipse.core:commands: checking for updates from central
[INFO] artifact org.eclipse:osgi: checking for updates from central
[INFO] artifact org.eclipse.equinox:common: checking for updates from central
[INFO] artifact org.eclipse.core:jobs: checking for updates from central
[INFO] artifact org.eclipse.equinox:registry: checking for updates from central
[INFO] artifact org.eclipse.equinox:preferences: checking for updates from 
central
[INFO] artifact org.eclipse.core:contenttype: checking for updates from central

Please use labels and text to provide additional information.
The eclipse poms specify a version range for dependencies, resulting in the 
check for newer artifact versions from central.


Original issue reported on code.google.com by [email protected] on 18 Jan 2011 at 3:42

Strip trailing whitespace

This doesn't appear to be an option in the eclipse formatter but is so useful 
it may be worth adding at this level. A number of tools really don't like 
trailing spaces (such as git) and it is an ambiguity in the formatting rules 
that can cause problems when patching if someones editor is too "helpful". I 
think this could be an "opt-in" option to start with.

It looks like it would be straightforward to add in at this line.

http://code.google.com/p/maven-java-formatter-plugin/source/browse/trunk/src/mai
n/java/com/relativitas/maven/plugins/formatter/FormatterMojo.java#453


if(stripWhitespace){
  formattedCode = formattedCode.replaceAll("\\s+$", "")
}

Original issue reported on code.google.com by [email protected] on 18 Dec 2012 at 8:22

Cleanup use of digester to parse xml

Currently the ruleset class defines object factories, a proxy, and a dummy 
object for parsing the config file xml using the Apache commons digester.

This could be cleaner using only objects matching the config file xml 
(profiles, profile, and setting)

Original issue reported on code.google.com by [email protected] on 23 Sep 2010 at 4:39

Java files have status changed on every execution

What steps will reproduce the problem?
1. Inspect a java file, note the time of the last filesystem stat change.
2. Run java-formatter-plugin
3. Note even if no changes were required to the java file the last status 
change has been changed.

When no formatting changes are required, it would be preferable if the java 
file was unmodified.  

I'm using version 0.3 on MacOSX, as part of the OpenMRS project.

For code editors that use the last stat change date (such as emacs) to detect 
file changes, this prompts the developer every time the java-formatter-plugin 
runs, even when it made no changes.

Original issue reported on code.google.com by [email protected] on 7 Jun 2012 at 12:56

Support directories parameters alongside includes/excludes

Issue #10 switched from directories to use includes/excludes, 
but the deprecated directories parameters should be allowed again.

These should default to the usual main and test sources, but allow using other 
directories as well.

As noted by others:
* Directories outside a Maven project
* Target directories for generated sources

Original issue reported on code.google.com by [email protected] on 11 Oct 2012 at 1:52

Fail when the configFile cannot be found, read, or parsed

What steps will reproduce the problem?
1. Specify a invalid or missing configFile for plugin

What is the expected output? What do you see instead?
Currently, errors will be logged or printed out but the build will continue and 
format files with default settings.
Expect the build to fail when the specified configFile cannot be used.

Please use labels and text to provide additional information.

Original issue reported on code.google.com by [email protected] on 23 Sep 2010 at 1:26

project.build.sourceEncoding should be used

There should be a new 'encoding' parameter
it should default to the project.build.sourceEncoding

1. There is no encoding specified when reading or writing
Uses FileReader/FileWriter (default character encoding)
1a. These could instead use:
InputStreamReader(FileInputStream, encoding)
OutputStreamWriter(FileOutputStream, encoding) 
1b. Commons-IO provides FileUtils:
readFileToString(File, encoding) 
writeStringToFile(File, String, encoding)
1c. Plexus-utils provides Reader/Writer factories:
ReaderFactory.newReader(File, encoding) 
WriterFactory.newWriter(File, encoding) 

2. There is a hard-coded encoding used to generate the md5 hash (ISO8859_1)
Uses String.getBytes()

Reference: 
http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding

Original issue reported on code.google.com by [email protected] on 19 Jan 2011 at 10:03

style checking?

I am in need of this behavior:

  1. format checking done the compile time
  2. code formatting upon formatter:format

No 2 is done by this plugin.
How about No 1? Is it possible to do format-checking with this plugin?

If not, is it possible to use https://maven.apache.org/plugins/maven-checkstyle-plugin/ to do it?
The important issue is that the styles for the format-checker and code-formatter need to be compatible.

Phase should be process-sources instead of compile

What steps will reproduce the problem?
1. Execute a build using the plugin

What is the expected output? What do you see instead?
Expect source files to be reformatted before compiling, but instead source 
files are formatter after compilation

What version of the product are you using? On what operating system?
Version 0.1.0 on Windows

Please provide any additional information below.
Although this can be configured by setting the plugin execution phase, I think 
the process-sources default phase makes more sense.

Original issue reported on code.google.com by [email protected] on 5 Sep 2010 at 3:13

problem with multi-module project

There is a solution here for handling multi-module projects, by creating an additional module build-tools. I was wondering if it is possible to bypass creating this extra module and just add the config file to one of the existing modules. Essentially is it possible to have the following structure for the project?

|-- pom.xml
|-- moduleA
|   |-- src
|   |   `-- main
|   |       `-- resources
|   |           `-- eclipse
|   |               `-- formatter.xml
|   `-- pom.xml
|-- moduleB

And modify the plugin definition to the following:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.googlecode.example.multiproject</groupId>
  <artifactId>multiproject-parent</artifactId>
  <version>1.0</version>
  <packaging>pom</packaging>
  <name>Multiproject Parent</name>
  <build>
    <plugins>
      <plugin>
        <groupId>net.revelc.code</groupId>
        <artifactId>formatter-maven-plugin</artifactId>
        <version>0.5.3-SNAPSHOT</version>
        <executions>
          <execution>
            <goals>
              <goal>format</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <configFile>eclipse/formatter.xml</configFile>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.googlecode.example.multiproject</groupId>
            <artifactId>moduleA</artifactId>
            <version>1.0</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
  <modules>
    <module>moduleA</module>
    <module>moduleB</module>
  </modules>
</project>

When I tried this I got some issues with the definition of the dependency for the plugin.

Maven formatter plugin doesnt produce formatting as per the configuration

What steps will reproduce the problem?
1.Create formatter.xml in eclipse and export it.
2.Run maven java formatter plugin on java source code using exported 
formatter.xml.
3.Format code using CTRL+SHIFT+F in eclipse

What is the expected output? What do you see instead?
Maven java formatter plugin's formatting should be same as eclipse formatting 
as they seems to use the same code.There are lots of differences in formatting 
between eclipse and formatter plugin including formatting maximum line 
length.In configuration i have mentioned the maximum line length as 100 but 
formatter plugin is not formatting the lines with length>100.

What version of the product are you using? On what operating system?
Eclipse :3.6 Helios
Maven:3.0.3 ( I have tried with 2.2.1 version also but still no improvement)
formatter plugin version:0.3.1
OD -windows xp
Java -jdk1.6.0_22


Please provide any additional information below.I have tried using different 
values of lineEnding tag including CRLF,LF but still no improvement.Please find 
attached my formatter file. 


Original issue reported on code.google.com by [email protected] on 1 Jul 2011 at 7:04

Attachments:

Support using settings from maven-compiler-plugin

Like the maven-compiler-plugin, 
Use expression 'maven.compiler.source' for the compiler source/compliance 
params 
Use the expression 'maven.compiler.target' for the compiler target param
Continue to support the default version 1.5 for all params.

Incase the compiler plugin settings are specified in the plugin configuration 
(instead of the above expressions),
Parse the compiler plugin settings (similar to the maven-eclipse-plugin)
Get values for 'source' and 'target' (and even 'encoding' incase the 
'project.build.sourceEncoding' property is not used)

This helps to avoid needing to specify these values again in the formatter 
plugin configuration or move from compiler configuration to properties.

Original issue reported on code.google.com by [email protected] on 1 Mar 2011 at 8:24

Source file multiline comments are reformatted on each run of the plugin

What steps will reproduce the problem?
1. Run the plugin on a source file with a multiline comment
2. Re-run the plugin on the same source file (multiple times)
3. Compare results of re-running plugin on source file (esp for comment)

What is the expected output? What do you see instead?
Expect source files to be formatted and not to be needlessly reformatted on 
each run. Instead, multiline comments are re-indented on each formatting run.

Please use labels and text to provide additional information.
Described in this eclipse formatter issue here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=198963
Bug is for version 3.3 of the formatter (used in the plugin) and apparently 
fixed in version 3.5

Original issue reported on code.google.com by [email protected] on 26 Sep 2010 at 4:42

Format the project with the formatter

One big thing that keeps jumping out at me is use of tabs exensively here. In more modern coding styles that is adviced against. However, that got me thinking, let's format ourselves with the formatter. This just requires we use the prior version to do so. Sort of chicken and egg but would be nice.

If need be, we can add excludes for our internal testing that needs incorrectly formatted classes. This will be more important once we figure out XML formatting.

Can you tell me the maven repository for all versions of the plugin?

I´m using The IDE Eclipse Mars (4.5.0) with the format source feature turned on in the Save Actions. And I use the formatter-maven-plugin 0.5.2 (found in maven central repository) to format all my java source code on Build. But sometimes the plugin formats the code in different way from Eclipse.
In the home page of project there is a table "Eclipse Compatibility" where is shown the version 2.0.0 of plugin is the compatible version for my IDE.

But I can´t find this version 2.0.0 of plugin in any maven public repository.

Can you tell me the maven repository for all versions of the plugin?

Thanks in advance.

Allow the configFile to be resolved from the classpath

What steps will reproduce the problem?
1. Use the plugin in a multi-module build or sharing the same configFile across 
projects
2. Must use a relative path for the configFile, such as at the parent level

What is the expected output? What do you see instead?
Expect to be able to include a dependency on the plugin and allow resolving the 
configFile location in its resources

Please use labels and text to provide additional information.
Functionality described here exists in the CheckStyle plugin where the 
configLocation can be "a URL, File, or build classpath resource reference".
Multi-module checkstyle plugin setup using dependency:
http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-co
nfig.html

Original issue reported on code.google.com by [email protected] on 23 Sep 2010 at 1:20

Build fails when running on my machine

Possibly due to line endings issue I mentioned on enforced validate. The build gets this far.


T E S T S

Running net.revelc.code.formatter.support.io.ResourceTest
Tests run: 13, Failures: 6, Errors: 0, Skipped: 0, Time elapsed: 0.026 sec <<< FAILURE! - in net.revelc.code.formatter.s
upport.io.ResourceTest
testAsInputStreamValidDefaultPackageResource(net.revelc.code.formatter.support.io.ResourceTest) Time elapsed: 0.019 sec
<<< FAILURE!
org.junit.ComparisonFailure: expected:<alpha[]
]eta> but was:<alpha[
beta>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at net.revelc.code.formatter.support.io.ResourceTest.testAsInputStreamValidDefaultPackageResource(ResourceTest.j
ava:73)

testForPath(net.revelc.code.formatter.support.io.ResourceTest) Time elapsed: 0 sec <<< FAILURE!
org.junit.ComparisonFailure: expected:<alpha[]
]eta> but was:<alpha[
beta>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at net.revelc.code.formatter.support.io.ResourceTest.testForPath(ResourceTest.java:223)

testAsString(net.revelc.code.formatter.support.io.ResourceTest) Time elapsed: 0.003 sec <<< FAILURE!
org.junit.ComparisonFailure: expected:<alpha subpackage[]
]eta subpackage> but was:<alpha subpackage[
beta subpackage>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at net.revelc.code.formatter.support.io.ResourceTest.testAsString(ResourceTest.java:114)

testAsInputStreamValidSubpackageResource(net.revelc.code.formatter.support.io.ResourceTest) Time elapsed: 0.001 sec <<
< FAILURE!
org.junit.ComparisonFailure: expected:<alpha subpackage[]
]eta subpackage> but was:<alpha subpackage[
beta subpackage>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at net.revelc.code.formatter.support.io.ResourceTest.testAsInputStreamValidSubpackageResource(ResourceTest.java:
89)

testLoadInputStreamClasspath(net.revelc.code.formatter.support.io.ResourceTest) Time elapsed: 0.001 sec <<< FAILURE!
org.junit.ComparisonFailure: expected:<alpha subpackage[]
]eta subpackage> but was:<alpha subpackage[
beta subpackage>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at net.revelc.code.formatter.support.io.ResourceTest.testLoadInputStreamClasspath(ResourceTest.java:130)

testLoadInputStreamFile(net.revelc.code.formatter.support.io.ResourceTest) Time elapsed: 0 sec <<< FAILURE!
org.junit.ComparisonFailure: expected:<alpha[]
]eta> but was:<alpha[
beta>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at net.revelc.code.formatter.support.io.ResourceTest.testLoadInputStreamFile(ResourceTest.java:146)

Running net.revelc.code.formatter.support.text.TemplateTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec - in net.revelc.code.formatter.support.text.Te
mplateTest

Results :

Failed tests:
ResourceTest.testAsInputStreamValidDefaultPackageResource:73 expected:<alpha[]
]eta> but was:<alpha[
beta>
ResourceTest.testAsInputStreamValidSubpackageResource:89 expected:<alpha subpackage[]
]eta subpackage> but was:<alpha subpackage[
beta subpackage>
ResourceTest.testAsString:114 expected:<alpha subpackage[]
]eta subpackage> but was:<alpha subpackage[
beta subpackage>
ResourceTest.testForPath:223 expected:<alpha[]
]eta> but was:<alpha[
beta>
ResourceTest.testLoadInputStreamClasspath:130 expected:<alpha subpackage[]
]eta subpackage> but was:<alpha subpackage[
beta subpackage>
ResourceTest.testLoadInputStreamFile:146 expected:<alpha[]
]eta> but was:<alpha[
beta>

Tests run: 17, Failures: 6, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................. SUCCESS [ 6.405 s]
[INFO] formatters ......................................... SUCCESS [ 2.412 s]
[INFO] jdt-core ........................................... SUCCESS [ 38.165 s]
[INFO] jsdt-core .......................................... SUCCESS [ 46.219 s]
[INFO] support ............................................ FAILURE [ 1.447 s]
[INFO] formatter-maven-plugin ............................. SKIPPED
[INFO] M2E formatter Connector ............................ SKIPPED
[INFO] net.revelc.code.formatter .......................... SKIPPED
[INFO] net.revelc.code.formatter.feature .................. SKIPPED
[INFO] net.revelc.code.formatter.site ..................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

Default to overriding the config file compiler versions

Avoid needing to specify a parameter to override the compiler versions in the 
config file.

If the values are explicitly set, use them instead of the config file versions.
If the values are not set, use those in the config file.
If none are defined in the config file or the config file is unspecified, use 
the default (1.5)

Remove the override config file parameter, as it would be unnecessary.

Original issue reported on code.google.com by [email protected] on 1 Mar 2011 at 8:25

velo-merge -> jdk usage

Since 0.2, master included ability to override what comes in the configuration files for jdk info. Not sure if that was removed on velo branch or something we really need. Opening this to just not the difference.

Validate mode - should perform formatting

Validate mode fails when formatting possible. It should format the code as well as that makes it easier to know what to commit prior to submitting.

For reference, latest head will not build on my machine without changing validate to format. This appears to be line endings issue.

Anonymous classes keep indenting

What steps will reproduce the problem?
1. Create a class with an anonymous inner class:

public class UniqueName implements Comparable<UniqueName>
{
    public static Comparator<UniqueName> ALPHA_ORDER = new Comparator<UniqueName>()
    {

        @Override
        public int compare(final UniqueName uniqueName1,
                                            final UniqueName uniqueName2)
        {
            if (uniqueName1 == uniqueName2)
            {
                return 0;
            }

            final String uniqueNameString1 = uniqueName1.toString();
            final String uniqueNameString2 = uniqueName2.toString();

            return Compare.twoStrings(uniqueNameString1, uniqueNameString2);
        }
    };

    @Override
    public final int compareTo(final UniqueName other)
    {
        return UniqueName.ALPHA_ORDER.compare(this, other);
    }
}


2. Run the formatter with the format provided.
3. The function signature of the anonymous class's method should be indented.
4. Run the formatter again.
5. The function signature of the anonymous class's method should be further 
indented.
6. Repeat 4&5 until convinced that the signature is no longer on the screen, 
but being pushed to the right. 

What is the expected output? What do you see instead?
I expect the signature to be indented once.  I expect the output of the code to 
be constant between runs of the formatter if no editing is done to the files 
between runs.

What version of the product are you using? On what operating system?
I'm on Mac OS X 10.7.4, I'm using .31 of the code.

Please provide any additional information below.
Apologies for not adding a source file.

Original issue reported on code.google.com by [email protected] on 12 Sep 2012 at 11:08

Attachments:

Can the plugin format the generated-sources

NOTE: Many formatting specific issues are related to the Eclipse version
used. See the compatibility matrix on the Project Home.

Expected output: I am trying to set the configuration to include the java code 
in the generated-source folder. The generated source code is from done through 
a tool that translate some other files to java. I expect the plugin to format 
these java code.

Actual output: both source and test java code are formatted. But the java code 
in generated source are not. I do not know if the plugin supports that or not. 
It could be that I am not doing it right.

Steps to reproduce:
1.
2.
3.

Plugin version:
Maven version:
Java version:
Eclipse version:
OS:

Additional details:
See attached debug build output...

Original issue reported on code.google.com by [email protected] on 7 Mar 2013 at 8:15

build failure on missing src/main/java or src/test/java

What steps will reproduce the problem?
Situation as described in
http://maven-java-formatter-plugin.googlecode.com/svn/site/0.3/examples.html#Mul
timodule_Configuration

What is the expected output? What do you see instead?
I expect non-existing source and test paths to not ignored instead of a build 
failure.

mvn install on the parent fails because there are no src/main/java and 
src/test/java in the parent project. Also fails when the src/test/java is 
missing.

What version of the product are you using? On what operating system?
                <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
                <artifactId>maven-java-formatter-plugin</artifactId>
                <version>0.3</version>
On win XP

Please provide any additional information below.
Part from the build log:
[INFO] [java-formatter:format {execution: default}]
[WARNING] File encoding has not been set, using platform encoding (Cp1252) to fo
rmat source files, i.e. build is platform dependent!
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] basedir D:\java\Performance\src\main\java does not exist
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.IllegalStateException: basedir D:\java\Performance\src\main\java does
not exist
        at org.codehaus.plexus.util.DirectoryScanner.scan(DirectoryScanner.java:
290)
        at org.codehaus.plexus.components.io.resources.PlexusIoFileResourceColle
ction.getResources(PlexusIoFileResourceCollection.java:173)
        at com.relativitas.maven.plugins.formatter.FormatterMojo.addCollectionFi
les(FormatterMojo.java:329)
        at com.relativitas.maven.plugins.formatter.FormatterMojo.execute(Formatt
erMojo.java:270)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:453)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:559)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:500)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:479)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:331)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:292)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:301)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Original issue reported on code.google.com by [email protected] on 3 Mar 2011 at 7:38

only space not working

I want to format code by replace all tab to space
In Eclipse Kepler, Indentation -> tab policy  => use space only
After export xml file, I found two properties
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting 
id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" 
value="true"/>

I think they are conflict settings.
There two way to format my code 
===========Test1: use formatter in Eclipse===========
Expected output:
all tabs are replace to spaces
Actual output:
all tabs are replace to spaces

Steps to reproduce:
1. mouse right click
2. source
3. format


===========Test2: use maven plugin===========
Expected output:
all tabs are replace to spaces
Actual output:
all tabs are replace to spaces, !!!except leading_indentation ones!!!

Steps to reproduce:
1. run plugin

Plugin version: 0.4
Maven version: 3.1.0
Java version: 1.7_x64
Eclipse version: Kepler
OS: Win7_x64

Additional details:
I have tried to set false value to use_tabs_only_for_leading_indentations.
(in text editor, I can not find a way to do this in eclipse )
The result of the Test2 comes to right.

I guess eclipse will ignore use_tabs_only_for_leading_indentations, if 
tabulation.char equals space.


Original issue reported on code.google.com by [email protected] on 30 Oct 2013 at 3:02

Attachments:

Format line with annotation in parameter

What steps will reproduce the problem?
1.configure a maven plugin and the eclipsewith dev_format_new.xml join in this 
ticket 
2.Run maven java formatter plugin on java source code using exported 
formatter.xml.
3.Format code using CTRL+SHIFT+F in eclipse

What is the expected output? 
    @GET
    @Path("/client/{id}")
    @Consumes("application/json")
    @Produces("application/json")
    public Client getClient(@PathParam("id")
    String id) {
        return auditedClientService.getClientById(Long.parseLong(id));
    }

What do you see instead?
 @GET
    @Path("/client/{id}")
    @Consumes("application/json")
    @Produces("application/json")
    public Client getClient(@PathParam("id")
    String id) {
        return auditedClientService.getClientById(Long.parseLong(id));
    }

=> method def child at indentation level 4 not at correct indentation, 8


What version of the product are you using? On what operating system?
maven-java-formatter-plugin>0.3.1
Eclipse => 3.7 
jdk 6
maven 2.2.1 & maven 3

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 2 Dec 2011 at 4:48

Attachments:

formatter plugin skips files for no obvious reason.

What steps will reproduce the problem?
1. Execute mvn java-formatter:format 

What is the expected output? What do you see instead?
I expect to have all of my source code formatted given the rules provided

What version of the product are you using? On what operating system?
CentOS 6
Maven 3
maven-java-formatter-plugin v. 0.3.1
Java 7_10 64bit 

Please provide any additional information below.
There is one specific package in my source folder which is consistently ignored 
by the formatter.  In addition, some files will be formatted once and then 
skipped over when edits are made.  My initial thought is that the checksum is 
the same so I make wild edits to the files (adding silly methods, etc), but the 
formatter continues to ignore the files.

From what I can tell, there is no rhyme or reason to the indiscriminate nature 
of the ignoring.  I have one specific class which has a single method that is 
ignored by the formatter while other methods !WITHIN THE SAME CLASS FILE! are 
formatted properly.

Without digging into the code, I'm at a loss.  Maybe I'll be inspired to check 
out the project in a future weekend, but I have found no where online with 
others describing this behavior.  If someone feels giddy about fixing this (or 
telling me what I'm doing wrong) I'll make some time this weekend to make a 
test project to duplicate the issue.

Attached is the "same class, method formatting ignored" issue.

Original issue reported on code.google.com by [email protected] on 6 Feb 2013 at 8:44

Attachments:

Allow line separator to be configurable for OS independent formatting

What steps will reproduce the problem?
1. Building a project on different OS using this plugin

What is the expected output? What do you see instead?
Expect to be able to have consistent formatting, instead the line separator 
used is dependent on the system

What version of the product are you using? On what operating system?
0.1.0 on Windows

Please provide any additional information below.
Possibly add a parameter for the line separator to use

Original issue reported on code.google.com by [email protected] on 5 Sep 2010 at 3:48

Exception Formatting When add-jars Is Included

**What steps will reproduce the problem?**
1. git clone git://github.com/ClemsonRSRG/RESOLVE.git
2. cd RESOLVE
3. git checkout formatterIssue
4. mvn clean compile

**What is the expected output? What do you see instead?**
Expected output is that the build process should complete successfully.  
Instead, the formatter throws an exception formatting the file 
src/main/java/edu/clemson/cs/r2jt/Main.java:

java.lang.StringIndexOutOfBoundsException: String index out of range: -3

The full output of the build process is attached.

Oddly, this only happens when the addjars-maven-plugin is included.  Commenting 
out the plugin in pom.xml will make the build process succeed.

**What version of the product are you using? On what operating system?**
com.googlecode.maven-java-formatter-plugin:maven-java-formatter-plugin:0.3.1

Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_09, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-18-generic", arch: "i386", family: "unix"

java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Server VM (build 23.5-b02, mixed mode)

Ubuntu 12.10 (also tested on Windows 7)

**Please provide any additional information below.**
As mentioned in "expected behavior", commenting out the addjars-maven-plugin 
plugin block in the pom makes it work fine.  (A version that's identical save 
for the presence of that plugin block can be found at 
https://github.com/ClemsonRSRG/RESOLVE/tree/8a35a3740a62996efb499baa9c0e480b56de
fda1).

Original issue reported on code.google.com by [email protected] on 9 Nov 2012 at 8:27

Attachments:

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.