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

mavenLocal broken when <localRepository>/my-relocated-maven-repo</localRepository> found in Maven settings.xml #2843

Closed
avelella opened this issue Aug 31, 2017 · 5 comments

Comments

@avelella
Copy link

avelella commented Aug 31, 2017

Regression in 4.1 compared to 3.4.1 - mavenLocal() does not work

Expected Behavior

Dependencies or plugins can't be read from mavenLocal(), where maven local is configured in my settings.xml to be in a custom location.

Current Behavior

I can publish to mavenLocal() and it goes to my custom repository. I can't read from mavenLocal(). Gradle does see my custom settings.xml, but it's using the current directory as the base. E.g.: (current-directory)/my-relocated-maven-repo

This looks a lot like the issue reported here: #1811

But that issue was using the empty tag: <localRepository/>

Context

We can't use mavenLocal in our builds.

Steps to Reproduce (for bugs)

Create a file ~/.m2/settings.xml

Contents:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localRepository>/my-relocated-maven-repo</localRepository> 
</settings>

Your Environment

Windows. Gradle 4.1.

@bigdaz
Copy link
Member

bigdaz commented Aug 31, 2017

In Gradle 3.5, we improved performance by removing the need to spawn an external process to read the Maven settings.xml file: 547a802. In doing so, we switched from using DefaultSettingsBuilder to use the lighter-weight DefaultSettingsReader (both Maven types).

In doing so, it looks like we lost this special handling of absolute file paths on Windows:

// for the special case of a drive-relative Windows path, make sure it's absolute to save plugins from trouble
String localRepository = userSettings.getLocalRepository();
if ( localRepository != null && localRepository.length() > 0 )
{
    File file = new File( localRepository );
    if ( !file.isAbsolute() && file.getPath().startsWith( File.separator ) )
    {
        userSettings.setLocalRepository( file.getAbsolutePath() );
    }
}

So this is the case where /file/path is not an absolute path on Windows, since it's missing the drive prefix.
If we do add this behaviour, we should probably do it after we've done any placeholder replacement here:

@avelella would you be interested in contributing a fix? We'd need some test coverage in DefaultLocalMavenRepositoryLocatorTest.groovy.

In the meantime, I think a workaround would be to provide a fully-qualified file path for windows (with the drive letter).

blindpirate added a commit that referenced this issue Sep 18, 2017
…localRepository (#2843)

#2843
On Windows, there's a special case to be handled in Maven localRepository element:
/absolute-path is a drive-relative path. This PR fixed this issue.
@blindpirate blindpirate self-assigned this Sep 18, 2017
blindpirate added a commit that referenced this issue Sep 22, 2017
…localRepository (#2843) (#2963)

#2843
On Windows, there's a special case to be handled in Maven localRepository element:
/absolute-path is a drive-relative path. This PR fixed this issue.
@bmuschko
Copy link
Contributor

bmuschko commented Sep 23, 2017

@blindpirate Can you please add the milestone so we know later what version of Gradle introduced the fix? Please also don't forget to mention the contribution in the release notes!

@blindpirate blindpirate added this to the 4.3 RC1 milestone Sep 24, 2017
@blindpirate
Copy link
Collaborator

@bmuschko No problem!

@blindpirate
Copy link
Collaborator

@bmuschko Looks like fixed issues are rendered via https://services.gradle.org/fixed-issues/4.2, and not written in notes.md. I'm wondering where should I write this issue down?

@bmuschko
Copy link
Contributor

@blindpirate Never mind about the release notes. For some reason I thought this was a PR.

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

No branches or pull requests

4 participants