org.gradle.language.base.LanguageSourceSet Java Examples
The following examples show how to use
org.gradle.language.base.LanguageSourceSet.
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: AbstractNativeBinarySpec.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
protected AbstractNativeBinarySpec(NativeComponentSpec owner, Flavor flavor, NativeToolChain toolChain, PlatformToolProvider toolProvider, NativePlatform targetPlatform, BuildType buildType, BinaryNamingScheme namingScheme, NativeDependencyResolver resolver) { this.component = owner; this.toolProvider = toolProvider; this.namingScheme = namingScheme; this.flavor = flavor; this.toolChain = toolChain; this.targetPlatform = targetPlatform; this.buildType = buildType; this.buildable = true; this.resolver = resolver; component.getSource().all(new Action<LanguageSourceSet>() { public void execute(LanguageSourceSet sourceSet) { sourceSets.add(sourceSet); } }); }
Example #2
Source File: AbstractProjectNativeBinary.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
protected AbstractProjectNativeBinary(ProjectNativeComponent owner, Flavor flavor, ToolChainInternal toolChain, Platform targetPlatform, BuildType buildType, BinaryNamingScheme namingScheme, NativeDependencyResolver resolver) { this.component = owner; this.namingScheme = namingScheme; this.flavor = flavor; this.toolChain = toolChain; this.targetPlatform = targetPlatform; this.buildType = buildType; this.buildable = true; this.resolver = resolver; owner.getSource().all(new Action<LanguageSourceSet>() { public void execute(LanguageSourceSet sourceSet) { source.add(sourceSet); } }); }
Example #3
Source File: ApplySourceSetConventions.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void execute(ProjectInternal project) { ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class); for (FunctionalSourceSet functionalSourceSet : projectSourceSet) { for (LanguageSourceSet languageSourceSet : functionalSourceSet) { // Only apply default locations when none explicitly configured if (languageSourceSet.getSource().getSrcDirs().isEmpty()) { languageSourceSet.getSource().srcDir(String.format("src/%s/%s", functionalSourceSet.getName(), languageSourceSet.getName())); } } for (HeaderExportingSourceSet headerSourceSet : functionalSourceSet.withType(HeaderExportingSourceSet.class)) { // Only apply default locations when none explicitly configured if (headerSourceSet.getExportedHeaders().getSrcDirs().isEmpty()) { headerSourceSet.getExportedHeaders().srcDir(String.format("src/%s/headers", functionalSourceSet.getName())); } headerSourceSet.getImplicitHeaders().setSrcDirs(headerSourceSet.getSource().getSrcDirs()); headerSourceSet.getImplicitHeaders().include("**/*.h"); } } }
Example #4
Source File: CreateSourceTransformTask.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void createCompileTasksForBinary(final TaskContainer tasks, BinarySpec binarySpec) { final BinarySpecInternal binary = (BinarySpecInternal) binarySpec; if (binary.isLegacyBinary() || !language.applyToBinary(binary)) { return; } final SourceTransformTaskConfig taskConfig = language.getTransformTask(); binary.getSource().withType(language.getSourceSetType(), new Action<LanguageSourceSet>() { public void execute(LanguageSourceSet languageSourceSet) { LanguageSourceSetInternal sourceSet = (LanguageSourceSetInternal) languageSourceSet; if (sourceSet.getMayHaveSources()) { String taskName = binary.getNamingScheme().getTaskName(taskConfig.getTaskPrefix(), sourceSet.getFullName()); Task task = tasks.create(taskName, taskConfig.getTaskType()); taskConfig.configureTask(task, binary, sourceSet); task.dependsOn(sourceSet); binary.getTasks().add(task); } } }); }
Example #5
Source File: JvmResourcesPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public SourceTransformTaskConfig getTransformTask() { return new SourceTransformTaskConfig() { public String getTaskPrefix() { return "process"; } public Class<? extends DefaultTask> getTaskType() { return ProcessResources.class; } public void configureTask(Task task, BinarySpec binary, LanguageSourceSet sourceSet) { ProcessResources resourcesTask = (ProcessResources) task; JvmResourceSet resourceSet = (JvmResourceSet) sourceSet; JvmBinarySpec jvmBinary = (JvmBinarySpec) binary; resourcesTask.from(resourceSet.getSource()); resourcesTask.setDestinationDir(jvmBinary.getResourcesDir()); jvmBinary.getTasks().getJar().dependsOn(resourcesTask); } }; }
Example #6
Source File: CreateCUnitBinaries.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void apply(final CUnitTestSuite cUnitTestSuite, final BinaryContainer binaries) { cUnitTestSuite.getTestedComponent().getBinaries().withType(ProjectNativeBinaryInternal.class).all(new Action<ProjectNativeBinaryInternal>() { public void execute(ProjectNativeBinaryInternal testedBinary) { final ProjectNativeBinary cunitExe = createTestBinary(cUnitTestSuite, testedBinary, project); ((ExtensionAware) cunitExe).getExtensions().create("cCompiler", DefaultPreprocessingTool.class); cUnitTestSuite.getBinaries().add(cunitExe); binaries.add(cunitExe); testedBinary.getSource().all(new Action<LanguageSourceSet>() { public void execute(LanguageSourceSet languageSourceSet) { cunitExe.source(languageSourceSet); } }); } }); }
Example #7
Source File: AndroidConfigAdaptor.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Convert a FunctionalSourceSet to an AndroidSourceFile. */ private static void convertSourceFile( AndroidSourceFile androidFile, FunctionalSourceSet source, String sourceName) { LanguageSourceSet languageSourceSet = source.get(sourceName); if (languageSourceSet == null) { return; } SourceDirectorySet dir = languageSourceSet.getSource(); if (dir == null) { return; } // We use the first file in the file tree until Gradle has a way to specify one source file // instead of an entire source set. Set<File> files = dir.getAsFileTree().getFiles(); if (!files.isEmpty()) { androidFile.srcFile(Iterables.getOnlyElement(files)); } }
Example #8
Source File: AndroidComponentModelSourceSet.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Set the default directory for each source sets if it is empty. */ public void setDefaultSrcDir() { all(new Action<FunctionalSourceSet>() { @Override public void execute(final FunctionalSourceSet functionalSourceSet) { functionalSourceSet.all( new Action<LanguageSourceSet>() { @Override public void execute(LanguageSourceSet languageSourceSet) { SourceDirectorySet source = languageSourceSet.getSource(); if (source.getSrcDirs().isEmpty()) { source.srcDir("src/" + functionalSourceSet.getName() + "/" + languageSourceSet.getName()); } } }); } }); }
Example #9
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 #10
Source File: SourceSetNotationParser.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static NotationParser<Object, Set<LanguageSourceSet>> parser() { return NotationParserBuilder .toType(new TypeInfo<Set<LanguageSourceSet>>(Set.class)) .parser(new FunctionalSourceSetConverter()) .parser(new SingleLanguageSourceSetConverter()) .parser(new LanguageSourceSetCollectionConverter()) .toComposite(); }
Example #11
Source File: BaseLanguageSourceSet.java From javaide with GNU General Public License v3.0 | 5 votes |
public static <T extends LanguageSourceSet> T create(Class<? extends LanguageSourceSet> publicType, Class<T> implementationType, ComponentSpecIdentifier componentId, SourceDirectorySetFactory sourceDirectorySetFactory) { NEXT_SOURCE_SET_INFO.set(new SourceSetInfo(componentId, publicType, sourceDirectorySetFactory)); try { try { return DirectInstantiator.INSTANCE.newInstance(implementationType); } catch (ObjectInstantiationException e) { throw new ModelInstantiationException(String.format("Could not create LanguageSourceSet of type %s", publicType.getSimpleName()), e.getCause()); } } finally { NEXT_SOURCE_SET_INFO.set(null); } }
Example #12
Source File: ProjectSharedLibraryBinary.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private boolean hasExportedSymbols() { // TODO:DAZ This is a very rough approximation: actually inspect the binary to determine if there are exported symbols for (LanguageSourceSet languageSourceSet : getSource()) { if (!(languageSourceSet instanceof WindowsResourceSet)) { if (!languageSourceSet.getSource().isEmpty()) { return true; } } } return false; }
Example #13
Source File: AbstractProjectLibraryBinary.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
protected boolean hasSources() { for (LanguageSourceSet sourceSet : getSource()) { if (!sourceSet.getSource().isEmpty()) { return true; } if (sourceSet.hasBuildDependencies()) { return true; } } return false; }
Example #14
Source File: DefaultSharedLibraryBinarySpec.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private boolean hasExportedSymbols() { for (LanguageSourceSet languageSourceSet : getSource()) { if (!(languageSourceSet instanceof NativeResourceSet)) { if (!languageSourceSet.getSource().isEmpty()) { return true; } } } return false; }
Example #15
Source File: SourceSetNotationParser.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public static NotationParser<Object, Set<LanguageSourceSet>> parser() { return NotationParserBuilder .toType(new TypeInfo<Set<LanguageSourceSet>>(Set.class)) .parser(new FunctionalSourceSetConverter()) .parser(new SingleLanguageSourceSetConverter()) .parser(new LanguageSourceSetCollectionConverter()) .toComposite(); }
Example #16
Source File: LanguageSourceSetContainer.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * Temporarily, we need to have a 'live' connection between a component's 'main' FunctionalSourceSet and the set of LanguageSourceSets for the component. * We should be able to do away with this, once sourceSets are part of the model proper. */ public void addMainSources(FunctionalSourceSet mainSources) { mainSources.all(new Action<LanguageSourceSet>() { public void execute(LanguageSourceSet languageSourceSet) { add(languageSourceSet); } }); }
Example #17
Source File: LanguageSourceSetContainer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
/** * Temporarily, we need to have a 'live' connection between a component's 'main' FunctionalSourceSet and the set of LanguageSourceSets for the component. * We should be able to do away with this, once sourceSets are part of the model proper. */ public void addMainSources(FunctionalSourceSet mainSources) { mainSources.all(new Action<LanguageSourceSet>() { public void execute(LanguageSourceSet languageSourceSet) { add(languageSourceSet); } }); }
Example #18
Source File: SourceSetRenderer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void render(LanguageSourceSet sourceSet, TextReportBuilder builder) { StyledTextOutput textOutput = builder.getOutput(); textOutput.println(StringUtils.capitalize(sourceSet.getDisplayName())); Set<File> srcDirs = sourceSet.getSource().getSrcDirs(); if (srcDirs.isEmpty()) { textOutput.println(" No source directories"); } else { for (File file : srcDirs) { textOutput.formatln(" %s", fileResolver.resolveAsRelativePath(file)); } } }
Example #19
Source File: SourceSetNativeDependencyResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolve(NativeBinaryResolveResult nativeBinaryResolveResult) { for (NativeBinaryRequirementResolveResult resolution : nativeBinaryResolveResult.getPendingResolutions()) { if (resolution.getInput() instanceof LanguageSourceSet) { LanguageSourceSet input = (LanguageSourceSet) resolution.getInput(); resolution.setNativeDependencySet(createNativeDependencySet(input)); } } delegate.resolve(nativeBinaryResolveResult); }
Example #20
Source File: ComponentModelBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private <U extends LanguageSourceSet> void registerLanguageSourceSetFactory(final LanguageRegistration<U> languageRegistration, ProjectSourceSet sources, final FileResolver fileResolver) { sources.all(new Action<FunctionalSourceSet>() { public void execute(final FunctionalSourceSet functionalSourceSet) { NamedDomainObjectFactory<U> namedDomainObjectFactory = new NamedDomainObjectFactory<U>() { public U create(String name) { Class<? extends U> sourceSetImplementation = languageRegistration.getSourceSetImplementation(); return instantiator.newInstance(sourceSetImplementation, name, functionalSourceSet, fileResolver); } }; functionalSourceSet.registerFactory(languageRegistration.getSourceSetType(), namedDomainObjectFactory); } }); }
Example #21
Source File: ComponentModelBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Finalize // Needs to run after NativeComponentModelPlugin.Rules.configureGeneratedSourceSets() void applyDefaultSourceConventions(ProjectSourceSet sources) { for (FunctionalSourceSet functionalSourceSet : sources) { for (LanguageSourceSet languageSourceSet : functionalSourceSet) { // Only apply default locations when none explicitly configured if (languageSourceSet.getSource().getSrcDirs().isEmpty()) { languageSourceSet.getSource().srcDir(String.format("src/%s/%s", functionalSourceSet.getName(), languageSourceSet.getName())); } } } }
Example #22
Source File: ComponentModelBasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private <U extends LanguageSourceSet> void createDefaultSourceSetForComponents(final LanguageRegistration<U> languageRegistration, ComponentSpecContainer components) { components.withType(ComponentSpecInternal.class).all(new Action<ComponentSpecInternal>() { public void execute(final ComponentSpecInternal componentSpecInternal) { final FunctionalSourceSet functionalSourceSet = componentSpecInternal.getMainSource(); if (componentSpecInternal.getInputTypes().contains(languageRegistration.getOutputType())) { functionalSourceSet.maybeCreate(languageRegistration.getName(), languageRegistration.getSourceSetType()); } } }); }
Example #23
Source File: DefaultSharedLibraryBinarySpec.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private boolean hasExportedSymbols() { for (LanguageSourceSet languageSourceSet : getSource()) { if (!(languageSourceSet instanceof NativeResourceSet)) { if (!languageSourceSet.getSource().isEmpty()) { return true; } } } return false; }
Example #24
Source File: JavaLanguagePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public SourceTransformTaskConfig getTransformTask() { return new SourceTransformTaskConfig() { public String getTaskPrefix() { return "compile"; } public Class<? extends DefaultTask> getTaskType() { return PlatformJavaCompile.class; } public void configureTask(Task task, BinarySpec binarySpec, LanguageSourceSet sourceSet) { PlatformJavaCompile compile = (PlatformJavaCompile) task; JavaSourceSet javaSourceSet = (JavaSourceSet) sourceSet; JvmBinarySpec binary = (JvmBinarySpec) binarySpec; compile.setDescription(String.format("Compiles %s.", javaSourceSet)); compile.setDestinationDir(binary.getClassesDir()); compile.setToolChain(binary.getToolChain()); compile.setPlatform(binary.getTargetPlatform()); compile.setSource(javaSourceSet.getSource()); compile.setClasspath(javaSourceSet.getCompileClasspath().getFiles()); compile.setTargetCompatibility(binary.getTargetPlatform().getTargetCompatibility().toString()); compile.setSourceCompatibility(binary.getTargetPlatform().getTargetCompatibility().toString()); compile.setDependencyCacheDir(new File(compile.getProject().getBuildDir(), "jvm-dep-cache")); compile.dependsOn(javaSourceSet); binary.getTasks().getJar().dependsOn(compile); } }; }
Example #25
Source File: SourceSetRenderer.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void render(LanguageSourceSet sourceSet, TextReportBuilder builder) { StyledTextOutput textOutput = builder.getOutput(); textOutput.println(StringUtils.capitalize(sourceSet.getDisplayName())); Set<File> srcDirs = sourceSet.getSource().getSrcDirs(); if (srcDirs.isEmpty()) { textOutput.println(" No source directories"); } else { for (File file : srcDirs) { textOutput.formatln(" %s", fileResolver.resolveAsRelativePath(file)); } } }
Example #26
Source File: AndroidComponentModelSourceSet.java From javaide with GNU General Public License v3.0 | 5 votes |
public void addDefaultSourceSet(final String sourceSetName, final Class<? extends LanguageSourceSet> type) { all(new Action<FunctionalSourceSet>() { @Override public void execute(FunctionalSourceSet functionalSourceSet) { functionalSourceSet.maybeCreate(sourceSetName, type); } }); }
Example #27
Source File: AndroidComponentModelSourceSet.java From javaide with GNU General Public License v3.0 | 5 votes |
public <T extends LanguageSourceSet> void registerLanguage(final LanguageRegistration<T> languageRegistration) { // Hardcoding registered language sets and default source sets for now. all(new Action<FunctionalSourceSet>() { @Override public void execute(final FunctionalSourceSet functionalSourceSet) { functionalSourceSet.registerFactory( languageRegistration.getSourceSetType(), languageRegistration.getSourceSetFactory(functionalSourceSet.getName())); } }); }
Example #28
Source File: ComponentModelBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private <U extends LanguageSourceSet> void createDefaultSourceSetForComponents(final LanguageRegistration<U> languageRegistration, ComponentSpecContainer components) { components.withType(ComponentSpecInternal.class).all(new Action<ComponentSpecInternal>() { public void execute(final ComponentSpecInternal componentSpecInternal) { final FunctionalSourceSet functionalSourceSet = componentSpecInternal.getMainSource(); if (componentSpecInternal.getInputTypes().contains(languageRegistration.getOutputType())) { functionalSourceSet.maybeCreate(languageRegistration.getName(), languageRegistration.getSourceSetType()); } } }); }
Example #29
Source File: AssembleTaskConfig.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void configureTask(Task task, BinarySpec binary, LanguageSourceSet sourceSet) { configureAssembleTask((Assemble) task, (NativeBinarySpecInternal) binary, (LanguageSourceSetInternal) sourceSet); }
Example #30
Source File: SourceSetNotationParser.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
private SingleLanguageSourceSetConverter() { super(LanguageSourceSet.class); }