org.wildfly.galleon.maven.ArtifactCoordsUtil Maven / Gradle / Ivy
/*
* Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.galleon.maven;
import org.wildfly.galleon.plugin.ArtifactCoords;
/**
*
* @author Alexey Loubyansky
*/
public class ArtifactCoordsUtil {
public static ArtifactCoords fromJBossModules(String str, String extension) {
final String[] parts = str.split(":");
if(parts.length < 2) {
throw new IllegalArgumentException("Unexpected artifact coordinates format: " + str);
}
final String groupId = parts[0];
final String artifactId = parts[1];
String version = null;
String classifier = null;
if(parts.length > 2) {
if(!parts[2].isEmpty()) {
version = parts[2];
}
if(parts.length > 3) {
if(!parts[3].isEmpty()) {
classifier = parts[3];
}
if(parts.length > 4) {
if(!parts[4].isEmpty()) {
extension = parts[4];
}
if (parts.length > 5) {
throw new IllegalArgumentException("Unexpected artifact coordinates format: " + str);
}
}
}
}
return new ArtifactCoords(groupId, artifactId, version, classifier, extension);
}
}