org.gradle.api.plugins.ExtensionAware Java Examples

The following examples show how to use org.gradle.api.plugins.ExtensionAware. 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: CredentialsPlugin.java    From gradle-credentials-plugin with Apache License 2.0 6 votes vote down vote up
private void init(Gradle gradle, ExtensionAware extensionAware, Function<String, File> locationResolver, Action<Pair> customizations) {
    // get the passphrase from the project properties, otherwise use the default passphrase
    String passphrase = getStringProperty(CREDENTIALS_PASSPHRASE_PROPERTY, DEFAULT_PASSPHRASE, extensionAware);

    // derive the name of the credentials file from the passphrase
    String credentialsFileName = deriveFileNameFromPassphrase(passphrase);

    // create credentials encryptor for the given passphrase
    CredentialsEncryptor credentialsEncryptor = CredentialsEncryptor.withPassphrase(passphrase.toCharArray());

    // create a credentials persistence manager that operates on the credentials file, possibly located in a user-configured folder
    String credentialsLocation = getStringProperty(CREDENTIALS_LOCATION_PROPERTY, null, extensionAware);
    File credentialsLocationDir = credentialsLocation != null ? locationResolver.apply(credentialsLocation) : gradle.getGradleUserHomeDir();
    File credentialsFile = new File(credentialsLocationDir, credentialsFileName);
    CredentialsPersistenceManager credentialsPersistenceManager = new CredentialsPersistenceManager(credentialsFile);

    // add a new 'credentials' property and transiently store the persisted credentials for access in build scripts
    CredentialsContainer credentialsContainer = new CredentialsContainer(credentialsEncryptor, credentialsPersistenceManager.readCredentials());
    setProperty(CREDENTIALS_CONTAINER_PROPERTY, credentialsContainer, extensionAware);
    LOGGER.debug("Registered property '" + CREDENTIALS_CONTAINER_PROPERTY + "'");

    // allow further ExtensionAware-specific customization
    customizations.execute(new Pair(credentialsEncryptor, credentialsPersistenceManager));
}
 
Example #2
Source File: CredentialsPlugin.java    From gradle-credentials-plugin with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("NullableProblems")
@Override
public void apply(ExtensionAware extensionAware) {
    // abort if old Gradle version is not supported
    if (GradleVersion.current().getBaseVersion().compareTo(GradleVersion.version("5.0")) < 0) {
        throw new IllegalStateException("This version of the credentials plugin is not compatible with Gradle < 5.0");
    }

    // handle plugin application to settings file and project file
    if (extensionAware instanceof Settings) {
        Settings settings = (Settings) extensionAware;
        init(settings.getGradle(), settings, (String loc) -> settings.getSettingsDir().toPath().resolve(loc).toFile(), NOOP);
    } else if (extensionAware instanceof Project) {
        Project project = (Project) extensionAware;
        init(project.getGradle(), project, project::file, (Pair creds) -> addTasks(creds, project.getTasks()));
    } else {
        throw new IllegalStateException("The credentials plugin can only be applied to Settings and Project instances");
    }
}
 
Example #3
Source File: WindowsResourcesCompileTaskConfig.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    }
}
 
Example #4
Source File: CreateCUnitBinaries.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #5
Source File: WindowsResourcesCompileTaskConfig.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    }
}
 
Example #6
Source File: CreateCUnitBinaries.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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: BeanstalkPlugin.java    From gradle-beanstalk-plugin with 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 #8
Source File: GolangPluginSupport.java    From gradle-golang-plugin with Mozilla Public License 2.0 6 votes vote down vote up
@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);
}
 
Example #9
Source File: SourceContextPlugin.java    From app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
private void createExtension() {
  // obtain extensions defined by core plugin.
  ExtensionAware appengine = new ExtensionUtil(project).get("appengine");
  final ToolsExtension tools = ((AppEngineCoreExtensionProperties) appengine).getTools();

  // create source context extension and set defaults
  extension =
      appengine
          .getExtensions()
          .create(SOURCE_CONTEXT_EXTENSION, GenRepoInfoFileExtension.class, project);
  extension.setOutputDirectory(new File(project.getBuildDir(), "sourceContext"));
  extension.setSourceDirectory(new File(project.getProjectDir(), "src"));

  // wait to read the cloudSdkHome till after project evaluation
  project.afterEvaluate(
      project -> {
        try {
          cloudSdkOperations = new CloudSdkOperations(tools.getCloudSdkHome(), null);
        } catch (CloudSdkNotFoundException ex) {
          // this should be caught in AppEngineCorePluginConfig before it can ever reach here.
          throw new GradleException("Could not find CloudSDK: ", ex);
        }
      });
}
 
Example #10
Source File: ShowConfigurationTaskTest.java    From app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #11
Source File: TestProject.java    From app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
private Project applyProjectBuilder(Class<?>... plugins) {
  Project p = ProjectBuilder.builder().withProjectDir(projectRoot).build();
  for (Class<?> clazz : plugins) {
    p.getPluginManager().apply(clazz);
  }

  Object appengineExt = p.getExtensions().getByName(APPENGINE_EXTENSION);
  DeployExtension deploy =
      ((ExtensionAware) appengineExt).getExtensions().getByType(DeployExtension.class);
  deploy.setProjectId("test-project");
  deploy.setVersion("test-version");

  ((ProjectInternal) p).evaluate();

  return p;
}
 
Example #12
Source File: ToolSettingNativeBinaryInitializer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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));
        }
    }
}
 
Example #13
Source File: ToolSettingNativeBinaryInitializer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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));
        }
    }
}
 
Example #14
Source File: CUnitPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #15
Source File: ExtensionUtils.java    From pygradle with Apache License 2.0 5 votes vote down vote up
public static <T> T maybeCreate(PythonExtension extension, String name, Class<T> type, Object... args) {
    ExtensionContainer extensionContainer = ((ExtensionAware) extension).getExtensions();
    T maybeExtension = extensionContainer.findByType(type);
    if (maybeExtension == null) {
        maybeExtension = extensionContainer.create(name, type, args);
    }
    return maybeExtension;
}
 
Example #16
Source File: SourceContextPluginTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@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);

  DeployExtension deploy =
      project.getExtensions().getByType(AppEngineStandardExtension.class).getDeploy();
  deploy.setProjectId("project");
  deploy.setVersion("version");
  ((ProjectInternal) project).evaluate();

  ExtensionAware ext =
      (ExtensionAware)
          project.getExtensions().getByName(AppEngineCorePluginConfiguration.APPENGINE_EXTENSION);
  GenRepoInfoFileExtension genRepoInfoExt =
      new ExtensionUtil(ext).get(SourceContextPlugin.SOURCE_CONTEXT_EXTENSION);
  Assert.assertEquals(
      new File(project.getBuildDir(), "sourceContext"), genRepoInfoExt.getOutputDirectory());
}
 
Example #17
Source File: AppEngineStandardExtension.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
/** Create nested configuration blocks as Extensions. */
public void createSubExtensions(Project project) {
  tools =
      ((ExtensionAware) this).getExtensions().create(TOOLS_EXT, ToolsExtension.class, project);
  deploy =
      ((ExtensionAware) this).getExtensions().create(DEPLOY_EXT, DeployExtension.class, project);
  stage =
      ((ExtensionAware) this)
          .getExtensions()
          .create(STAGE_EXT, StageStandardExtension.class, project);
  run = ((ExtensionAware) this).getExtensions().create(RUN_EXT, RunExtension.class, project);
}
 
Example #18
Source File: CUnitPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #19
Source File: Settings.java    From gradle-golang-plugin with Mozilla Public License 2.0 5 votes vote down vote up
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);
}
 
Example #20
Source File: Settings.java    From gradle-golang-plugin with Mozilla Public License 2.0 5 votes vote down vote up
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);
}
 
Example #21
Source File: AppEngineAppYamlExtension.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
/** Create nested configuration blocks as Extensions. */
public void createSubExtensions(Project project) {
  tools =
      ((ExtensionAware) this).getExtensions().create(TOOLS_EXT, ToolsExtension.class, project);
  deploy =
      ((ExtensionAware) this).getExtensions().create(DEPLOY_EXT, DeployExtension.class, project);
  stage =
      ((ExtensionAware) this)
          .getExtensions()
          .create(STAGE_EXT, StageAppYamlExtension.class, project);
}
 
Example #22
Source File: CompileTaskConfig.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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")));
}
 
Example #23
Source File: CredentialsPlugin.java    From gradle-credentials-plugin with Apache License 2.0 4 votes vote down vote up
private void setProperty(String key, Object value, ExtensionAware extensionAware) {
    ExtraPropertiesExtension properties = extensionAware.getExtensions().getExtraProperties();
    properties.set(key, value);
}
 
Example #24
Source File: CredentialsPlugin.java    From gradle-credentials-plugin with Apache License 2.0 4 votes vote down vote up
private String getStringProperty(String key, String defaultValue, ExtensionAware extensionAware) {
    ExtraPropertiesExtension properties = extensionAware.getExtensions().getExtraProperties();
    return properties.has(key) ? (String) properties.get(key) : defaultValue;
}
 
Example #25
Source File: CompileTaskConfig.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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")));
}
 
Example #26
Source File: DslObject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    if (extensionContainer == null) {
        this.extensionContainer = toType(object, ExtensionAware.class).getExtensions();
    }
    return extensionContainer;
}
 
Example #27
Source File: AssembleTaskConfig.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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")));
}
 
Example #28
Source File: DslObject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    if (extensionContainer == null) {
        this.extensionContainer = toType(object, ExtensionAware.class).getExtensions();
    }
    return extensionContainer;
}
 
Example #29
Source File: AssembleTaskConfig.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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")));
}
 
Example #30
Source File: DslObject.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtensionContainer getExtensions() {
    if (extensionContainer == null) {
        this.extensionContainer = toType(object, ExtensionAware.class).getExtensions();
    }
    return extensionContainer;
}