Errors from Eclipse code when terminating Maven

Open
#865 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
build-system

Research direction

The issue names the Maven spotless-apply execution, the configuration, and an Eclipse workspace metadata stack trace, but no source file or test. Start by reproducing the failure with Maven 3.6.3 on CentOS 7 while terminating the embedded-Tomcat run; done means the configured Eclipse WTP formats no longer emit the workspace-metadata FileNotFoundException.

Written by the indexing model from the issue text.

Description

bug-unconfirmed

A developer on my team gets multiple "Could not write workspace metadata" errors (complete error message below) when terminating a long-running mvn process. This happens for him in two different GitHub projects. He "git cloned" one of them to a different directory and the problem did not occur there. Others on the team have encountered this problem in the past when working on either project, but we don't understand how to make it happen or, more importantly, how to make it not happen. In the problematic directories the errors occur consistently. The errors don't occur if all spotless <format> blocks containing <eclipseWtp> are removed from the pom.xml.

This parent directory of the file referenced in the error message does not exist:

/tmp/com_diffplug_spotless_extra_eclipse611849813376111559/.metadata/.plugins/org.eclipse.core.resources/

The Maven goal that causes the problem is building and then running the target webapp with an embedded Tomcat instance. When the process is terminated using CTRL-C, the errors are printed. In project directories where the problem occurs, it does not seem to matter whether there are code changes known to git or that require reformatting.

Is anybody else who is using <eclipseWtp> seeing this?

Maven 3.6.3
Spotless 2.10.1
CentOS7

<plugin>
    <groupId>com.diffplug.spotless</groupId>
    <artifactId>spotless-maven-plugin</artifactId>
    <version>${version.spotless}</version>
    <configuration>
        <!-- optional: limit format enforcement to just the files changed by this feature branch -->
        <ratchetFrom>origin/main</ratchetFrom>
        <formats>
            <!-- you can define as many formats as you want, each is independent -->
            <format>
                <!-- define the files to apply to -->
                <includes>
                    <include>*.md</include>
                </includes>
                <excludes>
                    <!-- exclude>src/main/java/org/owasp/**/testcode/*.*</exclude -->
                    <exclude>data/**/*.*</exclude>
                    <exclude>results/**/*.*</exclude>
                    <exclude>scorecard/**/*.*</exclude>
                    <exclude>target/**/*.*</exclude>
                </excludes>
                <!-- define the steps to apply to those files -->
                <trimTrailingWhitespace />
                <endWithNewline />
                <indent>
                    <tabs>false</tabs>
                    <spaces>true</spaces>
                    <spacesPerTab>4</spacesPerTab>
                </indent>
            </format>

            <format>
                <includes>
                    <include>**/*.html</include>
                </includes>
                <excludes>
                    <exclude>data/**/*.*</exclude>
                    <exclude>results/**/*.*</exclude>
                    <exclude>target/**/*.*</exclude>
                </excludes>
                <eclipseWtp>
                    <type>HTML</type>
                    <files>
                        <file>${basedir}/DevStyleHtml.prefs</file>
                    </files>
                </eclipseWtp>
            </format>

            <format>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <excludes>
                    <exclude>results/**/*.*</exclude>
                    <exclude>scorecard/**/*.*</exclude>
                    <exclude>target/**/*.*</exclude>
                </excludes>
                <eclipseWtp>
                    <type>XML</type>
                    <files>
                        <file>${basedir}/DevStyleXml.prefs</file>
                    </files>
                </eclipseWtp>
            </format>
        </formats>

        <!-- define a language-specific format -->
        <java>
            <importOrder /> <!-- standard import order -->
            <removeUnusedImports /> <!-- self-explanatory -->

            <!-- apply a specific flavor of google-java-format -->
            <googleJavaFormat>
                <version>1.7</version>
                <style>AOSP</style>
            </googleJavaFormat>
        </java>
    </configuration>

    <executions>
        <execution>
            <id>spotless-apply</id>
            <phase>compile</phase>
            <goals>
                <goal>apply</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Link: https://github.com/OWASP/Benchmark

Maven output:

[INFO] Total time: 04:25 min
[INFO] Finished at: 2021-05-06T12:21:12-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Could not write workspace metadata '/tmp/com_diffplug_spotless_extra_eclipse611849813376111559/.metadata/.plugins/org.eclipse.core.resources/0.snap'.
java.io.FileNotFoundException: /tmp/com_diffplug_spotless_extra_eclipse611849813376111559/.metadata/.plugins/org.eclipse.core.resources/0.snap (No such file or directory)
at java.io.FileOutputStream.open0 (Native Method)
at java.io.FileOutputStream.open (FileOutputStream.java:270)
at java.io.FileOutputStream. (FileOutputStream.java:213)
at java.io.FileOutputStream. (FileOutputStream.java:133)
at org.eclipse.core.internal.localstore.SafeChunkyOutputStream. (SafeChunkyOutputStream.java:48)
at org.eclipse.core.internal.localstore.SafeChunkyOutputStream. (SafeChunkyOutputStream.java:44)
at org.eclipse.core.internal.resources.SaveManager.snapTree (SaveManager.java:1474)
at org.eclipse.core.internal.resources.SaveManager.save (SaveManager.java:1198)
at org.eclipse.core.internal.resources.SaveManager.save (SaveManager.java:1143)
at org.eclipse.core.internal.resources.DelayedSnapshotJob.run (DelayedSnapshotJob.java:55)
at org.eclipse.core.internal.jobs.Worker.run (Worker.java:63)

Dominant language
Java
Stars
5.7k
Forks
560
Avg merge
1d 13h
Merged PRs (30d)
43

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diffplug/spotless

All issues in diffplug/spotless

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.