Java Code Examples for org.gradle.api.artifacts.ProjectDependency#getGroup()

The following examples show how to use org.gradle.api.artifacts.ProjectDependency#getGroup() . 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: ProjectDependencyPublicationResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ModuleVersionIdentifier resolve(ProjectDependency dependency) {
    Project dependencyProject = dependency.getDependencyProject();
    ((ProjectInternal) dependencyProject).evaluate();

    PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class);

    if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) {
        // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name
        return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion());
    }

    // See if all publications have the same identifier
    Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class);
    Iterator<? extends PublicationInternal> iterator = publications.iterator();
    ModuleVersionIdentifier candidate = iterator.next().getCoordinates();
    while (iterator.hasNext()) {
        ModuleVersionIdentifier alternative = iterator.next().getCoordinates();
        if (!candidate.equals(alternative)) {
            throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications.");
        }
    }
    return candidate;

}
 
Example 2
Source File: ProjectDependencyPublicationResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ModuleVersionIdentifier resolve(ProjectDependency dependency) {
    Project dependencyProject = dependency.getDependencyProject();
    ((ProjectInternal) dependencyProject).evaluate();

    PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class);

    if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) {
        // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name
        return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion());
    }

    // See if all publications have the same identifier
    Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class);
    Iterator<? extends PublicationInternal> iterator = publications.iterator();
    ModuleVersionIdentifier candidate = iterator.next().getCoordinates();
    while (iterator.hasNext()) {
        ModuleVersionIdentifier alternative = iterator.next().getCoordinates();
        if (!candidate.equals(alternative)) {
            throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications.");
        }
    }
    return candidate;

}
 
Example 3
Source File: ProjectDependencyPublicationResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ModuleVersionIdentifier resolve(ProjectDependency dependency) {
    Project dependencyProject = dependency.getDependencyProject();
    ((ProjectInternal) dependencyProject).evaluate();

    PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class);

    if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) {
        // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name
        return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion());
    }

    // See if all publications have the same identifier
    Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class);
    Iterator<? extends PublicationInternal> iterator = publications.iterator();
    ModuleVersionIdentifier candidate = iterator.next().getCoordinates();
    while (iterator.hasNext()) {
        ModuleVersionIdentifier alternative = iterator.next().getCoordinates();
        if (!candidate.equals(alternative)) {
            throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications.");
        }
    }
    return candidate;

}
 
Example 4
Source File: ProjectDependencyPublicationResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ModuleVersionIdentifier resolve(ProjectDependency dependency) {
    Project dependencyProject = dependency.getDependencyProject();
    ((ProjectInternal) dependencyProject).evaluate();

    PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class);

    if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) {
        // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name
        return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion());
    }

    // See if all publications have the same identifier
    Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class);
    Iterator<? extends PublicationInternal> iterator = publications.iterator();
    ModuleVersionIdentifier candidate = iterator.next().getCoordinates();
    while (iterator.hasNext()) {
        ModuleVersionIdentifier alternative = iterator.next().getCoordinates();
        if (!candidate.equals(alternative)) {
            throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications.");
        }
    }
    return candidate;

}