org.gradle.model.Path Java Examples
The following examples show how to use
org.gradle.model.Path.
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: JvmComponentPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
@Mutate public void createBinaries(BinaryContainer binaries, PlatformContainer platforms, BinaryNamingSchemeBuilder namingSchemeBuilder, NamedDomainObjectCollection<JvmLibrarySpec> libraries, @Path("buildDir") File buildDir, ServiceRegistry serviceRegistry, JavaToolChainRegistry toolChains) { Instantiator instantiator = serviceRegistry.get(Instantiator.class); List<Action<? super JarBinarySpec>> actions = Lists.newArrayList(); actions.add(new JarBinarySpecInitializer(buildDir)); actions.add(new MarkBinariesBuildable()); Action<JarBinarySpec> initAction = Actions.composite(actions); JarBinariesFactory factory = new DefaultJarBinariesFactory(instantiator, initAction); Action<JvmLibrarySpec> createBinariesAction = new JvmLibrarySpecInitializer(factory, namingSchemeBuilder, toolChains, platforms); for (JvmLibrarySpec jvmLibrary : libraries) { createBinariesAction.execute(jvmLibrary); binaries.addAll(jvmLibrary.getBinaries()); } }
Example #2
Source File: JvmComponentPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
@Mutate public void createBinaries(BinaryContainer binaries, PlatformContainer platforms, BinaryNamingSchemeBuilder namingSchemeBuilder, NamedDomainObjectCollection<JvmLibrarySpec> libraries, @Path("buildDir") File buildDir, ServiceRegistry serviceRegistry, JavaToolChainRegistry toolChains) { Instantiator instantiator = serviceRegistry.get(Instantiator.class); List<Action<? super JarBinarySpec>> actions = Lists.newArrayList(); actions.add(new JarBinarySpecInitializer(buildDir)); actions.add(new MarkBinariesBuildable()); Action<JarBinarySpec> initAction = Actions.composite(actions); JarBinariesFactory factory = new DefaultJarBinariesFactory(instantiator, initAction); Action<JvmLibrarySpec> createBinariesAction = new JvmLibrarySpecInitializer(factory, namingSchemeBuilder, toolChains, platforms); for (JvmLibrarySpec jvmLibrary : libraries) { createBinariesAction.execute(jvmLibrary); binaries.addAll(jvmLibrary.getBinaries()); } }
Example #3
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 6 votes |
public void addDefaultAndroidSourceSet( @Path("android.sources") AndroidComponentModelSourceSet sources) { sources.addDefaultSourceSet("resources", AndroidLanguageSourceSet.class); sources.addDefaultSourceSet("java", AndroidLanguageSourceSet.class); sources.addDefaultSourceSet("manifest", AndroidLanguageSourceSet.class); sources.addDefaultSourceSet("res", AndroidLanguageSourceSet.class); sources.addDefaultSourceSet("assets", AndroidLanguageSourceSet.class); sources.addDefaultSourceSet("aidl", AndroidLanguageSourceSet.class); sources.addDefaultSourceSet("jniLibs", AndroidLanguageSourceSet.class); sources.all(new Action<FunctionalSourceSet>() { @Override public void execute(FunctionalSourceSet functionalSourceSet) { LanguageSourceSet manifest = functionalSourceSet.get("manifest"); manifest.getSource().setIncludes(ImmutableList.of("AndroidManifest.xml")); } }); }
Example #4
Source File: AndroidComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 6 votes |
@ComponentBinaries public void createBinaries( final ModelMap<AndroidBinary> binaries, @Path("android") final AndroidConfig androidConfig, @Path("android.buildTypes") final ModelMap<BuildType> buildTypes, final List<ProductFlavorCombo<ProductFlavor>> flavorCombos, final AndroidComponentSpec spec) { if (flavorCombos.isEmpty()) { flavorCombos.add(new ProductFlavorCombo<ProductFlavor>()); } for (final BuildType buildType : buildTypes.values()) { for (final ProductFlavorCombo<ProductFlavor> flavorCombo : flavorCombos) { binaries.create(getBinaryName(buildType, flavorCombo), new Action<AndroidBinary>() { @Override public void execute(AndroidBinary androidBinary) { DefaultAndroidBinary binary = (DefaultAndroidBinary) androidBinary; binary.setBuildType(buildType); binary.setProductFlavors(flavorCombo.getFlavorList()); } }); } } }
Example #5
Source File: DefaultMethodRuleDefinition.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private ModelReference<?> reference(Type type, Annotation[] annotations, int i) { Path pathAnnotation = (Path) findFirst(annotations, new Spec<Annotation>() { public boolean isSatisfiedBy(Annotation element) { return element.annotationType().equals(Path.class); } }); String path = pathAnnotation == null ? null : pathAnnotation.value(); ModelType<?> cast = ModelType.of(type); return ModelReference.of(path == null ? null : ModelPath.path(path), cast, String.format("parameter %s", i + 1)); }
Example #6
Source File: ReflectiveRule.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private static <T> BindableParameter binding(Class<T> type, Annotation[] annotations) { Path pathAnnotation = (Path) findFirst(annotations, new Spec<Annotation>() { public boolean isSatisfiedBy(Annotation element) { return element.annotationType().equals(Path.class); } }); String path = pathAnnotation == null ? null : pathAnnotation.value(); return new BindableParameter<T>(path == null ? null : ModelPath.path(path), type); }
Example #7
Source File: CUnitPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Mutate public void createCUnitTestBinaries(final BinaryContainer binaries, TestSuiteContainer testSuites, @Path("buildDir") File buildDir, ServiceRegistry serviceRegistry) { for (final CUnitTestSuiteSpec cUnitTestSuite : testSuites.withType(CUnitTestSuiteSpec.class)) { for (NativeBinarySpec testedBinary : cUnitTestSuite.getTestedComponent().getNativeBinaries()) { DefaultCUnitTestSuiteBinary testBinary = createTestBinary(serviceRegistry, cUnitTestSuite, testedBinary); configure(testBinary, buildDir); cUnitTestSuite.getBinaries().add(testBinary); binaries.add(testBinary); } } }
Example #8
Source File: CUnitPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Mutate public void configureCUnitTestSuiteSources(ProjectSourceSet projectSourceSet, TestSuiteContainer testSuites, @Path("buildDir") File buildDir) { for (final CUnitTestSuiteSpec suite : testSuites.withType(CUnitTestSuiteSpec.class)) { FunctionalSourceSet suiteSourceSet = ((ComponentSpecInternal) suite).getMainSource(); CSourceSet launcherSources = suiteSourceSet.maybeCreate(CUNIT_LAUNCHER_SOURCE_SET, CSourceSet.class); File baseDir = new File(buildDir, String.format("src/%s/cunitLauncher", suite.getName())); launcherSources.getSource().srcDir(new File(baseDir, "c")); launcherSources.getExportedHeaders().srcDir(new File(baseDir, "headers")); CSourceSet testSources = suiteSourceSet.maybeCreate("c", CSourceSet.class); testSources.lib(launcherSources); } }
Example #9
Source File: MavenPublishPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Mutate @SuppressWarnings("UnusedDeclaration") public void realizePublishingTasks(CollectionBuilder<Task> tasks, @Path("tasks.publish") Task publishLifecycleTask, @Path("tasks.publishToMavenLocal") Task publishLocalLifecycleTask, PublishingExtension extension) { // Create generatePom tasks for any Maven publication PublicationContainer publications = extension.getPublications(); for (final MavenPublicationInternal publication : publications.withType(MavenPublicationInternal.class)) { String publicationName = publication.getName(); createGeneratePomTask(tasks, publication, publicationName); createLocalInstallTask(tasks, publishLocalLifecycleTask, publication, publicationName); createPublishTasksForEachMavenRepo(tasks, extension, publishLifecycleTask, publication, publicationName); } }
Example #10
Source File: DefaultMethodRuleDefinition.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private ModelReference<?> reference(Type type, Annotation[] annotations, int i) { Path pathAnnotation = (Path) findFirst(annotations, new Spec<Annotation>() { public boolean isSatisfiedBy(Annotation element) { return element.annotationType().equals(Path.class); } }); String path = pathAnnotation == null ? null : pathAnnotation.value(); ModelType<?> cast = ModelType.of(type); return ModelReference.of(path == null ? null : ModelPath.path(path), cast, String.format("parameter %s", i + 1)); }
Example #11
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
public void createAndroidComponents( ComponentSpecContainer androidSpecs, ServiceRegistry serviceRegistry, AndroidConfig androidExtension, com.android.build.gradle.AndroidConfig adaptedModel, @Path("android.buildTypes") ModelMap<BuildType> buildTypes, @Path("android.productFlavors") ModelMap<ProductFlavor> productFlavors, @Path("android.signingConfigs") ModelMap<SigningConfig> signingConfigs, VariantFactory variantFactory, TaskManager taskManager, Project project, AndroidBuilder androidBuilder, SdkHandler sdkHandler, ExtraModelInfo extraModelInfo, @Path("isApplication") Boolean isApplication) { Instantiator instantiator = serviceRegistry.get(Instantiator.class); // check if the target has been set. TargetInfo targetInfo = androidBuilder.getTargetInfo(); if (targetInfo == null) { sdkHandler.initTarget(androidExtension.getCompileSdkVersion(), androidExtension.getBuildToolsRevision(), androidExtension.getLibraryRequests(), androidBuilder); } VariantManager variantManager = new VariantManager(project, androidBuilder, adaptedModel, variantFactory, taskManager, instantiator); for (BuildType buildType : buildTypes.values()) { variantManager.addBuildType(new BuildTypeAdaptor(buildType)); } for (ProductFlavor productFlavor : productFlavors.values()) { variantManager.addProductFlavor(new ProductFlavorAdaptor(productFlavor)); } DefaultAndroidComponentSpec spec = (DefaultAndroidComponentSpec) androidSpecs.get(COMPONENT_NAME); spec.setExtension(androidExtension); spec.setVariantManager(variantManager); }
Example #12
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
@Model(ANDROID_CONFIG_ADAPTOR) public com.android.build.gradle.AndroidConfig createModelAdaptor( ServiceRegistry serviceRegistry, AndroidConfig androidExtension, Project project, @Path("isApplication") Boolean isApplication) { Instantiator instantiator = serviceRegistry.get(Instantiator.class); return new AndroidConfigAdaptor(androidExtension, AndroidConfigHelper .createSourceSetsContainer(project, instantiator, !isApplication)); }
Example #13
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
public void initProductFlavors( @Path("android.productFlavors") final ModelMap<ProductFlavor> productFlavors) { productFlavors.beforeEach(new Action<ProductFlavor>() { @Override public void execute(ProductFlavor productFlavor) { initProductFlavor(productFlavor); } }); }
Example #14
Source File: AndroidComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Create all source sets for each AndroidBinary. */ @Mutate public void createVariantSourceSet( @Path("android.sources") final AndroidComponentModelSourceSet sources, @Path("android.buildTypes") final ModelMap<BuildType> buildTypes, @Path("android.productFlavors") ModelMap<ProductFlavor> flavors, List<ProductFlavorCombo<ProductFlavor>> flavorGroups, ProjectSourceSet projectSourceSet, LanguageRegistry languageRegistry) { sources.setProjectSourceSet(projectSourceSet); for (LanguageRegistration languageRegistration : languageRegistry) { sources.registerLanguage(languageRegistration); } // Create main source set. sources.create("main"); for (BuildType buildType : buildTypes.values()) { sources.maybeCreate(buildType.getName()); for (ProductFlavorCombo group : flavorGroups) { sources.maybeCreate(group.getName()); if (!group.getFlavorList().isEmpty()) { sources.maybeCreate( group.getName() + StringHelper.capitalize(buildType.getName())); } } } if (flavorGroups.size() != flavors.size()) { // If flavorGroups and flavors are the same size, there is at most 1 flavor // dimension. So we don't need to reconfigure the source sets for flavorGroups. for (ProductFlavor flavor : flavors.values()) { sources.maybeCreate(flavor.getName()); } } }
Example #15
Source File: AndroidComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
@Model public List<ProductFlavorCombo<ProductFlavor>> createProductFlavorCombo( @Path("android.productFlavors") ModelMap<ProductFlavor> productFlavors) { // TODO: Create custom product flavor container to manually configure flavor dimensions. Set<String> flavorDimensionList = Sets.newHashSet(); for (ProductFlavor flavor : productFlavors.values()) { if (flavor.getDimension() != null) { flavorDimensionList.add(flavor.getDimension()); } } return ProductFlavorCombo.createCombinations( Lists.newArrayList(flavorDimensionList), productFlavors.values()); }
Example #16
Source File: AndroidComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
@Defaults public void createDefaultBuildTypes( @Path("android.buildTypes") ModelMap<BuildType> buildTypes) { buildTypes.create(BuilderConstants.DEBUG, new Action<BuildType>() { @Override public void execute(BuildType buildType) { buildType.setDebuggable(true); } }); buildTypes.create(BuilderConstants.RELEASE); }
Example #17
Source File: ReflectiveRule.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private static <T> BindableParameter binding(Class<T> type, Annotation[] annotations) { Path pathAnnotation = (Path) findFirst(annotations, new Spec<Annotation>() { public boolean isSatisfiedBy(Annotation element) { return element.annotationType().equals(Path.class); } }); String path = pathAnnotation == null ? null : pathAnnotation.value(); return new BindableParameter<T>(path == null ? null : ModelPath.path(path), type); }
Example #18
Source File: CUnitPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Mutate public void createCUnitTestBinaries(final BinaryContainer binaries, TestSuiteContainer testSuites, @Path("buildDir") File buildDir, ServiceRegistry serviceRegistry) { for (final CUnitTestSuiteSpec cUnitTestSuite : testSuites.withType(CUnitTestSuiteSpec.class)) { for (NativeBinarySpec testedBinary : cUnitTestSuite.getTestedComponent().getNativeBinaries()) { DefaultCUnitTestSuiteBinary testBinary = createTestBinary(serviceRegistry, cUnitTestSuite, testedBinary); configure(testBinary, buildDir); cUnitTestSuite.getBinaries().add(testBinary); binaries.add(testBinary); } } }
Example #19
Source File: CUnitPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Mutate public void configureCUnitTestSuiteSources(ProjectSourceSet projectSourceSet, TestSuiteContainer testSuites, @Path("buildDir") File buildDir) { for (final CUnitTestSuiteSpec suite : testSuites.withType(CUnitTestSuiteSpec.class)) { FunctionalSourceSet suiteSourceSet = ((ComponentSpecInternal) suite).getMainSource(); CSourceSet launcherSources = suiteSourceSet.maybeCreate(CUNIT_LAUNCHER_SOURCE_SET, CSourceSet.class); File baseDir = new File(buildDir, String.format("src/%s/cunitLauncher", suite.getName())); launcherSources.getSource().srcDir(new File(baseDir, "c")); launcherSources.getExportedHeaders().srcDir(new File(baseDir, "headers")); CSourceSet testSources = suiteSourceSet.maybeCreate("c", CSourceSet.class); testSources.lib(launcherSources); } }
Example #20
Source File: MavenPublishPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Mutate @SuppressWarnings("UnusedDeclaration") public void realizePublishingTasks(CollectionBuilder<Task> tasks, @Path("tasks.publish") Task publishLifecycleTask, @Path("tasks.publishToMavenLocal") Task publishLocalLifecycleTask, PublishingExtension extension) { // Create generatePom tasks for any Maven publication PublicationContainer publications = extension.getPublications(); for (final MavenPublicationInternal publication : publications.withType(MavenPublicationInternal.class)) { String publicationName = publication.getName(); createGeneratePomTask(tasks, publication, publicationName); createLocalInstallTask(tasks, publishLocalLifecycleTask, publication, publicationName); createPublishTasksForEachMavenRepo(tasks, extension, publishLifecycleTask, publication, publicationName); } }
Example #21
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 4 votes |
@Model(EXTRA_MODEL_INFO) public ExtraModelInfo createExtraModelInfo( Project project, @NonNull @Path("isApplication") Boolean isApplication) { return new ExtraModelInfo(project, isApplication); }
Example #22
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 4 votes |
public void initDefaultConfig(@Path("android.defaultConfig") ProductFlavor defaultConfig) { initProductFlavor(defaultConfig); }
Example #23
Source File: AndroidComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 4 votes |
@Finalize public void setDefaultSrcDir( @Path("android.sources") AndroidComponentModelSourceSet sourceSet) { sourceSet.setDefaultSrcDir(); }
Example #24
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 4 votes |
public void modifyAssembleTaskDescription(@Path("tasks.assemble") Task assembleTask) { assembleTask.setDescription( "Assembles all variants of all applications and secondary packages."); }
Example #25
Source File: AndroidComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 4 votes |
@Defaults public void androidModelSources(AndroidConfig androidModel, @Path("androidSources") AndroidComponentModelSourceSet sources) { androidModel.setSources(sources); }
Example #26
Source File: IvyPublishPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
@Mutate @SuppressWarnings("UnusedDeclaration") public void createTasks(CollectionBuilder<Task> tasks, final @Path("tasks.publish") Task publishLifecycleTask, PublishingExtension publishingExtension) { PublicationContainer publications = publishingExtension.getPublications(); RepositoryHandler repositories = publishingExtension.getRepositories(); for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) { final String publicationName = publication.getName(); final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName)); tasks.create(descriptorTaskName, GenerateIvyDescriptor.class, new Action<GenerateIvyDescriptor>() { public void execute(final GenerateIvyDescriptor descriptorTask) { descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName())); descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); descriptorTask.setDescriptor(publication.getDescriptor()); ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping(); descriptorTaskConventionMapping.map("destination", new Callable<Object>() { public Object call() throws Exception { return new File(descriptorTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/ivy.xml"); } }); publication.setDescriptorFile(descriptorTask.getOutputs().getFiles()); } }); for (final IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) { final String repositoryName = repository.getName(); final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName)); tasks.create(publishTaskName, PublishToIvyRepository.class, new Action<PublishToIvyRepository>() { public void execute(PublishToIvyRepository publishTask) { publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName)); //Because dynamic rules are not yet implemented we have to violate input immutability here as an interim step publishLifecycleTask.dependsOn(publishTask); } }); } } }
Example #27
Source File: IvyPublishPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
@Mutate @SuppressWarnings("UnusedDeclaration") public void createTasks(CollectionBuilder<Task> tasks, final @Path("tasks.publish") Task publishLifecycleTask, PublishingExtension publishingExtension) { PublicationContainer publications = publishingExtension.getPublications(); RepositoryHandler repositories = publishingExtension.getRepositories(); for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) { final String publicationName = publication.getName(); final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName)); tasks.create(descriptorTaskName, GenerateIvyDescriptor.class, new Action<GenerateIvyDescriptor>() { public void execute(final GenerateIvyDescriptor descriptorTask) { descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName())); descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); descriptorTask.setDescriptor(publication.getDescriptor()); ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping(); descriptorTaskConventionMapping.map("destination", new Callable<Object>() { public Object call() throws Exception { return new File(descriptorTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/ivy.xml"); } }); publication.setDescriptorFile(descriptorTask.getOutputs().getFiles()); } }); for (final IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) { final String repositoryName = repository.getName(); final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName)); tasks.create(publishTaskName, PublishToIvyRepository.class, new Action<PublishToIvyRepository>() { public void execute(PublishToIvyRepository publishTask) { publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName)); //Because dynamic rules are not yet implemented we have to violate input immutability here as an interim step publishLifecycleTask.dependsOn(publishTask); } }); } } }