Java 类org.gradle.api.internal.java.JavaLibrary 实例源码

项目:Pushjet-Android    文件:JavaPlugin.java   
private void configureArchivesAndComponent(final Project project, final JavaPluginConvention pluginConvention) {
    Jar jar = project.getTasks().create(JAR_TASK_NAME, Jar.class);
    jar.getManifest().from(pluginConvention.getManifest());
    jar.setDescription("Assembles a jar archive containing the main classes.");
    jar.setGroup(BasePlugin.BUILD_GROUP);
    jar.from(pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput());
    jar.getMetaInf().from(new Callable() {
        public Object call() throws Exception {
            return pluginConvention.getMetaInf();
        }
    });

    ArchivePublishArtifact jarArtifact = new ArchivePublishArtifact(jar);
    Configuration runtimeConfiguration = project.getConfigurations().getByName(RUNTIME_CONFIGURATION_NAME);

    runtimeConfiguration.getArtifacts().add(jarArtifact);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(jarArtifact);
    project.getComponents().add(new JavaLibrary(jarArtifact, runtimeConfiguration.getAllDependencies()));
}
项目:Reer    文件:JavaPlugin.java   
private void configureArchivesAndComponent(final Project project, final JavaPluginConvention pluginConvention) {
    Jar jar = project.getTasks().create(JAR_TASK_NAME, Jar.class);
    jar.setDescription("Assembles a jar archive containing the main classes.");
    jar.setGroup(BasePlugin.BUILD_GROUP);
    jar.from(pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput());

    ArchivePublishArtifact jarArtifact = new ArchivePublishArtifact(jar);
    Configuration runtimeConfiguration = project.getConfigurations().getByName(RUNTIME_CONFIGURATION_NAME);

    runtimeConfiguration.getArtifacts().add(jarArtifact);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(jarArtifact);
    project.getComponents().add(new JavaLibrary(jarArtifact, runtimeConfiguration.getAllDependencies()));
}
项目:Pushjet-Android    文件:JavaPlugin.java   
private void configureArchivesAndComponent(final Project project, final JavaPluginConvention pluginConvention) {
    Jar jar = project.getTasks().create(JAR_TASK_NAME, Jar.class);
    jar.setDescription("Assembles a jar archive containing the main classes.");
    jar.setGroup(BasePlugin.BUILD_GROUP);
    jar.from(pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput());

    ArchivePublishArtifact jarArtifact = new ArchivePublishArtifact(jar);
    Configuration runtimeConfiguration = project.getConfigurations().getByName(RUNTIME_CONFIGURATION_NAME);

    runtimeConfiguration.getArtifacts().add(jarArtifact);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(jarArtifact);
    project.getComponents().add(new JavaLibrary(jarArtifact, runtimeConfiguration.getAllDependencies()));
}
项目:gradle-project-config    文件:MavenConfigPlugin.java   
/**
 * Create the default Maven publication
 *
 * @param publishingExtension Publishing extension where the publication is created
 * @param projectContext Project context to access project information
 * @param projectConfig Project configuration
 * @param mavenConfig Maven configuration
 * @param configurations Container to access configurations
 * @param services Service manager to obtain service objects
 */
@Mutate
public void createPublications(PublishingExtension publishingExtension, ProjectContext projectContext,
        ProjectConfig projectConfig, MavenConfig mavenConfig, ConfigurationContainer configurations,
        ServiceRegistry services) {
    SoftwareComponentContainer components = services.get(SoftwareComponentContainer.class);
    JavaLibrary javaComponent = components.withType(JavaLibrary.class).getByName("java");

    for (MavenPublicationConfig publicationConfig : mavenConfig.getPublications()) {
        Configuration configuration = configurations
                .getByName(publicationConfig.getArchivesConfiguration());

        publishingExtension.getPublications().create(publicationConfig.getName(), MavenPublication.class,
                p -> {
                    p.setArtifactId(publicationConfig.getArtifactId());

                    List<@NonNull Configuration> runtimeConfigurations = publicationConfig
                            .getRuntimeConfigurations().stream().map(c -> configurations.getByName(c))
                            .collect(Collectors.toList());

                    List<@NonNull Configuration> compileConfigurations = publicationConfig
                            .getCompileConfigurations().stream().map(c -> configurations.getByName(c))
                            .collect(Collectors.toList());

                    List<@NonNull PublishArtifact> artifacts = Collections.emptyList();

                    if (publicationConfig.isAddProjectArtifacts()) {
                        artifacts = javaComponent.getUsages().stream()
                                .flatMap(u -> u.getArtifacts().stream()).collect(Collectors.toList());
                    }

                    PomConfigurator configurator = new PomConfigurator(projectContext, projectConfig,
                            Validate.notNull(runtimeConfigurations),
                            Validate.notNull(compileConfigurations));

                    p.pom(pom -> pom.withXml(xml -> configurator.configurePom(Validate.notNull(xml))));

                    for (PublishArtifact a : configuration.getArtifacts()) {
                        p.artifact(a);
                    }
                });
    }
}