private URI prepareDistributionUri()

in maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperExecutor.java [101:128]


    private URI prepareDistributionUri() throws URISyntaxException {
        URI source = readDistroUrl();
        if (source.getScheme() == null) {
            // no scheme means someone passed a relative url. In our context only file relative urls make sense.
            return propertiesFile
                    .getParent()
                    .resolve(source.getSchemeSpecificPart())
                    .toUri();
        } else {
            String mvnwRepoUrl = getEnv(MVNW_REPOURL);
            if (mvnwRepoUrl != null && !mvnwRepoUrl.isEmpty()) {
                Logger.info("Detected MVNW_REPOURL environment variable " + mvnwRepoUrl);
                if (mvnwRepoUrl.endsWith("/")) {
                    mvnwRepoUrl = mvnwRepoUrl.substring(0, mvnwRepoUrl.length() - 1);
                }
                String distributionPath = source.getPath();
                int index = distributionPath.indexOf("org/apache/maven");
                if (index > 1) {
                    distributionPath = "/".concat(distributionPath.substring(index));
                } else {
                    Logger.warn("distributionUrl don't contain package name " + source.getPath());
                }
                return new URI(mvnwRepoUrl + distributionPath);
            }

            return source;
        }
    }