Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eclipse formatters on 2.43.0 does not use correctly maven local repository #2329

Open
glhez opened this issue Nov 4, 2024 · 1 comment
Open
Labels

Comments

@glhez
Copy link

glhez commented Nov 4, 2024

The <eclipse /> step is not respecting localRepository settings in Maven: if you have a <localRepository /> different than Maven default (%USERPROFILE%/.m2/repository on Windows or ${HOME}/.m2/repository on Linux), it tries to create file under the default.

As a technique to avoid having files in .m2/repository, I had created a file in place of a directory in .m2/repository:

# move actual repository
mv ~/.m2/repository ~/.m2/repository_old
# create a file
touch ~/.m2/repository

And then changed the Maven settings.

With this in place, you can see errors because Spotless tries to create a directory .m2/repository/dev which can't work because .m2/repository point to a file (see trace below).

I am under the impression that the problem lies here:

I could create a NTFS junction or a symlink, but on Windows, it is rather inconvenient as I am required to be admin.

Note: to print out the local repository, you can use ./mvnw help:evaluate -Dexpression='session.localRepository.basedir' -N


Settings:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
  <localRepository>E:\some\path\local</localRepository>
  ...
</settings>

Plugin configuration:

        <plugin> <groupId>com.diffplug.spotless</groupId> <artifactId>spotless-maven-plugin</artifactId> <version>2.43.0</version>
          <configuration>
            <java>
              <toggleOffOn />
              <eclipse>
                <!-- <file>${spotless.local.root}/java-formatter.xml</file> -->
              </eclipse>
              <removeUnusedImports />
              <importOrder>
                <order>javax,java,org,com,\#</order>
              </importOrder>
              <formatAnnotations />
            </java>

Error:

java.nio.file.NoSuchFileException: C:\Users\someuser\.m2\repository\dev
    at sun.nio.fs.WindowsException.translateToIOException (WindowsException.java:85)
    at sun.nio.fs.WindowsException.rethrowAsIOException (WindowsException.java:103)
    at sun.nio.fs.WindowsException.rethrowAsIOException (WindowsException.java:108)
    at sun.nio.fs.WindowsFileSystemProvider.createDirectory (WindowsFileSystemProvider.java:527)
    at java.nio.file.Files.createDirectory (Files.java:699)
    at java.nio.file.Files.createAndCheckIsDirectory (Files.java:807)
    at java.nio.file.Files.createDirectories (Files.java:793)
    at dev.equo.solstice.p2.FileMisc.lambda$mkdirs$2 (FileMisc.java:84)
    at dev.equo.solstice.p2.FileMisc.retry (FileMisc.java:101)
    at dev.equo.solstice.p2.FileMisc.retry (FileMisc.java:93)
    at dev.equo.solstice.p2.FileMisc.mkdirs (FileMisc.java:84)
    at dev.equo.solstice.p2.QueryCacheOnDisk.<init> (QueryCacheOnDisk.java:33)
    at dev.equo.solstice.p2.P2Model.query (P2Model.java:129)
    at com.diffplug.spotless.extra.EquoBasedStepBuilder.get (EquoBasedStepBuilder.java:114)
    at com.diffplug.spotless.FormatterStepImpl.calculateState (FormatterStepImpl.java:58)
    at com.diffplug.spotless.LazyForwardingEquality.state (LazyForwardingEquality.java:56)
    at com.diffplug.spotless.LazyForwardingEquality.toBytes (LazyForwardingEquality.java:85)
    at com.diffplug.spotless.LazyForwardingEquality.hashCode (LazyForwardingEquality.java:102)
    at java.util.ArrayList.hashCodeRange (ArrayList.java:677)
    at java.util.ArrayList.hashCode (ArrayList.java:664)
    at com.diffplug.spotless.Formatter.hashCode (Formatter.java:276)
    at java.util.HashMap.hash (HashMap.java:338)
    at java.util.HashMap.put (HashMap.java:618)
    at com.diffplug.spotless.maven.FormattersHolder.create (FormattersHolder.java:43)
    at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:232)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)

Versions:

  • Maven 3.9.9
  • Java 21.0.5 on Windows 10 x64
  • spotless-maven-plugin 2.43.0
@nedtwigg nedtwigg added the bug label Nov 5, 2024
@nedtwigg
Copy link
Member

nedtwigg commented Nov 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants