Java Code Examples for org.gradle.api.NamedDomainObjectContainer

The following examples show how to use org.gradle.api.NamedDomainObjectContainer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: crate   Source File: JdkTest.java    License: Apache License 2.0 6 votes vote down vote up
private void createJdk(Project project,
                       String name,
                       String vendor,
                       String version,
                       String os,
                       String arch) {
    //noinspection unchecked
    var jdks = (NamedDomainObjectContainer<Jdk>) project.getExtensions().getByName("jdks");
    jdks.create(name, jdk -> {
        if (vendor != null) {
            jdk.setVendor(vendor);
        }
        if (version != null) {
            jdk.setVersion(version);
        }
        if (os != null) {
            jdk.setOs(os);
        }
        if (arch != null) {
            jdk.setArch(arch);
        }
    }).finalizeValues();
}
 
Example 2
Source Project: atlas   Source File: AtlasExtensionFactory.java    License: Apache License 2.0 6 votes vote down vote up
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);

    }
 
Example 3
Source Project: javaide   Source File: VariantManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static void createCompoundSourceSets(
        @NonNull List<? extends ProductFlavor> productFlavorList,
        GradleVariantConfiguration variantConfig,
        NamedDomainObjectContainer<AndroidSourceSet> sourceSetsContainer) {
    if (!productFlavorList.isEmpty() && !variantConfig.getType().isSingleBuildType()) {
        DefaultAndroidSourceSet variantSourceSet =
                (DefaultAndroidSourceSet) sourceSetsContainer.maybeCreate(
                        computeSourceSetName(
                                variantConfig.getFullName(),
                                variantConfig.getType()));
        variantConfig.setVariantSourceProvider(variantSourceSet);
    }

    if (productFlavorList.size() > 1) {
        DefaultAndroidSourceSet multiFlavorSourceSet =
                (DefaultAndroidSourceSet) sourceSetsContainer.maybeCreate(
                        computeSourceSetName(
                                variantConfig.getFlavorName(),
                                variantConfig.getType()));
        variantConfig.setMultiFlavorSourceProvider(multiFlavorSourceSet);
    }
}
 
Example 4
Source Project: gradle-beanstalk-plugin   Source File: BeanstalkPlugin.java    License: MIT License 6 votes vote down vote up
public void apply(Project project) {
    NamedDomainObjectContainer<BeanstalkDeployment> deployments = project.container(BeanstalkDeployment.class);
    BeanstalkPluginExtension beanstalk = project.getExtensions().create("beanstalk", BeanstalkPluginExtension.class);
    ((ExtensionAware) beanstalk).getExtensions().add("deployments", deployments);

    project.afterEvaluate(p -> {
        for (BeanstalkDeployment deployment : deployments) {
            String name = deployment.getName();
            String task = "deploy" + Character.toUpperCase(name.charAt(0)) + name.substring(1);

            p.getTasks().create(task, DeployTask.class, deployTask -> {
                deployTask.setBeanstalk(beanstalk);
                deployTask.setDeployment(deployment);
            });
        }
    });
}
 
Example 5
Source Project: atlas   Source File: AtlasConfigHelper.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 6
Source Project: javaide   Source File: AppExtension.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 7
@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);
}
 
Example 8
@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);
}
 
Example 9
Source Project: crate   Source File: JdkDownloadPlugin.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    NamedDomainObjectContainer<Jdk> jdksContainer = project.container(
        Jdk.class,
        name -> new Jdk(name, project.getConfigurations().create("jdk_" + name), project.getObjects())
    );
    project.getExtensions().add(EXTENSION_NAME, jdksContainer);

    project.afterEvaluate(p ->
        jdksContainer.all(jdk -> {
            jdk.finalizeValues();
            // depend on the jdk directory "artifact" from the root project
            var dependencies = project.getDependencies();
            Map<String, Object> depConfig = Map.of(
                "path", ":",
                "configuration", configName(
                    "extract",
                    jdk.vendor(),
                    jdk.version(),
                    jdk.platform()));
            dependencies.add(
                jdk.configuration().getName(),
                dependencies.project(depConfig));

            setupRootJdkDownload(project.getRootProject(), jdk);
        })
    );
}
 
Example 10
Source Project: javaide   Source File: AndroidConfigAdaptor.java    License: GNU General Public License v3.0 5 votes vote down vote up
public AndroidConfigAdaptor(
        AndroidConfig model,
        NamedDomainObjectContainer<AndroidSourceSet> sourceSetsContainer) {
    this.model = model;
    this.sourceSetsContainer = sourceSetsContainer;
    applyProjectSourceSet();
}
 
Example 11
Source Project: curiostack   Source File: DownloadedToolManager.java    License: MIT License 5 votes vote down vote up
@Inject
public DownloadedToolManager(
    Project project, NamedDomainObjectContainer<ToolDownloaderExtension> tools) {
  this.tools = tools;

  curiostackDir = project.getGradle().getGradleUserHomeDir().toPath().resolve("curiostack");
}
 
Example 12
public NamedDomainObjectContainerConfigureDelegate(Object owner, NamedDomainObjectContainer container) {
    super(owner, container);
    _container = container;
}
 
Example 13
public NamedDomainObjectContainer<JvmLibrarySpec> getLibraries() {
    return libraries;
}
 
Example 14
public void libraries(Action<? super NamedDomainObjectContainer<? super JvmLibrarySpec>> action) {
    action.execute(libraries);
}
 
Example 15
public NamedDomainObjectContainerConfigureDelegate(Object owner, NamedDomainObjectContainer container) {
    super(owner, container);
    _container = container;
}
 
Example 16
public DefaultNativeComponentExtension(NamedDomainObjectContainer<NativeExecutableSpec> executables, NamedDomainObjectContainer<NativeLibrarySpec> libraries) {
    this.executables = executables;
    this.libraries = libraries;
}
 
Example 17
public NamedDomainObjectContainer<NativeLibrarySpec> getLibraries() {
    return libraries;
}
 
Example 18
public void executables(Action<? super NamedDomainObjectContainer<? super NativeExecutableSpec>> action) {
    action.execute(executables);
}
 
Example 19
public NamedDomainObjectContainer<NativeLibrarySpec> getLibraries() {
    return libraries;
}
 
Example 20
public void libraries(Action<? super NamedDomainObjectContainer<? super NativeLibrarySpec>> action) {
    action.execute(libraries);
}
 
Example 21
public NamedDomainObjectContainerConfigureDelegate(Object owner, NamedDomainObjectContainer container) {
    super(owner, container);
    _container = container;
}
 
Example 22
public NamedDomainObjectContainerConfigureDelegate(Object owner, NamedDomainObjectContainer container) {
    super(owner, container);
    _container = container;
}
 
Example 23
public void libraries(Action<? super NamedDomainObjectContainer<? super NativeLibrarySpec>> action) {
    action.execute(libraries);
}
 
Example 24
Source Project: atlas   Source File: AtlasExtension.java    License: Apache License 2.0 4 votes vote down vote up
public void buildTypes(Action<? super NamedDomainObjectContainer<T>> action) {
    action.execute(buildTypes);
}
 
Example 25
Source Project: atlas   Source File: AtlasExtension.java    License: Apache License 2.0 4 votes vote down vote up
public void patchConfigs(Action<? super NamedDomainObjectContainer<PatchConfig>> action) {
    action.execute(patchConfigs);
}
 
Example 26
Source Project: atlas   Source File: AtlasExtension.java    License: Apache License 2.0 4 votes vote down vote up
public void dexConfigs(Action<? super NamedDomainObjectContainer<DexConfig>> action) {
    action.execute(dexConfigs);
}
 
Example 27
Source Project: atlas   Source File: AtlasExtension.java    License: Apache License 2.0 4 votes vote down vote up
public void multiDexConfigs(Action<? super NamedDomainObjectContainer<MultiDexConfig>> action) {
    action.execute(multiDexConfigs);
}
 
Example 28
Source Project: atlas   Source File: AtlasExtension.java    License: Apache License 2.0 4 votes vote down vote up
public void enhanceConfigs(Action<? super NamedDomainObjectContainer<EnhanceConfig>> action) {
    action.execute(enhanceConfigs);
}
 
Example 29
Source Project: atlas   Source File: AtlasExtension.java    License: Apache License 2.0 4 votes vote down vote up
public void setEnhanceConfigs(NamedDomainObjectContainer<EnhanceConfig> enhanceConfigs) {
    this.enhanceConfigs = enhanceConfigs;
}
 
Example 30
Source Project: atlas   Source File: AtlasExtension.java    License: Apache License 2.0 4 votes vote down vote up
public NamedDomainObjectContainer<PatchConfig> getPatchConfigs() {
    return patchConfigs;
}