org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinates Java Examples

The following examples show how to use org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinates. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DependencyUtil.java    From jbang with MIT License 5 votes vote down vote up
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);
	}
 
Example #2
Source File: ShrinkwrapArtifactResolvingHelper.java    From thorntail with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #3
Source File: ProjectService.java    From citrus-admin with Apache License 2.0 4 votes vote down vote up
@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);
    }
}
 
Example #4
Source File: Utils.java    From arquillian-container-chameleon with Apache License 2.0 4 votes vote down vote up
public static MavenCoordinate toMavenCoordinate(String dep) {
    return MavenCoordinates.createCoordinate(dep);
}