@Override public void apply(Project project) { final ConfigurationContainer configurations = project.getConfigurations(); configurations.maybeCreate("test"); configurations.maybeCreate("build"); configurations.maybeCreate("tool"); final ExtensionContainer extensions = project.getExtensions(); final ExtensionAware golang = (ExtensionAware) extensions.create("golang", GolangSettings.class, true, project); golang.getExtensions().create("build", BuildSettings.class, true, project); golang.getExtensions().create("toolchain", ToolchainSettings.class, true, project); golang.getExtensions().create("dependencies", DependenciesSettings.class, true, project); golang.getExtensions().create("testing", TestingSettings.class, true, project); extensions.create(INSTANCE_PROPERTY_NAME, Reference.class, this); final TaskContainer tasks = project.getTasks(); addTasks(tasks); }
@Test public void testDefaultConfiguration() throws IOException { Project p = new TestProject(testProjectDir.getRoot()).applyFlexibleWarProjectBuilder(); ExtensionAware ext = (ExtensionAware) p.getExtensions().getByName("appengine"); DeployExtension deployExt = new ExtensionUtil(ext).get("deploy"); StageFlexibleExtension stageExt = new ExtensionUtil(ext).get("stage"); assertEquals(new File(p.getBuildDir(), "staged-app"), stageExt.getStagingDirectory()); assertEquals( testProjectDir.getRoot().toPath().toRealPath().resolve("src/main/appengine"), stageExt.getAppEngineDirectory().toPath()); assertEquals( testProjectDir.getRoot().toPath().toRealPath().resolve("src/main/appengine"), deployExt.getAppEngineDirectory().toPath()); assertEquals((((War) p.getProperties().get("war")).getArchivePath()), stageExt.getArtifact()); assertFalse(new File(testProjectDir.getRoot(), "src/main/docker").exists()); assertEquals( Collections.singletonList(new File(p.getBuildDir(), "staged-app/app.yaml")), deployExt.getDeployables()); }
@Test public void testFileAsString() throws IOException { Project p = setUpTestProject("file-as-string"); ExtensionAware ext = (ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION); DeployExtension deploy = new ExtensionUtil(ext).get(AppEngineCorePlugin.DEPLOY_EXTENSION); StageStandardExtension stage = new ExtensionUtil(ext).get(AppEngineStandardPlugin.STAGE_EXTENSION); RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION); ToolsExtension tools = new ExtensionUtil(ext).get(AppEngineCorePlugin.TOOLS_EXTENSION); Assert.assertEquals(deploy.getDeployables().size(), 1); Assert.assertEquals("test", deploy.getDeployables().get(0).getName()); Assert.assertEquals(run.getServices().size(), 1); Assert.assertEquals("test", run.getServices().get(0).getName()); Assert.assertEquals("test", stage.getSourceDirectory().getName()); Assert.assertEquals("test", stage.getStagingDirectory().getName()); Assert.assertEquals("test", stage.getDockerfile().getName()); Assert.assertEquals("test", tools.getCloudSdkHome().getName()); }
@Test public void testFilesAsString() throws IOException { Project p = setUpTestProject("files-as-string"); ExtensionAware ext = (ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION); DeployExtension deploy = new ExtensionUtil(ext).get(AppEngineCorePlugin.DEPLOY_EXTENSION); RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION); Assert.assertEquals(deploy.getDeployables().size(), 2); Assert.assertEquals("test0", deploy.getDeployables().get(0).getName()); Assert.assertEquals("test1", deploy.getDeployables().get(1).getName()); Assert.assertEquals(run.getServices().size(), 2); Assert.assertEquals("test0", run.getServices().get(0).getName()); Assert.assertEquals("test1", run.getServices().get(1).getName()); }
@Test public void testFileAsFile() throws IOException { Project p = setUpTestProject("file-as-file"); ExtensionAware ext = (ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION); DeployExtension deploy = new ExtensionUtil(ext).get(AppEngineCorePlugin.DEPLOY_EXTENSION); StageStandardExtension stage = new ExtensionUtil(ext).get(AppEngineStandardPlugin.STAGE_EXTENSION); RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION); ToolsExtension tools = new ExtensionUtil(ext).get(AppEngineCorePlugin.TOOLS_EXTENSION); Assert.assertEquals(deploy.getDeployables().size(), 1); Assert.assertEquals("test", deploy.getDeployables().get(0).getName()); Assert.assertEquals(run.getServices().size(), 1); Assert.assertEquals("test", run.getServices().get(0).getName()); Assert.assertEquals("test", stage.getSourceDirectory().getName()); Assert.assertEquals("test", stage.getStagingDirectory().getName()); Assert.assertEquals("test", stage.getDockerfile().getName()); Assert.assertEquals("test", tools.getCloudSdkHome().getName()); }
@Test public void testFilesAsFiles() throws IOException { Project p = setUpTestProject("files-as-files"); ExtensionAware ext = (ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION); DeployExtension deploy = new ExtensionUtil(ext).get(AppEngineCorePlugin.DEPLOY_EXTENSION); RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION); Assert.assertEquals(deploy.getDeployables().size(), 2); Assert.assertEquals("test0", deploy.getDeployables().get(0).getName()); Assert.assertEquals("test1", deploy.getDeployables().get(1).getName()); Assert.assertEquals(run.getServices().size(), 2); Assert.assertEquals("test0", run.getServices().get(0).getName()); Assert.assertEquals("test1", run.getServices().get(1).getName()); }
@Test public void testDefaultConfiguration() throws IOException { File appengineWebXml = new File(testProjectDir.getRoot(), "src/main/webapp/WEB-INF/appengine-web.xml"); appengineWebXml.getParentFile().mkdirs(); appengineWebXml.createNewFile(); Files.write(appengineWebXml.toPath(), "<web-app/>".getBytes()); Project project = ProjectBuilder.builder().withProjectDir(testProjectDir.getRoot()).build(); project.getPluginManager().apply(JavaPlugin.class); project.getPluginManager().apply(WarPlugin.class); project.getPluginManager().apply(AppEngineStandardPlugin.class); project.getPluginManager().apply(SourceContextPlugin.class); ((ProjectInternal) project).evaluate(); ExtensionAware ext = (ExtensionAware) project.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION); GenRepoInfoFileExtension genRepoInfoExt = new ExtensionUtil(ext).get(SourceContextPlugin.SOURCE_CONTEXT_EXTENSION); Assert.assertEquals( new File(project.getBuildDir(), "sourceContext"), genRepoInfoExt.getOutputDirectory()); }
@Test public void testGetAllFields_NestedExtensions() throws IllegalAccessException { String expected = "" + "root {\n" + " x {\n" + " y {\n" + " (int) yy = 0\n" + " z {\n" + " (String) zz = hello\n" + " (Map<String, List<String>>) zzNested = {a=[a1, a2], b=[b1, b2]}\n" + " }\n" + " }\n" + " }\n" + "}\n"; Project p = ProjectBuilder.builder().build(); ExtensionAware root = (ExtensionAware) p.getExtensions().create("root", ExtX.class); ExtensionAware x = (ExtensionAware) root.getExtensions().create("x", ExtX.class); ExtensionAware y = (ExtensionAware) x.getExtensions().create("y", ExtY.class); y.getExtensions().create("z", ExtZ.class); String result = ShowConfigurationTask.getExtensionData("root", root, 0); Assert.assertEquals(expected, result); }
private void configureResourceCompileTask(WindowsResourceCompile task, final NativeBinarySpecInternal binary, final WindowsResourceSet sourceSet) { task.setDescription(String.format("Compiles resources of the %s of %s", sourceSet, binary)); task.setToolChain(binary.getToolChain()); task.setTargetPlatform(binary.getTargetPlatform()); task.includes(new Callable<Set<File>>() { public Set<File> call() { return sourceSet.getExportedHeaders().getSrcDirs(); } }); task.source(sourceSet.getSource()); final Project project = task.getProject(); task.setOutputDir(project.file(String.valueOf(project.getBuildDir()) + "/objs/" + binary.getNamingScheme().getOutputDirectoryBase() + "/" + ((LanguageSourceSetInternal) sourceSet).getFullName())); PreprocessingTool rcCompiler = (PreprocessingTool) ((ExtensionAware) binary).getExtensions().getByName("rcCompiler"); task.setMacros(rcCompiler.getMacros()); task.setCompilerArgs(rcCompiler.getArgs()); FileTree resourceOutputs = task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.res")); binary.getTasks().getCreateOrLink().source(resourceOutputs); if (binary instanceof StaticLibraryBinarySpecInternal) { ((StaticLibraryBinarySpecInternal) binary).additionalLinkFiles(resourceOutputs); } }
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); } }); } }); }
public void apply(Project project) { project.getPluginManager().apply(BasePlugin.class); project.getExtensions().create(JavaScriptExtension.NAME, JavaScriptExtension.class); ((ExtensionAware) project.getRepositories()).getExtensions().create( JavaScriptRepositoriesExtension.NAME, JavaScriptRepositoriesExtension.class, project.getRepositories()); }
public void apply(Project project) { project.getPluginManager().apply(JavaScriptBasePlugin.class); JavaScriptExtension jsExtension = project.getExtensions().findByType(JavaScriptExtension.class); final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().create(RhinoExtension.NAME, RhinoExtension.class); final Configuration configuration = addClasspathConfiguration(project.getConfigurations()); configureDefaultRhinoDependency(configuration, project.getDependencies(), rhinoExtension); ConventionMapping conventionMapping = ((IConventionAware) rhinoExtension).getConventionMapping(); conventionMapping.map("classpath", new Callable<Configuration>() { public Configuration call() { return configuration; } }); conventionMapping.map("version", new Callable<String>() { public String call() { return RhinoExtension.DEFAULT_RHINO_DEPENDENCY_VERSION; } }); project.getTasks().withType(RhinoShellExec.class, new Action<RhinoShellExec>() { public void execute(RhinoShellExec task) { task.getConventionMapping().map("classpath", new Callable<FileCollection>() { public FileCollection call() { return rhinoExtension.getClasspath(); } }); task.getConventionMapping().map("main", new Callable<String>() { public String call() { return RhinoExtension.RHINO_SHELL_MAIN; } }); task.setClasspath(rhinoExtension.getClasspath()); } }); }
public void apply(final Project project) { project.getPluginManager().apply(RhinoPlugin.class); project.getPluginManager().apply(ReportingBasePlugin.class); JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class); final EnvJsExtension envJsExtension = ((ExtensionAware) jsExtension).getExtensions().create(EnvJsExtension.NAME, EnvJsExtension.class); final Configuration configuration = addConfiguration(project.getConfigurations(), project.getDependencies(), envJsExtension); final ConventionMapping conventionMapping = ((IConventionAware) envJsExtension).getConventionMapping(); conventionMapping.map("js", new Callable<Configuration>() { public Configuration call() { return configuration; } }); conventionMapping.map("version", new Callable<String>() { public String call() { return EnvJsExtension.DEFAULT_DEPENDENCY_VERSION; } }); final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().getByType(RhinoExtension.class); project.getTasks().withType(BrowserEvaluate.class, new Action<BrowserEvaluate>() { public void execute(BrowserEvaluate task) { ((IConventionAware) task).getConventionMapping().map("evaluator", new Callable<EnvJsBrowserEvaluator>() { public EnvJsBrowserEvaluator call() { RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(workerProcessBuilderFactory); File workDir = project.getProjectDir(); Factory<File> envJsFactory = new Factory<File>() { public File create() { return envJsExtension.getJs().getSingleFile(); } }; return new EnvJsBrowserEvaluator(handleFactory, rhinoExtension.getClasspath(), envJsFactory, project.getGradle().getStartParameter().getLogLevel(), workDir); } }); } }); }
public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) { _project = project; _golang = container.getByType(GolangSettings.class); if (!(_golang instanceof ExtensionAware)) { throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + "."); } final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions(); _build = globalExtensions.getByType(BuildSettings.class); _toolchain = globalExtensions.getByType(ToolchainSettings.class); _dependencies = globalExtensions.getByType(DependenciesSettings.class); _testing = globalExtensions.getByType(TestingSettings.class); }
public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) { _project = project; _golang = container.create("golang", GolangSettings.class, init, project); final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions(); _build = taskExtensions.create("build", BuildSettings.class, init, project); _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project); _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project); _testing = taskExtensions.create("testing", TestingSettings.class, init, project); }
@VisibleForTesting // recursive (but doesn't search through nested objects, only nested extensions) static String getExtensionData(String extensionName, Object extensionInstance, int depth) throws IllegalAccessException { StringBuilder result = new StringBuilder(""); // extension start block result.append(spaces(depth)).append(extensionName).append(" {\n"); // all non-extension fields for (Field field : extensionInstance.getClass().getSuperclass().getDeclaredFields()) { // ignore synthetic fields (stuff added by compiler or instrumenter) if (field.isSynthetic()) { continue; } // This is just a helper for the extensions, don't show it if (field.getType().equals(org.gradle.api.Project.class)) { continue; } result.append(getFieldData(field, extensionInstance, depth + 1)); } // all extension fields Map<String, Object> map = ((ExtensionContainerInternal) ((ExtensionAware) extensionInstance).getExtensions()) .getAsMap(); for (String childExtensionName : map.keySet()) { Object childExtensionInstance = map.get(childExtensionName); // only expand out extensions we understand (we're ignoring the default ext group here, which // is not ExtensionAware) if (childExtensionInstance instanceof ExtensionAware) { result.append(getExtensionData(childExtensionName, map.get(childExtensionName), depth + 1)); } } // extension end block result.append(spaces(depth)).append("}\n"); return result.toString(); }
@Test public void testDefaultConfigurationAlternative() throws IOException { Project p = new TestProject(testProjectDir.getRoot()).addDockerDir().applyFlexibleProjectBuilder(); ExtensionAware ext = (ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION); StageFlexibleExtension stageExt = new ExtensionUtil(ext).get(AppEngineFlexiblePlugin.STAGE_EXTENSION); assertTrue(new File(testProjectDir.getRoot(), "src/main/docker").exists()); assertEquals((((Jar) p.getProperties().get("jar")).getArchivePath()), stageExt.getArtifact()); }
@Test public void testReadEnvironment() throws IOException { Project p = setUpTestProject("environment-params"); ExtensionAware ext = (ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION); RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION); Assert.assertEquals(run.getEnvironment(), ImmutableMap.of("key1", "value1", "key2", "value2")); }
@Test public void testDefaultConfiguration() throws IOException { Project p = new TestProject(testProjectDir.getRoot()) .addAppEngineWebXml() .applyStandardProjectBuilder(); final ExtensionAware ext = (ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION); final DeployExtension deployExt = new ExtensionUtil(ext).get(AppEngineCorePlugin.DEPLOY_EXTENSION); final StageStandardExtension stageExt = new ExtensionUtil(ext).get(AppEngineStandardPlugin.STAGE_EXTENSION); final RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION); assertEquals( new File(p.getBuildDir(), "exploded-" + p.getName()), stageExt.getSourceDirectory()); assertEquals(new File(p.getBuildDir(), "staged-app"), stageExt.getStagingDirectory()); assertEquals( new File(p.getBuildDir(), "staged-app/WEB-INF/appengine-generated"), deployExt.getAppEngineDirectory()); assertEquals( Collections.singletonList(new File(p.getBuildDir(), "staged-app/app.yaml")), deployExt.getDeployables()); assertEquals( Collections.singletonList(new File(p.getBuildDir(), "exploded-" + p.getName())), run.getServices()); assertFalse(new File(testProjectDir.getRoot(), "src/main/docker").exists()); assertEquals(20, run.getStartSuccessTimeout()); }
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); }
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)); }
private void configure(DefaultCUnitTestSuiteBinary testBinary, File buildDir) { BinaryNamingScheme namingScheme = testBinary.getNamingScheme(); PlatformToolProvider toolProvider = testBinary.getPlatformToolProvider(); File binaryOutputDir = new File(new File(buildDir, "binaries"), namingScheme.getOutputDirectoryBase()); String baseName = testBinary.getComponent().getBaseName(); testBinary.setExecutableFile(new File(binaryOutputDir, toolProvider.getExecutableName(baseName))); ((ExtensionAware) testBinary).getExtensions().create("cCompiler", DefaultPreprocessingTool.class); }
public void execute(NativeBinarySpec nativeBinary) { for (LanguageRegistration<?> language : languageRegistry) { Map<String, Class<?>> binaryTools = language.getBinaryTools(); for (String toolName : binaryTools.keySet()) { ((ExtensionAware) nativeBinary).getExtensions().create(toolName, binaryTools.get(toolName)); } } }
public void apply(Project project) { project.getPluginManager().apply(RhinoPlugin.class); project.getPluginManager().apply(ReportingBasePlugin.class); JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class); final JsHintExtension jsHintExtension = ((ExtensionAware) jsExtension).getExtensions().create(JsHintExtension.NAME, JsHintExtension.class); final Configuration configuration = addConfiguration(project.getConfigurations(), project.getDependencies(), jsHintExtension); ConventionMapping conventionMapping = ((IConventionAware) jsHintExtension).getConventionMapping(); conventionMapping.map("js", new Callable<Configuration>() { public Configuration call() { return configuration; } }); conventionMapping.map("version", new Callable<String>() { public String call() { return JsHintExtension.DEFAULT_DEPENDENCY_VERSION; } }); final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().getByType(RhinoExtension.class); final ReportingExtension reportingExtension = project.getExtensions().getByType(ReportingExtension.class); project.getTasks().withType(JsHint.class, new Action<JsHint>() { public void execute(final JsHint task) { task.getConventionMapping().map("rhinoClasspath", new Callable<FileCollection>() { public FileCollection call() { return rhinoExtension.getClasspath(); } }); task.getConventionMapping().map("jsHint", new Callable<FileCollection>() { public FileCollection call() { return jsHintExtension.getJs(); } }); task.getConventionMapping().map("jsonReport", new Callable<File>() { public File call() { return reportingExtension.file(task.getName() + "/report.json"); } }); } }); }
public void apply(Project project) { project.getPluginManager().apply(RhinoPlugin.class); JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class); ExtensionContainer extensionContainer = ((ExtensionAware) jsExtension).getExtensions(); final CoffeeScriptExtension csExtension = extensionContainer.create(CoffeeScriptExtension.NAME, CoffeeScriptExtension.class); final Configuration jsConfiguration = addJsConfiguration(project.getConfigurations(), project.getDependencies(), csExtension); ConventionMapping conventionMapping = ((IConventionAware) csExtension).getConventionMapping(); conventionMapping.map("js", new Callable<Configuration>() { @Override public Configuration call() { return jsConfiguration; } }); conventionMapping.map("version", new Callable<String>() { @Override public String call() { return CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_VERSION; } }); final RhinoExtension rhinoExtension = extensionContainer.getByType(RhinoExtension.class); project.getTasks().withType(CoffeeScriptCompile.class, new Action<CoffeeScriptCompile>() { @Override public void execute(CoffeeScriptCompile task) { task.getConventionMapping().map("rhinoClasspath", new Callable<FileCollection>() { public FileCollection call() { return rhinoExtension.getClasspath(); } }); task.getConventionMapping().map("coffeeScriptJs", new Callable<FileCollection>() { public FileCollection call() { return csExtension.getJs(); } }); } }); }
public ExtensionContainer getExtensions() { if (extensionContainer == null) { this.extensionContainer = toType(object, ExtensionAware.class).getExtensions(); } return extensionContainer; }
public ExtensionUtil(ExtensionAware searchRoot) { this.searchRoot = searchRoot; }
public static DefaultPreprocessingTool getCCompiler(BinarySpec binary) { return (DefaultPreprocessingTool) ((ExtensionAware) binary).getExtensions().getByName("cCompiler"); }
public static DefaultPreprocessingTool getCppCompiler(BinarySpec binary) { return (DefaultPreprocessingTool) ((ExtensionAware) binary).getExtensions().getByName("cppCompiler"); }
private void configureCompileTask(AbstractNativeCompileTask task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) { task.setDescription(String.format("Compiles the %s of %s", sourceSet, binary)); task.setToolChain(binary.getToolChain()); task.setTargetPlatform(binary.getTargetPlatform()); task.setPositionIndependentCode(binary instanceof SharedLibraryBinarySpec); // TODO:DAZ Not sure if these both need to be lazy task.includes(new Callable<Set<File>>() { public Set<File> call() throws Exception { return ((HeaderExportingSourceSet) sourceSet).getExportedHeaders().getSrcDirs(); } }); task.includes(new Callable<List<FileCollection>>() { public List<FileCollection> call() { Collection<NativeDependencySet> libs = binary.getLibs((DependentSourceSet) sourceSet); return CollectionUtils.collect(libs, new Transformer<FileCollection, NativeDependencySet>() { public FileCollection transform(NativeDependencySet original) { return original.getIncludeRoots(); } }); } }); task.source(sourceSet.getSource()); final Project project = task.getProject(); task.setObjectFileDir(project.file(String.valueOf(project.getBuildDir()) + "/objs/" + binary.getNamingScheme().getOutputDirectoryBase() + "/" + sourceSet.getFullName())); for (String toolName : language.getBinaryTools().keySet()) { Tool tool = (Tool) ((ExtensionAware) binary).getExtensions().getByName(toolName); if (tool instanceof PreprocessingTool) { task.setMacros(((PreprocessingTool) tool).getMacros()); } task.setCompilerArgs(tool.getArgs()); } binary.getTasks().getCreateOrLink().source(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o"))); }
private void configureAssembleTask(Assemble task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) { task.setDescription(String.format("Assembles the %s of %s", sourceSet, binary)); task.setToolChain(binary.getToolChain()); task.setTargetPlatform(binary.getTargetPlatform()); task.source(sourceSet.getSource()); final Project project = task.getProject(); task.setObjectFileDir(project.file(project.getBuildDir() + "/objs/" + binary.getNamingScheme().getOutputDirectoryBase() + "/" + sourceSet.getFullName())); Tool assemblerTool = (Tool) ((ExtensionAware) binary).getExtensions().getByName("assembler"); task.setAssemblerArgs(assemblerTool.getArgs()); binary.getTasks().getCreateOrLink().source(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o"))); }