Giter Club home page Giter Club logo

tidy-maven-plugin's People

Contributors

andham avatar bmarwell avatar dantran avatar darxriggs avatar dennisl avatar dependabot[bot] avatar dmitry-timofeev avatar hboutemy avatar jieryn avatar jlleitschuh avatar khmarbaise avatar larslindq avatar pzygielo avatar slachiewicz avatar slawekjaranowski avatar stefanbirkner avatar stephan202 avatar stephenc avatar

Stargazers

 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  avatar  avatar  avatar  avatar  avatar  avatar

tidy-maven-plugin's Issues

Modules placement does not work with archetype

We have a number of custom archetypes that we use for development, and we were rolling tidy pom into them, but have run into this issue.

In an archetype there is no modules section in the parent pom, it is added during the process, but it is added between and in my case, but tidy pom wants it at the end of the file.

This issue causes our integration test of the archetype to fail.

Dependency Exclusions groupId/artifactId get inconsistency ordered

When a dependency have multiple exclusions, is seems like the order of groupId and artifactId are consistently, ordered inconsistently:

      <exclusions>
        <exclusion>
          <groupId>com.smxemail</groupId>
          <artifactId>*</artifactId>
        </exclusion>
        <exclusion>
          <artifactId>*</artifactId>
          <groupId>smx3</groupId>
        </exclusion>
      </exclusions>

The first exclusion, puts groupId first as expected, but the second gets artifactId first.

Please release a new version that includes the threadSafe fix

this was fixed in #27 however no new version was released since then.

we would like to avoid these warnings in all of our modules:

2022-03-10T07:47:46.4483999Z [INFO] --------------------------------[ jar ]---------------------------------
2022-03-10T07:47:46.4484394Z [WARNING] *****************************************************************
2022-03-10T07:47:46.4484675Z [WARNING] * Your build is requesting parallel execution, but project      *
2022-03-10T07:47:46.4484980Z [WARNING] * contains the following plugin(s) that have goals not marked   *
2022-03-10T07:47:46.4485294Z [WARNING] * as @threadSafe to support parallel building.                  *
2022-03-10T07:47:46.4485660Z [WARNING] * While this /may/ work fine, please look for plugin updates    *
2022-03-10T07:47:46.4486065Z [WARNING] * and/or request plugins be made thread-safe.                   *
2022-03-10T07:47:46.4486369Z [WARNING] * If reporting an issue, report it against the plugin in        *
2022-03-10T07:47:46.4486730Z [WARNING] * question, not against maven-core                              *
2022-03-10T07:47:46.4486979Z [WARNING] *****************************************************************
2022-03-10T07:47:46.4487376Z [WARNING] The following plugins are not marked @threadSafe in (project):
2022-03-10T07:47:46.4487791Z [WARNING] org.codehaus.mojo:tidy-maven-plugin:1.1.0
2022-03-10T07:47:46.4488107Z [WARNING] Enable debug to see more precisely which goals are not marked @threadSafe.
2022-03-10T07:47:46.4488392Z [WARNING] *****************************************************************

Thank you

indent size ignored

Plugin states that

The pom.xml file will be rewritten according to the POM Code Convention of the Maven team.

POM Code Convention states that

Indentation: Always use 2 space indents, unless you're wrapping a new XML tags line in which case you should indent 4 spaces.

Tidy-maven-plugin seems to ignore indent altogether.

Make plugin @threadSafe

Please mark the tidy-maven-plugin as @threadSafe (likely safe, unless some underlying XML parser factory or similar isn’t).

How to avoid checking maven-shade-plugin: dependency-reduced-pom.xml?

Using tidy-maven-plugin:1.2.0, I'm seeing a build failure while running clean package deploy on a multi-module project. It appears tidy:check is checking the generated file: dependency-reduced-pom.xml, and failing the build because that file is not formatted correctly.

Is there some way to make tidy ignore the generated dependency-reduced-pom.xml file?

FWIW, using <createDependencyReducedPom>false</createDependencyReducedPom> on the maven-shade-plugin does not solve the issue as there are other side effects from not generating this pom. I also tried moving the location of that generated file, and renaming it.

In case it matters, tidy:check is configured in an external parent pom:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tidy-maven-plugin</artifactId>
                <version>1.2.0</version>
                <executions>
                    <execution>
                        <id>validate</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Also wondering if there is some way to force a tidy:pom invocation on just the generated file to get that file reformatted before the tidy:check occurs?

Update: Well in true "describe the problem, solve the problem" fashion, I just ran clean deploy (without the explicit package phase), and the problem does not occur. It this behavior "expected"?

PS: Thanks for this nifty plugin!

comments in pom are moved by tidy:pom

tidy-m-p staged v1.0.0
Maven 3.3.3 on Oracle JDK 1.7.0_79 on Windows 7.

For some scenarios the pom mojomoves comments in the pom.

  1. Case 1

    <dependency>
        <!-- bla bla -->
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>
    

is changed to

    <dependency><!-- bla bla -->
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>
  1. Case 2:

    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-java-dsl</artifactId>
        <version>1.1.2.RELEASE</version> <!-- TODO bla bla -->
    </dependency>
    

is changed to

    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-java-dsl</artifactId>
        <version>1.1.2.RELEASE</version>
        <!-- TODO bla bla -->
    </dependency>

Apply XML Code Style

http://maven.apache.org/developers/conventions/code.html#XML_Code_Style

Tidy currently applies the "POM Code Convention". However since pom.xml files are also XML, the "XML Code Style" should also be applied. In particular, tabs should not be used, and indentation is mostly 2-spaces, with 4-space "hanging" indents for long opening tags (many attributes). Line breaks are also required in many places -- all complex XML types -- and forbidden in a few -- simple XML types.

While it is possible that some projects would prefer to follow the "POM Code Convention" without the "XML Code Style"; they are likely to be rare. In any case, it would be a nice option for tidy-maven-plugin to also apply the XML Code Style, either by default or at least when explicitly requested, either via a new goal or configuration of the existing check/pom goals.

May be a duplicate of #18

com.ctc.wstx.exc.WstxParsingException:

Taking a failure during tidy:pom and tidy:check. The line specified, 2766 is actually the end of file.

[ERROR] Failed to execute goal org.codehaus.mojo:tidy-maven-plugin:1.0.0:check (default-cli) on project base: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
[ERROR] at [row,col {unknown-source}]: [2766,7]
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tidy-maven-plugin:1.0.0:check (default-cli) on project base: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
 at [row,col {unknown-source}]: [2766,7]
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:185)
        at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:181)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.plugin.MojoExecutionException: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
 at [row,col {unknown-source}]: [2766,7]
        at org.codehaus.mojo.tidy.TidyMojo.tidy(TidyMojo.java:106)
        at org.codehaus.mojo.tidy.CheckMojo.executeForPom(CheckMojo.java:39)
        at org.codehaus.mojo.tidy.TidyMojo.execute(TidyMojo.java:67)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        ... 11 more
Caused by: com.ctc.wstx.exc.WstxParsingException: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
 at [row,col {unknown-source}]: [2766,7]
        at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:580)
        at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:453)
        at com.ctc.wstx.sr.BasicStreamReader.readPIPrimary(BasicStreamReader.java:3877)
        at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2017)
        at com.ctc.wstx.sr.BasicStreamReader.closeContentTree(BasicStreamReader.java:2858)
        at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2609)
        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1054)
        at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255)
        at org.codehaus.mojo.tidy.task.EnsureOrderAndIndent$SectionSorter.sortSections(EnsureOrderAndIndent.java:117)
        at org.codehaus.mojo.tidy.task.EnsureOrderAndIndent.tidyPom(EnsureOrderAndIndent.java:78)
        at org.codehaus.mojo.tidy.task.PomTidy.tidy(PomTidy.java:44)
        at org.codehaus.mojo.tidy.TidyMojo.tidy(TidyMojo.java:102)
        ... 15 more

I was able to figure out what in my pom.xml is causing this, it's build > pluginManagement > plugins >

        <plugin>
          <groupId>org.apache.openejb.maven</groupId>
          <artifactId>tomee-maven-plugin</artifactId>
          <configuration>
            <synchronization>
              <extensions>
                <extension>.class</extension>   
                <extension>.css</extension>
                <extension>.html</extension>
                <extension>.js</extension>
                <extension>.ui.xml</extension>
              </extensions>
            </synchronization>
          </configuration>
        </plugin>

Falling back to 1.0-beta-1 lets tidy:pom work again.

More specific section paths when sorting

Some paths for sections in the SectionSorter is currently too loosely specified, which causes problems e.g. with some plugins which have configuration elements with the same name as some elements/sections of the pom.

Pom goal destroys poms that use shade relocation

The SectionSorter defined at https://github.com/mojohaus/tidy-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/tidy/task/EnsureOrderAndIndent.java#L70 incorrectly matches "relocation" sections of the pom such as:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.3</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <relocations>
                    <relocation>
                        <pattern>com.foo.bar</pattern>
                        <shadedPattern>somewhereelse.com.foo.bar</shadedPattern>
                    </relocation>
                </relocations>
            </configuration>
        </execution>
    </executions>
</plugin>

This interacts badly to cause the whole pom to be duplicated a number of times. This can be fixed by setting the scope to "/project/distributionManagement/relocation", however I don't know if this will have any unintended side effects.

It seems that there are a number of quite loose matchers there that could interact badly with any pom that contains third party plugin that uses "exclusion", "extension", "parent", "plugin" or "relocation" in their configuration.

tidy:pom concatentes original and tidied POM, producing invalid XML

The following self-contained pom.xml is completely broken by tidy:pom (version 1.0.0):

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>example</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.apache.maven.indexer</groupId>
            <artifactId>indexer-core</artifactId>
            <version>5.1.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <relocations>
                                <relocation>
                                    <pattern>org.apache.lucene</pattern>
                                    <shadedPattern>org.apache.maven.indexer.lucene</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

The resulting POM consists of two POMs concatenated together:

…
    </build>
</project>
  <?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>
…

Also, the resulting POM contains this sequence of broken formatting:

<relocations>
    <relocation><pattern>org.apache.lucene</pattern>
        <shadedPattern>org.apache.maven.indexer.lucene</shadedPattern>
    </relocation>
</relocations>

Trailing blank rows in dependencies block are not removed

tidy-m-p staged v1.0.0
Maven 3.3.3 on Oracle JDK 1.7.0_79 on Windows 7.

For this snippet:

<dependencies>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>


</dependencies>

I'd like the trailing blank rows to be removed (before the close dependencies tag), which they aren't.

tidy:check tries to check (virtual) pom.xml of POM-less Tycho build

Eclipse Tycho (a Maven plugin used to build OSGi bundles with Maven) has a .mvn/extensions.xml build extension that allows POM-less builds for projects with a certain <packaging> to not have a physical pom.xml; all information in the POM is inferred from other files in the project (META-INF/MANIFEST.MF).

Apparently, tidy:check tries to check the (virtual) POM of the POM-less Tycho project – and fails.
The attached project illustrates this problem. Performing a mvn clean verify ultimately results in

[ERROR] Failed to execute goal org.codehaus.mojo:tidy-maven-plugin:1.0.0:check (check-pom) on project org.example.plugin: The POM violates the code style. Please format it by running `mvn tidy:pom`. -> [Help 1]

FWIW, if you think that this is rather a problem with Tycho, feel free to open a bug with the Tycho project instead.

WstxParsingException when using properties ending on dependency or plugin.

Hi guys!

I just found this line...

This actually should be return path.endsWith( "/" + scope ); as we are looking for the element named like the scope, not an element ending just with the scope...

The current version causes an exception when a property is ending with something like "-dependency" or "-plugin.

com.ctc.wstx.exc.WstxParsingException: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
 at [row,col {unknown-source}]: [15,7]
	at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:621)
	at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:491)
	at com.ctc.wstx.sr.BasicStreamReader.readPIPrimary(BasicStreamReader.java:4019)
	at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2141)
	at com.ctc.wstx.sr.BasicStreamReader.closeContentTree(BasicStreamReader.java:2991)
	at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2734)
	at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1123)
	at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255)
	at org.codehaus.mojo.tidy.task.EnsureOrderAndIndent$SectionSorter.sortSections(EnsureOrderAndIndent.java:110)
	at org.codehaus.mojo.tidy.task.EnsureOrderAndIndent.tidyPom(EnsureOrderAndIndent.java:71)
	at org.codehaus.mojo.tidy.task.PomTidy.tidy(PomTidy.java:44)

Don't flag HTTPS xsi:schemaLocations as invalid

After 52917c0 the tidy-maven-plugin now uses HTTPS for xsi:schemaLocations (good). But ironically tidy:check itself still insists that only HTTP xsi:schemaLocations are valid (bad):

<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">

is valid, but

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

is not.

Also, tidy:format reverts https://maven.apache.org/xsd/maven-4.0.0.xsd back to http://maven.apache.org/xsd/maven-4.0.0.xsd, which it shouldn’t.

Support for validating other XML related files (i.e. assembly descriptors).

I'd like to use this plugin but to use this we'd like to be able to also check our assembly descriptors. I'd be happy to do the work if you're open to this behavior.

I was thinking of something akin the following for the configuration:

<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>tidy-maven-plugin</artifactId>
	<version>1.1.0</version>
	<configuration>
		<includes>
			<include>pom.xml</include>
			<include>src/assembly/*.xml</include>
		</includes>
	</configuration
</plugin>

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.