当前位置: 首页>>代码示例>>Java>>正文


Java JavaLibrary类代码示例

本文整理汇总了Java中org.gradle.api.internal.java.JavaLibrary的典型用法代码示例。如果您正苦于以下问题:Java JavaLibrary类的具体用法?Java JavaLibrary怎么用?Java JavaLibrary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaLibrary类属于org.gradle.api.internal.java包,在下文中一共展示了JavaLibrary类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureArchivesAndComponent

import org.gradle.api.internal.java.JavaLibrary; //导入依赖的package包/类
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()));
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:20,代码来源:JavaPlugin.java

示例2: configureArchivesAndComponent

import org.gradle.api.internal.java.JavaLibrary; //导入依赖的package包/类
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()));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:JavaPlugin.java

示例3: createPublications

import org.gradle.api.internal.java.JavaLibrary; //导入依赖的package包/类
/**
 * 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);
                    }
                });
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:53,代码来源:MavenConfigPlugin.java


注:本文中的org.gradle.api.internal.java.JavaLibrary类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。