org.gradle.api.component.SoftwareComponent Java Examples

The following examples show how to use org.gradle.api.component.SoftwareComponent. 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: DefaultMavenPublication.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void from(SoftwareComponent component) {
    if (this.component != null) {
        throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name));
    }
    this.component = (SoftwareComponentInternal) component;

    for (Usage usage : this.component.getUsages()) {
        // TODO Need a smarter way to map usage to artifact classifier
        for (PublishArtifact publishArtifact : usage.getArtifacts()) {
            artifact(publishArtifact);
        }

        // TODO Need a smarter way to map usage to scope
        for (ModuleDependency dependency : usage.getDependencies()) {
            if (dependency instanceof ProjectDependency) {
                addProjectDependency((ProjectDependency) dependency);
            } else {
                addModuleDependency(dependency);
            }
        }
    }
}
 
Example #2
Source File: DefaultMavenPublication.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void from(SoftwareComponent component) {
    if (this.component != null) {
        throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name));
    }
    this.component = (SoftwareComponentInternal) component;

    for (Usage usage : this.component.getUsages()) {
        // TODO Need a smarter way to map usage to artifact classifier
        for (PublishArtifact publishArtifact : usage.getArtifacts()) {
            artifact(publishArtifact);
        }

        // TODO Need a smarter way to map usage to scope
        for (ModuleDependency dependency : usage.getDependencies()) {
            if (dependency instanceof ProjectDependency) {
                addProjectDependency((ProjectDependency) dependency);
            } else {
                addModuleDependency(dependency);
            }
        }
    }
}
 
Example #3
Source File: DefaultMavenPublication.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void from(SoftwareComponent component) {
    if (this.component != null) {
        throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name));
    }
    this.component = (SoftwareComponentInternal) component;

    for (Usage usage : this.component.getUsages()) {
        // TODO Need a smarter way to map usage to artifact classifier
        for (PublishArtifact publishArtifact : usage.getArtifacts()) {
            artifact(publishArtifact);
        }

        // TODO Need a smarter way to map usage to scope
        for (ModuleDependency dependency : usage.getDependencies()) {
            if (dependency instanceof ProjectDependency) {
                addProjectDependency((ProjectDependency) dependency);
            } else {
                addModuleDependency(dependency);
            }
        }
    }
}
 
Example #4
Source File: DefaultMavenPublication.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void from(SoftwareComponent component) {
    if (this.component != null) {
        throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name));
    }
    this.component = (SoftwareComponentInternal) component;

    for (Usage usage : this.component.getUsages()) {
        // TODO Need a smarter way to map usage to artifact classifier
        for (PublishArtifact publishArtifact : usage.getArtifacts()) {
            artifact(publishArtifact);
        }

        // TODO Need a smarter way to map usage to scope
        for (ModuleDependency dependency : usage.getDependencies()) {
            if (dependency instanceof ProjectDependency) {
                addProjectDependency((ProjectDependency) dependency);
            } else {
                addModuleDependency(dependency);
            }
        }
    }
}
 
Example #5
Source File: AndroidPublishPlugin.java    From shipkit with MIT License 5 votes vote down vote up
public void apply(final Project project) {
    final AndroidPublishConfiguration androidPublishConfiguration = project.getExtensions().create(ANDROID_PUBLISH_EXTENSION, AndroidPublishConfiguration.class);

    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();

    project.getPlugins().apply(LocalSnapshotPlugin.class);
    Task snapshotTask = project.getTasks().getByName(LocalSnapshotPlugin.SNAPSHOT_TASK);
    snapshotTask.dependsOn(MAVEN_LOCAL_TASK);

    project.getPlugins().apply("maven-publish");

    BintrayExtension bintray = project.getExtensions().getByType(BintrayExtension.class);
    bintray.setPublications(PUBLICATION_NAME);

    project.getPlugins().withId("com.android.library", plugin -> {
        deferredConfiguration(project, () -> {
            GradleDSLHelper.publications(project, publications -> {
                MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, publication -> {
                    publication.setArtifactId(androidPublishConfiguration.getArtifactId());

                    SoftwareComponent releaseComponent = project.getComponents().findByName("release");
                    if (releaseComponent == null) {
                        throw new GradleException("'release' component not found in project. " +
                            "Make sure you are using Android Gradle Plugin 3.6.0-beta05 or newer.");
                    }
                    publication.from(releaseComponent);
                    PomCustomizer.customizePom(project, conf, publication);
                });
                LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId());
            });
        });

        //so that we flesh out problems with maven publication during the build process
        project.getTasks().getByName("build").dependsOn(MAVEN_LOCAL_TASK);
    });
}
 
Example #6
Source File: DefaultIvyPublication.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void from(SoftwareComponent component) {
    if (this.component != null) {
        throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name));
    }
    this.component = (SoftwareComponentInternal) component;

    configurations.maybeCreate("default");

    for (Usage usage : this.component.getUsages()) {
        String conf = usage.getName();
        configurations.maybeCreate(conf);
        configurations.getByName("default").extend(conf);

        for (PublishArtifact publishArtifact : usage.getArtifacts()) {
            artifact(publishArtifact).setConf(conf);
        }

        for (ModuleDependency dependency : usage.getDependencies()) {
            // TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id.
            String confMapping = String.format("%s->%s", conf, dependency.getConfiguration());
            if (dependency instanceof ProjectDependency) {
                addProjectDependency((ProjectDependency) dependency, confMapping);
            } else {
                addModuleDependency(dependency, confMapping);
            }
        }
    }
}
 
Example #7
Source File: DefaultIvyPublication.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void from(SoftwareComponent component) {
    if (this.component != null) {
        throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name));
    }
    this.component = (SoftwareComponentInternal) component;

    configurations.maybeCreate("default");

    for (Usage usage : this.component.getUsages()) {
        String conf = usage.getName();
        configurations.maybeCreate(conf);
        configurations.getByName("default").extend(conf);

        for (PublishArtifact publishArtifact : usage.getArtifacts()) {
            artifact(publishArtifact).setConf(conf);
        }

        for (ModuleDependency dependency : usage.getDependencies()) {
            // TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id.
            String confMapping = String.format("%s->%s", conf, dependency.getConfiguration());
            if (dependency instanceof ProjectDependency) {
                addProjectDependency((ProjectDependency) dependency, confMapping);
            } else {
                addModuleDependency(dependency, confMapping);
            }
        }
    }
}
 
Example #8
Source File: DefaultIvyPublication.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void from(SoftwareComponent component) {
    if (this.component != null) {
        throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name));
    }
    this.component = (SoftwareComponentInternal) component;

    configurations.maybeCreate("default");

    for (Usage usage : this.component.getUsages()) {
        String conf = usage.getName();
        configurations.maybeCreate(conf);
        configurations.getByName("default").extend(conf);

        for (PublishArtifact publishArtifact : usage.getArtifacts()) {
            artifact(publishArtifact).setConf(conf);
        }

        for (ModuleDependency dependency : usage.getDependencies()) {
            // TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id.
            String confMapping = String.format("%s->%s", conf, dependency.getConfiguration());
            if (dependency instanceof ProjectDependency) {
                addProjectDependency((ProjectDependency) dependency, confMapping);
            } else {
                addModuleDependency(dependency, confMapping);
            }
        }
    }
}
 
Example #9
Source File: DefaultIvyPublication.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void from(SoftwareComponent component) {
    if (this.component != null) {
        throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name));
    }
    this.component = (SoftwareComponentInternal) component;

    configurations.maybeCreate("default");

    for (Usage usage : this.component.getUsages()) {
        String conf = usage.getName();
        configurations.maybeCreate(conf);
        configurations.getByName("default").extend(conf);

        for (PublishArtifact publishArtifact : usage.getArtifacts()) {
            artifact(publishArtifact).setConf(conf);
        }

        for (ModuleDependency dependency : usage.getDependencies()) {
            // TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id.
            String confMapping = String.format("%s->%s", conf, dependency.getConfiguration());
            if (dependency instanceof ProjectDependency) {
                addProjectDependency((ProjectDependency) dependency, confMapping);
            } else {
                addModuleDependency(dependency, confMapping);
            }
        }
    }
}
 
Example #10
Source File: MavenPublishBasePlugin.java    From gradle-plugins with MIT License 4 votes vote down vote up
public SoftwareComponent getSoftwareComponent() {
    return getProject().getComponents().getByName(getComponentName());
}
 
Example #11
Source File: MavenPublishBasePlugin.java    From gradle-plugins with MIT License 4 votes vote down vote up
public SoftwareComponent getSoftwareComponent() {
    return getProject().getComponents().getByName(getComponentName());
}
 
Example #12
Source File: IvyPublication.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Provides the software component that should be published.
 *
 * <ul>
 *     <li>Any artifacts declared by the component will be included in the publication.</li>
 *     <li>The dependencies declared by the component will be included in the published meta-data.</li>
 * </ul>
 *
 * Currently 2 types of component are supported: 'components.java' (added by the JavaPlugin) and 'components.web' (added by the WarPlugin).
 * For any individual IvyPublication, only a single component can be provided in this way.
 *
 * The following example demonstrates how to publish the 'java' component to a ivy repository.
 * <pre autoTested="true">
 * apply plugin: "java"
 * apply plugin: "ivy-publish"
 *
 * publishing {
 *   publications {
 *     ivy(IvyPublication) {
 *       from components.java
 *     }
 *   }
 * }
 * </pre>
 *
 * @param component The software component to publish.
 */
void from(SoftwareComponent component);
 
Example #13
Source File: MavenPublication.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Provides the software component that should be published.
 *
 * <ul>
 *     <li>Any artifacts declared by the component will be included in the publication.</li>
 *     <li>The dependencies declared by the component will be included in the published meta-data.</li>
 * </ul>
 *
 * Currently 2 types of component are supported: 'components.java' (added by the JavaPlugin) and 'components.web' (added by the WarPlugin).
 * For any individual MavenPublication, only a single component can be provided in this way.
 *
 * The following example demonstrates how to publish the 'java' component to a Maven repository.
 * <pre autoTested="true">
 * apply plugin: "java"
 * apply plugin: "maven-publish"
 *
 * publishing {
 *   publications {
 *     maven(MavenPublication) {
 *       from components.java
 *     }
 *   }
 * }
 * </pre>
 *
 * @param component The software component to publish.
 */
void from(SoftwareComponent component);
 
Example #14
Source File: MavenPublication.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Provides the software component that should be published.
 *
 * <ul>
 *     <li>Any artifacts declared by the component will be included in the publication.</li>
 *     <li>The dependencies declared by the component will be included in the published meta-data.</li>
 * </ul>
 *
 * Currently 2 types of component are supported: 'components.java' (added by the JavaPlugin) and 'components.web' (added by the WarPlugin).
 * For any individual MavenPublication, only a single component can be provided in this way.
 *
 * The following example demonstrates how to publish the 'java' component to a Maven repository.
 * <pre autoTested="true">
 * apply plugin: "java"
 * apply plugin: "maven-publish"
 *
 * publishing {
 *   publications {
 *     maven(MavenPublication) {
 *       from components.java
 *     }
 *   }
 * }
 * </pre>
 *
 * @param component The software component to publish.
 */
void from(SoftwareComponent component);
 
Example #15
Source File: MavenPublication.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Provides the software component that should be published.
 *
 * <ul>
 *     <li>Any artifacts declared by the component will be included in the publication.</li>
 *     <li>The dependencies declared by the component will be included in the published meta-data.</li>
 * </ul>
 *
 * Currently 2 types of component are supported: 'components.java' (added by the JavaPlugin) and 'components.web' (added by the WarPlugin).
 * For any individual MavenPublication, only a single component can be provided in this way.
 *
 * The following example demonstrates how to publish the 'java' component to a Maven repository.
 * <pre autoTested="true">
 * apply plugin: "java"
 * apply plugin: "maven-publish"
 *
 * publishing {
 *   publications {
 *     maven(MavenPublication) {
 *       from components.java
 *     }
 *   }
 * }
 * </pre>
 *
 * @param component The software component to publish.
 */
void from(SoftwareComponent component);
 
Example #16
Source File: IvyPublication.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Provides the software component that should be published.
 *
 * <ul>
 *     <li>Any artifacts declared by the component will be included in the publication.</li>
 *     <li>The dependencies declared by the component will be included in the published meta-data.</li>
 * </ul>
 *
 * Currently 2 types of component are supported: 'components.java' (added by the JavaPlugin) and 'components.web' (added by the WarPlugin).
 * For any individual IvyPublication, only a single component can be provided in this way.
 *
 * The following example demonstrates how to publish the 'java' component to a ivy repository.
 * <pre autoTested="true">
 * apply plugin: "java"
 * apply plugin: "ivy-publish"
 *
 * publishing {
 *   publications {
 *     ivy(IvyPublication) {
 *       from components.java
 *     }
 *   }
 * }
 * </pre>
 *
 * @param component The software component to publish.
 */
void from(SoftwareComponent component);
 
Example #17
Source File: MavenPublication.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Provides the software component that should be published.
 *
 * <ul>
 *     <li>Any artifacts declared by the component will be included in the publication.</li>
 *     <li>The dependencies declared by the component will be included in the published meta-data.</li>
 * </ul>
 *
 * Currently 2 types of component are supported: 'components.java' (added by the JavaPlugin) and 'components.web' (added by the WarPlugin).
 * For any individual MavenPublication, only a single component can be provided in this way.
 *
 * The following example demonstrates how to publish the 'java' component to a Maven repository.
 * <pre autoTested="true">
 * apply plugin: "java"
 * apply plugin: "maven-publish"
 *
 * publishing {
 *   publications {
 *     maven(MavenPublication) {
 *       from components.java
 *     }
 *   }
 * }
 * </pre>
 *
 * @param component The software component to publish.
 */
void from(SoftwareComponent component);
 
Example #18
Source File: IvyPublication.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Provides the software component that should be published.
 *
 * <ul>
 *     <li>Any artifacts declared by the component will be included in the publication.</li>
 *     <li>The dependencies declared by the component will be included in the published meta-data.</li>
 * </ul>
 *
 * Currently 2 types of component are supported: 'components.java' (added by the JavaPlugin) and 'components.web' (added by the WarPlugin).
 * For any individual IvyPublication, only a single component can be provided in this way.
 *
 * The following example demonstrates how to publish the 'java' component to a ivy repository.
 * <pre autoTested="true">
 * apply plugin: "java"
 * apply plugin: "ivy-publish"
 *
 * publishing {
 *   publications {
 *     ivy(IvyPublication) {
 *       from components.java
 *     }
 *   }
 * }
 * </pre>
 *
 * @param component The software component to publish.
 */
void from(SoftwareComponent component);
 
Example #19
Source File: IvyPublication.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Provides the software component that should be published.
 *
 * <ul>
 *     <li>Any artifacts declared by the component will be included in the publication.</li>
 *     <li>The dependencies declared by the component will be included in the published meta-data.</li>
 * </ul>
 *
 * Currently 2 types of component are supported: 'components.java' (added by the JavaPlugin) and 'components.web' (added by the WarPlugin).
 * For any individual IvyPublication, only a single component can be provided in this way.
 *
 * The following example demonstrates how to publish the 'java' component to a ivy repository.
 * <pre autoTested="true">
 * apply plugin: "java"
 * apply plugin: "ivy-publish"
 *
 * publishing {
 *   publications {
 *     ivy(IvyPublication) {
 *       from components.java
 *     }
 *   }
 * }
 * </pre>
 *
 * @param component The software component to publish.
 */
void from(SoftwareComponent component);