當前位置: 首頁>>代碼示例>>Java>>正文


Java Project.setProperty方法代碼示例

本文整理匯總了Java中org.gradle.api.Project.setProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Project.setProperty方法的具體用法?Java Project.setProperty怎麽用?Java Project.setProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.gradle.api.Project的用法示例。


在下文中一共展示了Project.setProperty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureConfigurations

import org.gradle.api.Project; //導入方法依賴的package包/類
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.maybeCreate(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.maybeCreate(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:25,代碼來源:BasePlugin.java

示例2: normal

import org.gradle.api.Project; //導入方法依賴的package包/類
@Test
public void normal() throws Exception {
  Project project = ProjectBuilder.builder().withName("api").build();
  project.setGroup("org.curioswitch.test");

  project.getPluginManager().apply(DependencyManagementPlugin.class);
  DependencyManagementExtension dependencyManagement =
      project.getExtensions().getByType(DependencyManagementExtension.class);
  dependencyManagement.dependencies(
      handler -> {
        handler.dependency("io.grpc:grpc-core:5.0.0");
        handler.dependency("io.grpc:grpc-protobuf:5.0.0");
        handler.dependency("io.grpc:grpc-stub:5.0.0");
        handler.dependency("com.google.protobuf:protoc:6.0.0");
      });

  project.getPluginManager().apply("org.curioswitch.gradle-grpc-api-plugin");
  project.setProperty("archivesBaseName", "curio-test-api");

  ((DefaultProject) project).evaluate();

  Task task = project.getTasks().findByName("generateProto");
  assertThat(task).isInstanceOf(GenerateProtoTask.class).isNotNull();
  GenerateProtoTask generateProtoTask = (GenerateProtoTask) task;
  // 2 output dirs for java and grpc, but they are the same in our config.
  String outputDir = project.getBuildDir().getAbsolutePath() + "/generated/source/proto/main";
  assertThat(generateProtoTask.getAllOutputDirs().stream().map(File::getAbsolutePath))
      .containsExactly(outputDir, outputDir);
  assertThat(generateProtoTask.getGenerateDescriptorSet()).isTrue();
  assertThat(generateProtoTask.getDescriptorSetOptions().getIncludeSourceInfo()).isTrue();
  assertThat(generateProtoTask.getDescriptorSetOptions().getIncludeImports()).isTrue();
  assertThat(generateProtoTask.getDescriptorSetOptions().getPath().toString())
      .isEqualTo(
          project.getBuildDir()
              + "/resources/main/META-INF/armeria/grpc/org.curioswitch.test.curio-test-api.dsc");

  ProtobufConfigurator protobuf =
      project.getConvention().getPlugin(ProtobufConvention.class).getProtobuf();
  protobuf.protoc(
      LambdaClosure.of(
          (ExecutableLocator locator) ->
              assertThat(locator.getArtifact()).isEqualTo("com.google.protobuf:protoc:6.0.0")));
  protobuf.plugins(
      LambdaClosure.of(
          (NamedDomainObjectContainer<ExecutableLocator> locators) ->
              assertThat(locators.getByName("grpc").getArtifact())
                  .isEqualTo("io.grpc:protoc-gen-grpc-java:5.0.0")));
}
 
開發者ID:curioswitch,項目名稱:curiostack,代碼行數:49,代碼來源:GrpcApiPluginTest.java


注:本文中的org.gradle.api.Project.setProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。