public Location resolve()

in src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java [115:176]


    public Location resolve(String locationSpecification, MessageHolder messageHolder) {
        String[] parts = locationSpecification.split(":");

        Location location = null;

        if (parts.length > 2) {
            String groupId = parts[0];
            String artifactId = parts[1];
            String version = parts[2];

            String type = defaultArtifactType;
            if (parts.length > 3) {
                if (parts[3].trim().length() > 0) {
                    type = parts[3];
                }
            }

            String classifier = defaultClassifier;
            if (parts.length > 4) {
                classifier = parts[4];
            }

            if (parts.length > 5) {
                messageHolder.newMessage().append("Location specification has unused tokens: \'");

                for (int i = 5; i < parts.length; i++) {
                    messageHolder.append(":" + parts[i]);
                }
            }

            Artifact artifact;
            if (classifier == null) {
                artifact = factory.createArtifact(groupId, artifactId, version, null, type);
            } else {
                artifact = factory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
            }

            try {
                resolver.resolve(artifact, remoteRepositories, localRepository);

                if (artifact.getFile() != null) {
                    location = new ArtifactLocation(artifact, locationSpecification);
                } else {
                    messageHolder.addMessage(
                            "Supposedly resolved artifact: " + artifact.getId() + " does not have an associated file.");
                }
            } catch (ArtifactResolutionException e) {
                messageHolder.addMessage(
                        "Failed to resolve artifact: " + artifact.getId() + " for location: " + locationSpecification,
                        e);
            } catch (ArtifactNotFoundException e) {
                messageHolder.addMessage(
                        "Failed to resolve artifact: " + artifact.getId() + " for location: " + locationSpecification,
                        e);
            }
        } else {
            messageHolder.addMessage("Invalid artifact specification: \'" + locationSpecification
                    + "\'. Must contain at least three fields, separated by ':'.");
        }

        return location;
    }