question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XML formatter config is sometimes not applied when running gradle --parallel

See original GitHub issue

At this moment, don’t know if this is a gradle or spotless-plugin problem.

Sometimes, when running gradle --parallel, the configFile() setting is not applied, or is applied too late (after formatting has started in another thread)

Command line used from Jenkins is: gradle --parallel build check --info

05:26:04 ------------------------------------------------------------
05:26:04 Gradle 5.6.3
05:26:04 ------------------------------------------------------------
05:26:04 
05:26:04 Build time:   2019-10-18 00:28:36 UTC
05:26:04 Revision:     bd168bbf5d152c479186a897f2cea494b7875d13
05:26:04 
05:26:04 Kotlin:       1.3.41
05:26:04 Groovy:       2.5.4
05:26:04 Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019
05:26:04 JVM:          1.8.0_231 (Oracle Corporation 25.231-b11)
05:26:04 OS:           Linux 3.10.0-1062.el7.x86_64 amd64
...
05:26:18 Downloading https://plugins.gradle.org/m2/com/diffplug/spotless/spotless-plugin-gradle/3.26.1/spotless-plugin-gradle-3.26.1.jar to XXXX
05:26:25 Downloading https://plugins.gradle.org/m2/com/diffplug/spotless/spotless-eclipse-base/3.2.1/spotless-eclipse-base-3.2.1.pom to XXXX
05:26:25 Downloading https://plugins.gradle.org/m2/com/diffplug/spotless/spotless-eclipse-wtp/3.15.1/spotless-eclipse-wtp-3.15.1.pom to XXXX

This is the spotless version:

classpath group: 'com.diffplug.spotless', name: 'spotless-plugin-gradle', version: '3.26.1'

This is the spotless configuration:

  spotless {
        java {
            googleJavaFormat('1.7')
            licenseHeaderFile file("$project.rootProject.projectDir/config/license.java")
        }
        format 'gradle', {
            target '**/*.gradle'
            trimTrailingWhitespace()
            indentWithSpaces(2)
            endWithNewline()
        }
        format 'xml', {
            target fileTree('.') {
                include '**/*.xml'
                exclude '**/build/**'
            }
            eclipseWtp('xml').configFile("$project.rootProject.projectDir/config/spotless.xml.prefs")
        }
    }

The xml prefs are the standard eclipse prefs:

user@host> cat config/spotless.xml.prefs
eclipse.preferences.version=1
indentationChar=space
indentationSize=2
lineWidth=200
user@host>

Error message (trimmed):

05:26:32 FAILURE: Build failed with an exception.
05:26:32 
05:26:32 * What went wrong:
05:26:32 Execution failed for task ':some-proj:spotlessXml'.
05:26:32 > The following files had format violations:
05:26:32       some-proj/path/some-file.xml
05:26:32           @@ -1,93 +1,117 @@
05:26:32            <?xml·version="1.0"·encoding="UTF-8"·standalone="no"?>
05:26:32           -<tag foo="value that is quite long and is likely to span several lines when formatted">
05:26:32           -··<!--·some comment·-->
05:26:32           -··<child-tag name="some-name"·value="123456789"·/>
05:26:32           +<tag
05:26:32           +\t\tname="value that is quite long and is likely to span several lines when formatted">
05:26:32           +\t\t<!--·some comment·-->
05:26:32           +\t\t<child-tag name="some-name"·value="123456789"·/>
...

It should be noted that the file was already formatted (as is seen in the above output, using two spaces) when this error was seen. Something in either gradle or spotless causes the formatter to start formatting before it has received the correct service config (i.e. the contents of the property file). I’d be happy to help to figure out what, if you could guide me into where to start looking (e.g. what are the entry points between the spotless plugin/ gradle configuration and the wtp formatter).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
fvghcommented, Feb 15, 2020

Sorry, thought that it was related to an issue I found. But it is not.

0reactions
aaimecommented, Apr 5, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Declaring dependencies - Gradle User Manual
A configuration which has canBeResolved set to false is not meant to be resolved. Such a configuration is there only to declare dependencies....
Read more >
Understanding Gradle Module Metadata - Gradle User Manual
Gradle Module Metadata is a format used to serialize the Gradle component model. It is similar to Apache Maven™'s POM file or Apache...
Read more >
Upgrading your build from Gradle 6.x to the latest
Head over to the documentation to learn how to migrate to the new format. The migration can be performed per configuration and does...
Read more >
Testing in Java & JVM projects - Gradle User Manual
You can run your tests in parallel by setting this property to a value greater ... XML test results in a format compatible...
Read more >
Learning the Basics - Gradle User Manual
The following sections describe repositories format, Maven or Ivy. ... If no settings.xml is available, Gradle uses the default location ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found