org.gradle.api.NamedDomainObjectContainer Java Examples
The following examples show how to use
org.gradle.api.NamedDomainObjectContainer.
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 File: JdkTest.java From crate with Apache License 2.0 | 6 votes |
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 File: AtlasExtensionFactory.java From atlas with Apache License 2.0 | 6 votes |
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 File: BeanstalkPlugin.java From gradle-beanstalk-plugin with MIT License | 6 votes |
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 #4
Source File: VariantManager.java From javaide with GNU General Public License v3.0 | 6 votes |
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 #5
Source File: AppExtension.java From javaide with GNU General Public License v3.0 | 5 votes |
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 #6
Source File: DownloadedToolManager.java From curiostack with MIT License | 5 votes |
@Inject public DownloadedToolManager( Project project, NamedDomainObjectContainer<ToolDownloaderExtension> tools) { this.tools = tools; curiostackDir = project.getGradle().getGradleUserHomeDir().toPath().resolve("curiostack"); }
Example #7
Source File: AndroidConfigAdaptor.java From javaide with GNU General Public License v3.0 | 5 votes |
public AndroidConfigAdaptor( AndroidConfig model, NamedDomainObjectContainer<AndroidSourceSet> sourceSetsContainer) { this.model = model; this.sourceSetsContainer = sourceSetsContainer; applyProjectSourceSet(); }
Example #8
Source File: JdkDownloadPlugin.java From crate with Apache License 2.0 | 5 votes |
@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 #9
Source File: ApplicationVariantFactory.java From javaide with GNU General Public License v3.0 | 5 votes |
@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 #10
Source File: AtlasConfigHelper.java From atlas with Apache License 2.0 | 5 votes |
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 #11
Source File: LibraryVariantFactory.java From javaide with GNU General Public License v3.0 | 5 votes |
@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 #12
Source File: ToolDownloaderPlugin.java From curiostack with MIT License | 4 votes |
public NamedDomainObjectContainer<ToolDownloaderExtension> tools() { return tools; }
Example #13
Source File: ProtobufExtension.java From curiostack with MIT License | 4 votes |
default ProtobufExtension sources( Action<? super NamedDomainObjectContainer<SourceDirectorySet>> action) { action.execute(getSources()); return this; }
Example #14
Source File: TerraformSetupExtension.java From curiostack with MIT License | 4 votes |
default TerraformSetupExtension providers( Action<? super NamedDomainObjectContainer<CustomProvider>> action) { action.execute(getProviders()); return this; }
Example #15
Source File: ClojureExtension.java From clojurephant with Apache License 2.0 | 4 votes |
public void builds(Action<? super NamedDomainObjectContainer<? super ClojureBuild>> configureAction) { configureAction.execute(builds); }
Example #16
Source File: SamplesExtension.java From native-samples with Apache License 2.0 | 4 votes |
public NamedDomainObjectContainer<ExternalRepo> getExternalRepos() { return externalRepos; }
Example #17
Source File: SamplesExtension.java From native-samples with Apache License 2.0 | 4 votes |
public NamedDomainObjectContainer<Sample> getSamples() { return samples; }
Example #18
Source File: DefaultJvmComponentExtension.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DefaultJvmComponentExtension(NamedDomainObjectContainer<JvmLibrarySpec> libraries) { this.libraries = libraries; }
Example #19
Source File: DefaultJvmComponentExtension.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public NamedDomainObjectContainer<JvmLibrarySpec> getLibraries() { return libraries; }
Example #20
Source File: DefaultJvmComponentExtension.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void libraries(Action<? super NamedDomainObjectContainer<? super JvmLibrarySpec>> action) { action.execute(libraries); }
Example #21
Source File: DefaultNativeComponentExtension.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DefaultNativeComponentExtension(NamedDomainObjectContainer<NativeExecutableSpec> executables, NamedDomainObjectContainer<NativeLibrarySpec> libraries) { this.executables = executables; this.libraries = libraries; }
Example #22
Source File: ClojureExtension.java From clojurephant with Apache License 2.0 | 4 votes |
public NamedDomainObjectContainer<ClojureBuild> getBuilds() { return builds; }
Example #23
Source File: VariantFactory.java From javaide with GNU General Public License v3.0 | 4 votes |
void createDefaultComponents( @NonNull NamedDomainObjectContainer<BuildType> buildTypes, @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors, @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs);
Example #24
Source File: DefaultNativeComponentExtension.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public NamedDomainObjectContainer<NativeExecutableSpec> getExecutables() { return executables; }
Example #25
Source File: AndroidConfigAdaptor.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public NamedDomainObjectContainer<AndroidSourceSet> getSourceSets() { return sourceSetsContainer; }
Example #26
Source File: BaseExtension.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * All source sets. Note that the Android plugin uses its own implementation of * source sets, {@link AndroidSourceSet}. */ @Override public NamedDomainObjectContainer<AndroidSourceSet> getSourceSets() { return sourceSetsContainer; }
Example #27
Source File: BaseExtension.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Configures the signing configs. */ public void signingConfigs(Action<? super NamedDomainObjectContainer<SigningConfig>> action) { checkWritability(); action.execute(signingConfigs); }
Example #28
Source File: BaseExtension.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Configures the product flavors. */ public void productFlavors(Action<? super NamedDomainObjectContainer<CoreProductFlavor>> action) { checkWritability(); action.execute(productFlavors); }
Example #29
Source File: BaseExtension.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Configures the build types. */ public void buildTypes(Action<? super NamedDomainObjectContainer<BuildType>> action) { checkWritability(); action.execute(buildTypes); }
Example #30
Source File: BaseExtension.java From javaide with GNU General Public License v3.0 | 4 votes |
BaseExtension( @NonNull final 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, final boolean isLibrary) { this.androidBuilder = androidBuilder; this.sdkHandler = sdkHandler; this.buildTypes = buildTypes; //noinspection unchecked this.productFlavors = (NamedDomainObjectContainer) productFlavors; this.signingConfigs = signingConfigs; this.extraModelInfo = extraModelInfo; this.project = project; logger = Logging.getLogger(this.getClass()); defaultConfig = instantiator.newInstance(ProductFlavor.class, BuilderConstants.MAIN, project, instantiator, project.getLogger()); aaptOptions = instantiator.newInstance(AaptOptions.class); dexOptions = instantiator.newInstance(DexOptions.class); lintOptions = instantiator.newInstance(LintOptions.class); compileOptions = instantiator.newInstance(CompileOptions.class); packagingOptions = instantiator.newInstance(PackagingOptions.class); preprocessingOptions = instantiator.newInstance(PreprocessingOptions.class); splits = instantiator.newInstance(Splits.class, instantiator); sourceSetsContainer = project.container(AndroidSourceSet.class, new AndroidSourceSetFactory(instantiator, project, isLibrary)); sourceSetsContainer.whenObjectAdded(new Action<AndroidSourceSet>() { @Override public void execute(AndroidSourceSet sourceSet) { ConfigurationContainer configurations = project.getConfigurations(); createConfiguration( configurations, sourceSet.getCompileConfigurationName(), "Classpath for compiling the " + sourceSet.getName() + " sources."); String packageConfigDescription; if (isLibrary) { packageConfigDescription = "Classpath only used when publishing '" + sourceSet.getName() + "'."; } else { packageConfigDescription = "Classpath packaged with the compiled '" + sourceSet.getName() + "' classes."; } createConfiguration( configurations, sourceSet.getPackageConfigurationName(), packageConfigDescription); createConfiguration( configurations, sourceSet.getProvidedConfigurationName(), "Classpath for only compiling the " + sourceSet.getName() + " sources."); createConfiguration( configurations, sourceSet.getWearAppConfigurationName(), "Link to a wear app to embed for object '" + sourceSet.getName() + "'."); sourceSet.setRoot(String.format("src/%s", sourceSet.getName())); } }); sourceSetsContainer.create(defaultConfig.getName()); }