Java 类org.gradle.api.NamedDomainObjectContainer 实例源码

项目:atlas    文件:AtlasExtension.java   
public AtlasExtension(@NonNull final ProjectInternal project,
                      @NonNull Instantiator instantiator,
                      @NonNull NamedDomainObjectContainer<T> buildTypes,
                      @NonNull NamedDomainObjectContainer<PatchConfig> patchConfigs,
                      @NonNull NamedDomainObjectContainer<DexConfig>dexConfigs) {

    logger = Logging.getLogger(this.getClass());
    this.project = project;

    this.patchConfigs = patchConfigs;
    this.dexConfigs = dexConfigs;
    this.buildTypes = buildTypes;
    this.multiDexConfigs = project.container(MultiDexConfig.class, new MultiDexConfigFactory(
        instantiator,project, project.getLogger()));

    tBuildConfig = (Z) instantiator.newInstance(TBuildConfig.class);
    manifestOptions = instantiator.newInstance(ManifestOptions.class);
    bundleConfig = instantiator.newInstance(BundleConfig.class);
}
项目:atlas    文件:AtlasExtensionFactory.java   
public AtlasExtension createExtendsion(Project project, Instantiator instantiator) {

        AtlasExtension atlasExtension = getExtendsion(project);

        if (null != atlasExtension) {
            return atlasExtension;
        }

        final NamedDomainObjectContainer<TBuildType> buildTypeContainer = project.container(TBuildType.class,
                                                                                            new TBuildTypeFactory(
                                                                                                instantiator, project,
                                                                                                project.getLogger()));
        final NamedDomainObjectContainer<PatchConfig> patchConfigContainer = project.container(PatchConfig.class,
                                                                                               new PatchConfigFactory(
                                                                                                   instantiator,
                                                                                                   project, project
                                                                                                       .getLogger()));
        final NamedDomainObjectContainer<DexConfig>dexConfigContainer = project.container(DexConfig.class,new DexConfigFactory(instantiator,project,project.getLogger()));

        return project.getExtensions().create("atlas", AtlasExtension.class, project, instantiator,
                                              buildTypeContainer, patchConfigContainer,dexConfigContainer);

    }
项目:Reer    文件:DefaultConfigurationPublications.java   
@Override
public NamedDomainObjectContainer<ConfigurationVariant> getVariants() {
    if (variants == null) {
        // Create variants container only as required
        variants = new FactoryNamedDomainObjectContainer<ConfigurationVariant>(ConfigurationVariant.class, instantiator, new NamedDomainObjectFactory<ConfigurationVariant>() {
            @Override
            public ConfigurationVariant create(String name) {
                return instantiator.newInstance(DefaultVariant.class, name, parentAttributes, artifactNotationParser, fileCollectionFactory);
            }
        });
    }
    return variants;
}
项目:Reer    文件:MavenPluginPublishingRules.java   
@Finalize
public void addMarkerPublications(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment) {
    if (!pluginDevelopment.isAutomatedPublishing()) {
        return;
    }

    PublicationContainer publications = publishing.getPublications();
    NamedDomainObjectContainer<PluginDeclaration> declaredPlugins = pluginDevelopment.getPlugins();

    for (PluginDeclaration declaration : declaredPlugins) {
        createMavenMarkerPublication(declaration, (MavenPublication) publications.getByName("pluginMaven"), publications);
    }
}
项目:Reer    文件:IvyPluginPublishingRules.java   
@Finalize
public void addMarkerPublications(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment) {
    if (!pluginDevelopment.isAutomatedPublishing()) {
        return;
    }
    PublicationContainer publications = publishing.getPublications();
    NamedDomainObjectContainer<PluginDeclaration> declaredPlugins = pluginDevelopment.getPlugins();
    for (PluginDeclaration declaration : declaredPlugins) {
        createIvyMarkerPublication(declaration, (IvyPublication) publications.getByName("pluginIvy"), publications);
    }
}
项目:atlas    文件:AtlasConfigHelper.java   
public static void setProperty(Object object,
                               String fieldName,
                               String value)
    throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchFieldException {

    String[] fieldNames = fieldName.split("\\.");

    Object last = object;
    for (int i = 0; i < fieldNames.length - 1; i++) {

        String field = fieldNames[i];

        if (last instanceof NamedDomainObjectContainer) {
            last = ((NamedDomainObjectContainer)last).maybeCreate(field);
        } else {
            Field declaredField = last.getClass().getField(field);
            declaredField.setAccessible(true);

            if (null == declaredField.get(last)) {
                Object newInstance = declaredField.getType()
                    .getConstructors()
                    .getClass()
                    .newInstance();
                declaredField.set(last, newInstance);
            }

            last = declaredField.get(last);
        }
    }

    BeanUtils.setProperty(last, fieldNames[fieldNames.length - 1], value);
}
项目:android-gradle-plugins    文件:SourceSetBasedCodeQualityPlugin.java   
private void configureForSourceSets(NamedDomainObjectContainer<AndroidSourceSet> sourceSets) {
    sourceSets.all(sourceSet -> {
        Task task = project.getTasks().create(getTaskName(sourceSet, getTaskBaseName(), null), getCastedTaskType());
        task.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
        configureForSourceSet(sourceSet, (T)task);
    });
}
项目:aws-sam-gradle    文件:AwsSamDeployPlugin.java   
private SamConfig createConfigDsl() {
    log.debug("Setup serverless config DSL");
    final NamedDomainObjectContainer<Stage> stages = project.container(Stage.class);
    final SamConfigDsl samConfig = project.getExtensions().create("serverless", SamConfigDsl.class, project,
            stages);
    ((ExtensionAware) samConfig).getExtensions().add("stages", stages);
    return new SamConfig(project, samConfig);
}
项目:intellij-ce-playground    文件:TestedExtension.java   
public TestedExtension(@NonNull ProjectInternal project, @NonNull Instantiator instantiator,
        @NonNull AndroidBuilder androidBuilder, @NonNull SdkHandler sdkHandler,
        @NonNull NamedDomainObjectContainer<BuildType> buildTypes,
        @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors,
        @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs,
        @NonNull ExtraModelInfo extraModelInfo, boolean isLibrary) {
    super(project, instantiator, androidBuilder, sdkHandler, buildTypes, productFlavors,
            signingConfigs, extraModelInfo, isLibrary);

    getSourceSetsContainer().create(ANDROID_TEST.getPrefix());
    getSourceSetsContainer().create(UNIT_TEST.getPrefix());
}
项目:intellij-ce-playground    文件:TestExtension.java   
public TestExtension(@NonNull ProjectInternal project, @NonNull Instantiator instantiator,
        @NonNull AndroidBuilder androidBuilder, @NonNull SdkHandler sdkHandler,
        @NonNull NamedDomainObjectContainer<BuildType> buildTypes,
        @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors,
        @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs,
        @NonNull ExtraModelInfo extraModelInfo, boolean isLibrary) {
    super(project, instantiator, androidBuilder, sdkHandler, buildTypes, productFlavors,
            signingConfigs, extraModelInfo, isLibrary);
}
项目:intellij-ce-playground    文件:AppExtension.java   
public AppExtension(@NonNull ProjectInternal project, @NonNull Instantiator instantiator,
        @NonNull AndroidBuilder androidBuilder, @NonNull SdkHandler sdkHandler,
        @NonNull NamedDomainObjectContainer<BuildType> buildTypes,
        @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors,
        @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs,
        @NonNull ExtraModelInfo extraModelInfo, boolean isLibrary) {
    super(project, instantiator, androidBuilder, sdkHandler, buildTypes, productFlavors,
            signingConfigs, extraModelInfo, isLibrary);
}
项目:intellij-ce-playground    文件:LibraryExtension.java   
public LibraryExtension(@NonNull ProjectInternal project, @NonNull Instantiator instantiator,
        @NonNull AndroidBuilder androidBuilder, @NonNull SdkHandler sdkHandler,
        @NonNull NamedDomainObjectContainer<BuildType> buildTypes,
        @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors,
        @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs,
        @NonNull ExtraModelInfo extraModelInfo, boolean isLibrary) {
    super(project, instantiator, androidBuilder, sdkHandler, buildTypes, productFlavors,
            signingConfigs, extraModelInfo, isLibrary);
}
项目:intellij-ce-playground    文件:TestVariantFactory.java   
@Override
public void createDefaultComponents(
        @NonNull NamedDomainObjectContainer<BuildType> buildTypes,
        @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors,
        @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs) {
    // don't call super as we don't want the default app version.
    // must create signing config first so that build type 'debug' can be initialized
    // with the debug signing config.
    signingConfigs.create(BuilderConstants.DEBUG);
    buildTypes.create(BuilderConstants.DEBUG);
}
项目:intellij-ce-playground    文件:LibraryVariantFactory.java   
@Override
public void createDefaultComponents(
        @NonNull NamedDomainObjectContainer<BuildType> buildTypes,
        @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors,
        @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs) {
    // must create signing config first so that build type 'debug' can be initialized
    // with the debug signing config.
    signingConfigs.create(DEBUG);
    buildTypes.create(DEBUG);
    buildTypes.create(RELEASE);
}
项目:intellij-ce-playground    文件:AndroidConfigAdaptor.java   
public AndroidConfigAdaptor(
        AndroidConfig model,
        NamedDomainObjectContainer<AndroidSourceSet> sourceSetsContainer) {
    this.model = model;
    this.sourceSetsContainer = sourceSetsContainer;
    applyProjectSourceSet();
}
项目:gradle-beanstalk-plugin    文件:BeanstalkPlugin.java   
public void apply(final Project project) {
    NamedDomainObjectContainer<BeanstalkDeployment> deployments = project.container(BeanstalkDeployment.class);
    BeanstalkPluginExtension beanstalk = project.getExtensions().create("beanstalk", BeanstalkPluginExtension.class);

    ((ExtensionAware) beanstalk).getExtensions().add("deployments", deployments);

    project.getTasks().addRule(new DeployRule(deployments, project, beanstalk));
}
项目:Reer    文件:DefaultConfigurationPublications.java   
@Override
public void variants(Action<? super NamedDomainObjectContainer<ConfigurationVariant>> configureAction) {
    configureAction.execute(getVariants());
}
项目:Reer    文件:DefaultNativeComponentExtension.java   
public DefaultNativeComponentExtension(NamedDomainObjectContainer<NativeExecutableSpec> executables, NamedDomainObjectContainer<NativeLibrarySpec> libraries) {
    this.executables = executables;
    this.libraries = libraries;
}
项目:Reer    文件:DefaultNativeComponentExtension.java   
@Override
public NamedDomainObjectContainer<NativeExecutableSpec> getExecutables() {
    return executables;
}
项目:Reer    文件:DefaultNativeComponentExtension.java   
@Override
public void executables(Action<? super NamedDomainObjectContainer<? super NativeExecutableSpec>> action) {
    action.execute(executables);
}
项目:Reer    文件:DefaultNativeComponentExtension.java   
@Override
public NamedDomainObjectContainer<NativeLibrarySpec> getLibraries() {
    return libraries;
}
项目:Reer    文件:DefaultNativeComponentExtension.java   
@Override
public void libraries(Action<? super NamedDomainObjectContainer<? super NativeLibrarySpec>> action) {
    action.execute(libraries);
}
项目:Reer    文件:DefaultProject.java   
public <T> NamedDomainObjectContainer<T> container(Class<T> type) {
    Instantiator instantiator = getServices().get(Instantiator.class);
    return instantiator.newInstance(FactoryNamedDomainObjectContainer.class, type, instantiator, new DynamicPropertyNamer());
}
项目:Reer    文件:DefaultProject.java   
public <T> NamedDomainObjectContainer<T> container(Class<T> type, NamedDomainObjectFactory<T> factory) {
    Instantiator instantiator = getServices().get(Instantiator.class);
    return instantiator.newInstance(FactoryNamedDomainObjectContainer.class, type, instantiator, new DynamicPropertyNamer(), factory);
}
项目:Reer    文件:DefaultProject.java   
public <T> NamedDomainObjectContainer<T> container(Class<T> type, Closure factoryClosure) {
    Instantiator instantiator = getServices().get(Instantiator.class);
    return instantiator.newInstance(FactoryNamedDomainObjectContainer.class, type, instantiator, new DynamicPropertyNamer(), factoryClosure);
}
项目:Reer    文件:DefaultTaskContainer.java   
public <U extends Task> NamedDomainObjectContainer<U> containerWithType(Class<U> type) {
    throw new UnsupportedOperationException();
}
项目:Reer    文件:NamedDomainObjectContainerConfigureDelegate.java   
public NamedDomainObjectContainerConfigureDelegate(Closure configureClosure, NamedDomainObjectContainer container) {
    super(configureClosure, container);
    _container = container;
}
项目:Reer    文件:TypedDomainObjectContainerWrapper.java   
public NamedDomainObjectContainer<U> configure(Closure configureClosure) {
    NamedDomainObjectContainerConfigureDelegate delegate = new NamedDomainObjectContainerConfigureDelegate(configureClosure, this);
    return ConfigureUtil.configureSelf(configureClosure, this, delegate);
}
项目:Reer    文件:AbstractPolymorphicDomainObjectContainer.java   
public <U extends T> NamedDomainObjectContainer<U> containerWithType(Class<U> type) {
    return getInstantiator().newInstance(TypedDomainObjectContainerWrapper.class, type, this, getInstantiator());
}
项目:atlas    文件:AtlasExtension.java   
public void buildTypes(Action<? super NamedDomainObjectContainer<T>> action) {
    action.execute(buildTypes);
}
项目:atlas    文件:AtlasExtension.java   
public void patchConfigs(Action<? super NamedDomainObjectContainer<PatchConfig>> action) {
    action.execute(patchConfigs);
}
项目:atlas    文件:AtlasExtension.java   
public void dexConfigs(Action<? super NamedDomainObjectContainer<DexConfig>>action){
    action.execute(dexConfigs);
}
项目:atlas    文件:AtlasExtension.java   
public void multiDexConfigs(Action<? super NamedDomainObjectContainer<MultiDexConfig>> action) {
    action.execute(multiDexConfigs);
}
项目:atlas    文件:AtlasExtension.java   
public NamedDomainObjectContainer<PatchConfig> getPatchConfigs() {
    return patchConfigs;
}
项目:atlas    文件:AtlasExtension.java   
public NamedDomainObjectContainer<T> getBuildTypes() {
    return buildTypes;
}
项目:atlas    文件:AtlasExtension.java   
public NamedDomainObjectContainer<DexConfig> getDexConfig(){
    return dexConfigs;
}
项目:atlas    文件:AtlasExtension.java   
public NamedDomainObjectContainer<MultiDexConfig> getMultiDexConfigs() {
    return multiDexConfigs;
}
项目:atlas    文件:AtlasExtension.java   
public void setMultiDexConfigs(
    NamedDomainObjectContainer<MultiDexConfig> multiDexConfigs) {
    this.multiDexConfigs = multiDexConfigs;
}
项目:atlas    文件:AtlasConfigHelper.java   
private static void readConfig(Object object,
                               String prefix,
                               List<AtlasConfigField> configFieldList,
                               int groupOrder,
                               String variantName) throws IllegalAccessException {

    if (null == object) {
        return;
    }

    for (Field field : getAllFields(object.getClass())) {

        field.setAccessible(true);

        Config config = field.getAnnotation(Config.class);
        if (null != config) {
            AtlasConfigField configField = new AtlasConfigField();
            configField.name = prefix + "." + field.getName();
            configField.order = config.order();
            configField.desc = config.message();
            Object obj = field.get(object);
            String value = "";
            if (obj != null && !(obj instanceof Map) && !(obj instanceof List)) {
                value = String.valueOf(obj);
            }
            configField.value = value;
            configField.groupOrder = groupOrder;
            configField.variantName = variantName;
            configField.type = field.getType().getSimpleName();
            configField.advanced = config.advance();
            configField.group = config.group();

            String variant = StringUtils.isEmpty(variantName) ? "" : ("[" + variantName + "]");
            String title = StringUtils.isEmpty(config.title()) ? config.message() : config.title();
            configField.title = variant + title;

            configFieldList.add(configField);

            continue;
        }

        ConfigGroup configGroup = field.getAnnotation(ConfigGroup.class);
        if (null != configGroup) {

            Object nestedValue = field.get(object);

            if (nestedValue instanceof NamedDomainObjectContainer) {

                readConfig(((NamedDomainObjectContainer)nestedValue).maybeCreate("debug"),
                           prefix + "." + field.getName() + ".debug",
                           configFieldList,
                           configGroup.order(),
                           "debug");
                readConfig(((NamedDomainObjectContainer)nestedValue).maybeCreate("release"),
                           prefix + "." + field.getName() + ".release",
                           configFieldList,
                           configGroup.order(),
                           "release");
            } else {

                readConfig(nestedValue,
                           prefix + "." + field.getName(),
                           configFieldList,
                           configGroup.order(),
                           "");
            }
        }
    }
}
项目:curiostack    文件:GrpcApiPluginTest.java   
@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")));
}