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

[maven] using an url as file does not work on windows. #250

Closed
wesnigk-espirit opened this issue May 29, 2018 · 8 comments · Fixed by #254
Closed

[maven] using an url as file does not work on windows. #250

wesnigk-espirit opened this issue May 29, 2018 · 8 comments · Fixed by #254
Labels

Comments

@wesnigk-espirit
Copy link

wesnigk-espirit commented May 29, 2018

  • using an url as file does not work on windows.
  • [ maven 3.2.4 ] gradle or maven version
  • [1.0.0.BETA4 ] spotless version
  • [ windows 10 - 1709] operating system and version
				<configuration>
					<java>
						<eclipse>
							<file>https://git.mycompany.de/projects/INFRA/repos/pm-codestyle/raw/eclipse-java-pm-style.xml</file>
							<version>4.7.1</version>
						</eclipse>
					</java>
</configuration>
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:1.0.0.BETA4:apply (code-formatting) on project project-api: Execution code-formatting of goal com.diffplug.spotless:spotless-maven-plugin:1.0.0.BETA4:apply failed: Unable to create tem
poraty file 'https://git.mycompany.de/projects/INFRA/repos/pm-codestyle/raw/eclipse-java-pm-style-1527576190601.xml' in the output directory: Failed to create directory D:\git\project\api\target\https:\git.mycompany.de\projects\INFRA\repos\pm-codestyle\raw -> [
Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:1.0.0.BETA4:apply (code-formatting) on project project-api: Execution code-formatting of goal com.diffplug.spotless:spotless-maven-plugi
n:1.0.0.BETA4:apply failed: Unable to create temporaty file 'https://git.mycompany.de/projects/INFRA/repos/pm-codestyle/raw/eclipse-java-pm-style-1527576190601.xml' in the output directory
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
        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.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution code-formatting of goal com.diffplug.spotless:spotless-maven-plugin:1.0.0.BETA4:apply failed: Unable to create temporaty file 'https://git.mycompany.de/projects/INFRA/repos/pm-codestyle/raw/ec
lipse-java-pm-style-1527576190601.xml' in the output directory
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:143)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
Caused by: java.lang.RuntimeException: Unable to create temporaty file 'https://git.mycompany.de/projects/INFRA/repos/pm-codestyle/raw/eclipse-java-pm-style-1527576190601.xml' in the output directory
        at com.diffplug.spotless.maven.FileLocator.locateFile(FileLocator.java:46)
        at com.diffplug.spotless.maven.java.Eclipse.newFormatterStep(Eclipse.java:41)
        at com.diffplug.spotless.maven.FormatterFactory.lambda$newFormatter$1(FormatterFactory.java:74)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at com.diffplug.spotless.maven.FormatterFactory.newFormatter(FormatterFactory.java:75)
        at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute(AbstractSpotlessMojo.java:101)
        at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute(AbstractSpotlessMojo.java:95)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        ... 20 more
Caused by: org.codehaus.plexus.resource.loader.FileResourceCreationException: Failed to create directory D:\git\project\api\target\https:\git.mycompany.de\projects\INFRA\repos\pm-codestyle\raw
        at org.codehaus.plexus.resource.DefaultResourceManager.createResourceAsFile(DefaultResourceManager.java:209)
        at org.codehaus.plexus.resource.DefaultResourceManager.getResourceAsFile(DefaultResourceManager.java:101)
        at com.diffplug.spotless.maven.FileLocator.locateFile(FileLocator.java:42)
        ... 34 more

So, i guess the problem is the colon ":" as well as the slashes "/" as they do not work on windows.

@fvgh
Copy link
Member

fvgh commented May 30, 2018

@lutovich I don't know whether you foresee any special treatment for Maven. For Gradle I currently depend on files to determine a signature (location, modification date) for incremental builds.
As a convenience, it can be discussed to automatically download/extract files from HTTP/JAR.
But I think it is difficult to find a generic solution, when the file should be updated. I can't see whether a file on a remote server has changed, nor can I download it every time, since this would prevent offline builds.

@mikula-espirit
I think a proper way for Maven would be the provision download/extract of the configuration at an earlier phase (probably process-test-resources). You have to decide for your HTTP source when the local configuration files shall be updated and how offline builds shall be supported. But I am not the Maven expert. Just my 2 cents...

@lutovich
Copy link
Contributor

@fvgh honestly, I have not thought about incremental builds or fast up-to-date checking. Maybe it is acceptable to download the file every time if it is identified by a URL. I think, right now com.diffplug.spotless.maven.FileLocator will either copy file from a local filesystem or download it from a URL on every execution.

I'll look into this issue.

@wesnigk-espirit
Copy link
Author

It is downloading it every time and this is 100% acceptable. But the temp file has the same name as the given url. This simply does not work on windows machines. If you trim the temp file name to the stuff following the last slash it should work fine.

@fvgh
Copy link
Member

fvgh commented May 30, 2018

As stated before, I think an automatic download is problematic, since there are still a few people and companies out there who do not live in the cloud 😉 . Anyhow, I think the treatment should be similar for Maven and Gradle and located within or above the FileSignature. But please remember that Maven has the offline mode and somehow the solution should respect that.

@lutovich
Copy link
Contributor

@fvgh attached PR fixes the described problem by simplifying the output file name selection. It does not address all your points but makes it possible to use URL file config on Windows. Would be great to get your review!

I do not know any way to bind plugin to a specific phase or make it run a task during some phase. Thus I'm unsure how to implement the suggested process-test-resources approach. We've discussed binding to phases here #188 (comment).

Other maven plugins with similar configuration seem to be using the same file resolution approach. They resolve configs directly during execution. Checkstyle plugin does it here, findbugs does it here.

@nedtwigg
Copy link
Member

If folks want offline support, they can put the config files in the repo. If they want to share config across projects at the cost of no offline support, they can use URLs. Caching URLs for offline use is definitely the ideal solution, but I don't wanna block "good enough" while we wait for "best".

@nedtwigg nedtwigg added the bug label May 31, 2018
@nedtwigg nedtwigg changed the title using an url as file does not work on windows. [maven] using an url as file does not work on windows. May 31, 2018
@fvgh
Copy link
Member

fvgh commented Jun 1, 2018

@lutovich The process-test-resources approach was not for the spotless plugin, but for the user so that the user triggers a download before spotless and apply the filename of the downloaded files in the spotless configuration. My apologizes for causing confusion. @nedtwigg is of course right that a simple solution meeting the users needs is preferred and as you pointed out, your solution is a standard approach in Maven.

@nedtwigg
Copy link
Member

nedtwigg commented Jun 2, 2018

Fixed in 1.13.0.

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

Successfully merging a pull request may close this issue.

4 participants