Java源码示例:org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinates
示例1
public MavenCoordinate depIdToArtifact(String depId) {
Pattern gavPattern = Pattern.compile(
"^(?<groupid>[^:]*):(?<artifactid>[^:]*):(?<version>[^:@]*)(:(?<classifier>[^@]*))?(@(?<type>.*))?$");
Matcher gav = gavPattern.matcher(depId);
gav.find();
if (!gav.matches()) {
throw new IllegalStateException(String.format(
"[ERROR] Invalid dependency locator: '%s'. Expected format is groupId:artifactId:version[:classifier][@type]",
depId));
}
String groupId = gav.group("groupid");
String artifactId = gav.group("artifactid");
String version = formatVersion(gav.group("version"));
String classifier = gav.group("classifier");
String type = Optional.ofNullable(gav.group("type")).orElse("jar");
// String groupId, String artifactId, String classifier, String extension,
// String version
// String groupId, String artifactId, String version, String scope, String type,
// String classifier, ArtifactHandler artifactHandler
// shrinkwrap format: groupId:artifactId:[packagingType:[classifier]]:version
return MavenCoordinates.createCoordinate(groupId, artifactId, version, PackagingType.of(type), classifier);
}
示例2
public MavenDependency createMavenDependency(final ArtifactSpec spec) {
final MavenCoordinate newCoordinate = MavenCoordinates.createCoordinate(
spec.groupId(),
spec.artifactId(),
spec.version(),
PackagingType.of(spec.type()),
spec.classifier());
return MavenDependencies.createDependency(newCoordinate, ScopeType.fromScopeType(spec.scope), false);
}
示例3
@PostConstruct
public void loadDefaultProject() {
String defaultProjectHome = System.getProperty(Application.PROJECT_HOME, System.getenv(Application.PROJECT_HOME_ENV));
if (project == null && StringUtils.hasText(defaultProjectHome)) {
setActiveProject(load(defaultProjectHome));
}
String repositoryUrl = System.getProperty(Application.PROJECT_REPOSITORY, System.getenv(Application.PROJECT_REPOSITORY_ENV));
if (project == null && StringUtils.hasText(repositoryUrl)) {
Repository repository;
String vcs = System.getProperty(Application.PROJECT_VERSION_CONTROL, Optional.ofNullable(System.getenv(Application.PROJECT_VERSION_CONTROL_ENV)).orElse(Repository.VERSION_CONTROL_GIT));
if (vcs.equalsIgnoreCase(Repository.VERSION_CONTROL_GIT)) {
repository = new GitRepository();
} else if (vcs.equalsIgnoreCase(Repository.VERSION_CONTROL_SVN)) {
repository = new SvnRepository();
} else {
throw new ApplicationRuntimeException(String.format("Unsupported version control system '%s'", vcs));
}
repository.setUrl(repositoryUrl);
repository.setBranch(System.getProperty(Application.PROJECT_REPOSITORY_BRANCH,
System.getenv(Application.PROJECT_REPOSITORY_BRANCH_ENV) != null ? System.getenv(Application.PROJECT_REPOSITORY_BRANCH_ENV) : repository.getBranch()));
repository.setModule(System.getProperty(Application.PROJECT_REPOSITORY_MODULE,
System.getenv(Application.PROJECT_REPOSITORY_MODULE_ENV) != null ? System.getenv(Application.PROJECT_REPOSITORY_MODULE_ENV) : repository.getModule()));
repository.setUsername(System.getProperty(Application.PROJECT_REPOSITORY_USERNAME, System.getenv(Application.PROJECT_REPOSITORY_USERNAME_ENV)));
repository.setPassword(System.getProperty(Application.PROJECT_REPOSITORY_PASSWORD, System.getenv(Application.PROJECT_REPOSITORY_PASSWORD_ENV)));
create(repository);
}
String mavenArchetype = System.getProperty(Application.MAVEN_ARCHETYPE_COORDINATES, System.getenv(Application.MAVEN_ARCHETYPE_COORDINATES_ENV));
if (project == null && StringUtils.hasText(mavenArchetype)) {
MavenArchetype archetype = new MavenArchetype();
MavenCoordinate archetypeCoordinates = MavenCoordinates.createCoordinate(mavenArchetype);
archetype.setArchetypeGroupId(archetypeCoordinates.getGroupId());
archetype.setArchetypeArtifactId(archetypeCoordinates.getArtifactId());
archetype.setArchetypeVersion(archetypeCoordinates.getVersion());
String mavenProject = System.getProperty(Application.MAVEN_PROJECT_COORDINATES,
System.getenv(Application.MAVEN_PROJECT_COORDINATES_ENV) != null ? System.getenv(Application.MAVEN_PROJECT_COORDINATES_ENV) : "com.consol.citrus:citrus-project:1.0.0");
MavenCoordinate projectCoordinates = MavenCoordinates.createCoordinate(mavenProject);
archetype.setGroupId(projectCoordinates.getGroupId());
archetype.setArtifactId(projectCoordinates.getArtifactId());
archetype.setVersion(projectCoordinates.getVersion());
archetype.setPackageName(System.getProperty(Application.MAVEN_PROJECT_PACKAGE,
System.getenv(Application.MAVEN_PROJECT_PACKAGE_ENV) != null ? System.getenv(Application.MAVEN_PROJECT_PACKAGE_ENV) : projectCoordinates.getGroupId()));
create(archetype);
}
}
示例4
public static MavenCoordinate toMavenCoordinate(String dep) {
return MavenCoordinates.createCoordinate(dep);
}