當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。