org.gradle.api.GradleException Java Examples

The following examples show how to use org.gradle.api.GradleException. 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: MergeResources.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void generateFile(File toBeGenerated, File original) throws IOException {
    try {
        super.generateFile(toBeGenerated, original);
    } catch (ResourcesNotSupportedException e) {
        // Add gradle-specific error message.
        throw new GradleException(
                String.format(
                        "Can't process attribute %1$s=\"%2$s\": "
                                + "references to other resources are not supported by "
                                + "build-time PNG generation. "
                                + "See http://developer.android.com/tools/help/vector-asset-studio.html "
                                + "for details.",
                        e.getName(), e.getValue()));
    }
}
 
Example #2
Source File: DownloadTask.java    From swaggerhub-gradle-plugin with Apache License 2.0 6 votes vote down vote up
@TaskAction
public void downloadDefinition() throws GradleException {
    SwaggerHubClient swaggerHubClient = new SwaggerHubClient(host, port, protocol, token);

    LOGGER.info("Downloading from " + host
            + ": api:" + api
            + ", owner:" + owner
            + ", version:" + version
            + ", format:" + format
            + ", outputFile:" + outputFile);

    SwaggerHubRequest swaggerHubRequest = new SwaggerHubRequest.Builder(api, owner, version)
            .format(format)
            .build();

    try {
        String swaggerJson = swaggerHubClient.getDefinition(swaggerHubRequest);
        File file = new File(outputFile);

        setUpOutputDir(file);
        Files.write(Paths.get(outputFile), swaggerJson.getBytes(Charset.forName("UTF-8")));
    } catch (IOException | GradleException e) {
        throw new GradleException(e.getMessage(), e);
    }
}
 
Example #3
Source File: ModularCreateStartScripts.java    From gradle-modules-plugin with MIT License 6 votes vote down vote up
private static void configure(ModularCreateStartScripts startScriptsTask, Project project) {
    var appConvention = project.getConvention().findPlugin(ApplicationPluginConvention.class);
    if (appConvention != null) {
        var distDir = project.file(project.getBuildDir() + "/install/" + appConvention.getApplicationName());
        startScriptsTask.setOutputDir(new File(distDir, appConvention.getExecutableDir()));
    }

    ModularJavaExec runTask = startScriptsTask.getRunTask();
    if (runTask == null) throw new GradleException("runTask not set for task " + startScriptsTask.getName());

    var runJvmArgs = runTask.getOwnJvmArgs();
    if (!runJvmArgs.isEmpty()) {
        var defaultJvmOpts = new ArrayList<>(runJvmArgs);
        startScriptsTask.getDefaultJvmOpts().forEach(defaultJvmOpts::add);
        startScriptsTask.setDefaultJvmOpts(defaultJvmOpts);
    }

    var mutator = new StartScriptsMutator(runTask, project);
    mutator.updateStartScriptsTask(startScriptsTask);
    mutator.movePatchedLibs();
}
 
Example #4
Source File: ClientNativeLink.java    From client-gradle-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@TaskAction
public void action() {
    getProject().getLogger().info("ClientNativeLink action");

    boolean result;
    try {
        SubstrateDispatcher dispatcher = new ConfigBuild(project).createSubstrateDispatcher();
        result = dispatcher.nativeLink();
    } catch (Exception e) {
    	throw new GradleException("Failed to link", e);
    }

    if (!result) {
    	throw new GradleException("Linking failed");
    }
}
 
Example #5
Source File: JavadocExecHandleBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ExecAction getExecHandle() {
    try {
        options.write(optionsFile);
    } catch (IOException e) {
        throw new GradleException("Failed to store javadoc options.", e);
    }

    ExecAction execAction = execActionFactory.newExecAction();
    execAction.workingDir(execDirectory);
    execAction.executable(GUtil.elvis(executable, Jvm.current().getJavadocExecutable()));
    execAction.args("@" + optionsFile.getAbsolutePath());

    options.contributeCommandLineOptions(execAction);

    return execAction;
}
 
Example #6
Source File: Wrapper.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@TaskAction
void generate() {
    File jarFileDestination = getJarFile();
    File unixScript = getScriptFile();
    FileResolver resolver = getFileLookup().getFileResolver(unixScript.getParentFile());
    String jarFileRelativePath = resolver.resolveAsRelativePath(jarFileDestination);

    writeProperties(getPropertiesFile());

    URL jarFileSource = Wrapper.class.getResource("/gradle-wrapper.jar");
    if (jarFileSource == null) {
        throw new GradleException("Cannot locate wrapper JAR resource.");
    }
    GFileUtils.copyURLToFile(jarFileSource, jarFileDestination);

    StartScriptGenerator generator = new StartScriptGenerator();
    generator.setApplicationName("Gradle");
    generator.setMainClassName(GradleWrapperMain.class.getName());
    generator.setClasspath(WrapUtil.toList(jarFileRelativePath));
    generator.setOptsEnvironmentVar("GRADLE_OPTS");
    generator.setExitEnvironmentVar("GRADLE_EXIT_CONSOLE");
    generator.setAppNameSystemProperty("org.gradle.appname");
    generator.setScriptRelPath(unixScript.getName());
    generator.generateUnixScript(unixScript);
    generator.generateWindowsScript(getBatchScript());
}
 
Example #7
Source File: NonTransformedModelDslBacking.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Void methodMissing(String name, Object argsObj) {
    Object[] args = (Object[]) argsObj;

    if (!executingDsl.get()) {
        if (name.equals("$")) {
            throw new GradleException(ATTEMPTED_INPUT_SYNTAX_USED_MESSAGE);
        } else {
            throw new MissingMethodException(name, getClass(), args);
        }
    } else {
        if (args.length != 1 || !(args[0] instanceof Closure)) {
            throw new MissingMethodException(name, getClass(), args);
        } else {
            Closure closure = (Closure) args[0];
            getChildPath(name).registerConfigurationAction(closure);
            return null;
        }
    }
}
 
Example #8
Source File: DefaultScriptCompilationHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public <T extends Script> Class<? extends T> loadFromDir(ScriptSource source, ClassLoader classLoader, File scriptCacheDir,
                                          Class<T> scriptBaseClass) {
    if (new File(scriptCacheDir, EMPTY_SCRIPT_MARKER_FILE_NAME).isFile()) {
        return emptyScriptGenerator.generate(scriptBaseClass);
    }
    
    try {
        URLClassLoader urlClassLoader = new URLClassLoader(WrapUtil.toArray(scriptCacheDir.toURI().toURL()),
                classLoader);
        return urlClassLoader.loadClass(source.getClassName()).asSubclass(scriptBaseClass);
    } catch (Exception e) {
        File expectedClassFile = new File(scriptCacheDir, source.getClassName()+".class");
        if(!expectedClassFile.exists()){
            throw new GradleException(String.format("Could not load compiled classes for %s from cache. Expected class file %s does not exist.", source.getDisplayName(), expectedClassFile.getAbsolutePath()), e);
        }
        throw new GradleException(String.format("Could not load compiled classes for %s from cache.", source.getDisplayName()), e);
    }
}
 
Example #9
Source File: ApiGroovyCompiler.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void applyConfigurationScript(File configScript, CompilerConfiguration configuration) {
    VersionNumber version = parseGroovyVersion();
    if (version.compareTo(VersionNumber.parse("2.1")) < 0) {
        throw new GradleException("Using a Groovy compiler configuration script requires Groovy 2.1+ but found Groovy " + version + "");
    }
    Binding binding = new Binding();
    binding.setVariable("configuration", configuration);

    CompilerConfiguration configuratorConfig = new CompilerConfiguration();
    ImportCustomizer customizer = new ImportCustomizer();
    customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
    configuratorConfig.addCompilationCustomizers(customizer);

    GroovyShell shell = new GroovyShell(binding, configuratorConfig);
    try {
        shell.evaluate(configScript);
    } catch (Exception e) {
        throw new GradleException("Could not execute Groovy compiler configuration script: " + configScript.getAbsolutePath(), e);
    }
}
 
Example #10
Source File: ConsumerOperationParameters.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Builder setLaunchables(Iterable<? extends Launchable> launchables) {
    Set<String> taskPaths = new LinkedHashSet<String>();
    List<InternalLaunchable> launchablesParams = Lists.newArrayList();
    for (Launchable launchable : launchables) {
        Object original = new ProtocolToModelAdapter().unpack(launchable);
        if (original instanceof InternalLaunchable) {
            // A launchable created by the provider - just hand it back
            launchablesParams.add((InternalLaunchable) original);
        } else if (original instanceof TaskListingLaunchable) {
            // A launchable synthesized by the consumer - unpack it into a set of task names
            taskPaths.addAll(((TaskListingLaunchable) original).getTaskNames());
        } else if (launchable instanceof Task) {
            // A task created by a provider that does not understand launchables
            taskPaths.add(((Task) launchable).getPath());
        } else {
            throw new GradleException("Only Task or TaskSelector instances are supported: "
                    + (launchable != null ? launchable.getClass() : "null"));
        }
    }
    this.launchables = launchablesParams;
    tasks = Lists.newArrayList(taskPaths);
    return this;
}
 
Example #11
Source File: JavadocExecHandleBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ExecAction getExecHandle() {
    try {
        options.write(optionsFile);
    } catch (IOException e) {
        throw new GradleException("Failed to store javadoc options.", e);
    }

    ExecAction execAction = execActionFactory.newExecAction();
    execAction.workingDir(execDirectory);
    execAction.executable(GUtil.elvis(executable, Jvm.current().getJavadocExecutable()));
    execAction.args("@" + optionsFile.getAbsolutePath());

    options.contributeCommandLineOptions(execAction);

    return execAction;
}
 
Example #12
Source File: GenerateSchemaTask.java    From smallrye-graphql with Apache License 2.0 6 votes vote down vote up
private void write(String schema) {
    try {
        if (destination == null || destination.isEmpty()) {
            // no destination file specified => print to stdout
            getLogger().quiet(schema);
        } else {
            Path path = new File(destination).toPath();
            path.toFile().getParentFile().mkdirs();
            Files.write(path, schema.getBytes(),
                    StandardOpenOption.WRITE,
                    StandardOpenOption.CREATE,
                    StandardOpenOption.TRUNCATE_EXISTING);
            getLogger().info("Wrote the schema to " + path.toAbsolutePath().toString());
        }
    } catch (IOException e) {
        throw new GradleException("Can't write the result", e);
    }
}
 
Example #13
Source File: CommandLineTool.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public WorkResult execute(T spec) {
    ExecAction compiler = execActionFactory.newExecAction();
    compiler.executable(executable);
    if (workDir != null) {
        compiler.workingDir(workDir);
    }

    List<String> args = specToArgs.transform(specTransformer.transform(spec));
    compiler.args(args);

    if (!path.isEmpty()) {
        String pathVar = OperatingSystem.current().getPathVar();
        String compilerPath = Joiner.on(File.pathSeparator).join(path);
        compilerPath = compilerPath + File.pathSeparator + System.getenv(pathVar);
        compiler.environment(pathVar, compilerPath);
    }

    compiler.environment(environment);

    try {
        compiler.execute();
    } catch (ExecException e) {
        throw new GradleException(String.format("%s failed; see the error output for details.", action), e);
    }
    return new SimpleWorkResult(true);
}
 
Example #14
Source File: FirebaseLibraryExtension.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Register to be released alongside another Firebase Library project.
 *
 * <p>This will force the released version of the current project to match the one it's released
 * with.
 */
public void releaseWith(Project releaseWithProject) {
  try {
    FirebaseLibraryExtension releaseWithLibrary =
        releaseWithProject.getExtensions().getByType(FirebaseLibraryExtension.class);
    releaseWithLibrary.librariesToCoRelease.add(this);
    this.project.setVersion(releaseWithProject.getVersion());

    String latestRelease = "latestReleasedVersion";
    if (releaseWithProject.getExtensions().getExtraProperties().has(latestRelease)) {
      this.project
          .getExtensions()
          .getExtraProperties()
          .set(latestRelease, releaseWithProject.getProperties().get(latestRelease));
    }

  } catch (UnknownDomainObjectException ex) {
    throw new GradleException(
        "Library cannot be released with a project that is not a Firebase Library itself");
  }
}
 
Example #15
Source File: SwaggerHubClient.java    From swaggerhub-gradle-plugin with Apache License 2.0 6 votes vote down vote up
public void saveDefinition(SwaggerHubRequest swaggerHubRequest) throws GradleException {
    HttpUrl httpUrl = getUploadUrl(swaggerHubRequest);
    MediaType mediaType = MediaType.parse("application/" + swaggerHubRequest.getFormat());

    final Request httpRequest = buildPostRequest(httpUrl, mediaType, swaggerHubRequest.getSwagger());

    try {
        Response response = client.newCall(httpRequest).execute();
        if (!response.isSuccessful()) {
            throw new GradleException(
                    String.format("Failed to upload definition: %s", response.body().string())
            );
        }
    } catch (IOException e) {
        throw new GradleException("Failed to upload definition", e);
    }
    return;
}
 
Example #16
Source File: DefaultScriptCompilationHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public <T extends Script> Class<? extends T> loadFromDir(ScriptSource source, ClassLoader classLoader, File scriptCacheDir,
                                                         Class<T> scriptBaseClass) {
    if (new File(scriptCacheDir, EMPTY_SCRIPT_MARKER_FILE_NAME).isFile()) {
        return emptyScriptGenerator.generate(scriptBaseClass);
    }

    try {
        URLClassLoader urlClassLoader = new URLClassLoader(WrapUtil.toArray(scriptCacheDir.toURI().toURL()), classLoader);
        return urlClassLoader.loadClass(source.getClassName()).asSubclass(scriptBaseClass);
    } catch (Exception e) {
        File expectedClassFile = new File(scriptCacheDir, source.getClassName() + ".class");
        if (!expectedClassFile.exists()) {
            throw new GradleException(String.format("Could not load compiled classes for %s from cache. Expected class file %s does not exist.", source.getDisplayName(), expectedClassFile.getAbsolutePath()), e);
        }
        throw new GradleException(String.format("Could not load compiled classes for %s from cache.", source.getDisplayName()), e);
    }
}
 
Example #17
Source File: SkipOnlyIfTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    boolean skip;
    try {
        skip = !task.getOnlyIf().isSatisfiedBy(task);
    } catch (Throwable t) {
        state.executed(new GradleException(String.format("Could not evaluate onlyIf predicate for %s.", task), t));
        return;
    }

    if (skip) {
        LOGGER.info("Skipping {} as task onlyIf is false.", task);
        state.skipped("SKIPPED");
        return;
    }

    executer.execute(task, state, context);
}
 
Example #18
Source File: BuildInvocationsBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DefaultBuildInvocations buildAll(String modelName, Project project) {
    if (!canBuild(modelName)) {
        throw new GradleException("Unknown model name " + modelName);
    }
    List<LaunchableGradleTaskSelector> selectors = Lists.newArrayList();
    Set<String> aggregatedTasks = Sets.newLinkedHashSet();
    Set<String> visibleTasks = Sets.newLinkedHashSet();
    findTasks(project, aggregatedTasks, visibleTasks);
    for (String selectorName : aggregatedTasks) {
        selectors.add(new LaunchableGradleTaskSelector().
                setName(selectorName).
                setTaskName(selectorName).
                setProjectPath(project.getPath()).
                setDescription(project.getParent() != null
                        ? String.format("%s:%s task selector", project.getPath(), selectorName)
                        : String.format("%s task selector", selectorName)).
                setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.toString())).
                setPublic(visibleTasks.contains(selectorName)));
    }
    return new DefaultBuildInvocations()
            .setSelectors(selectors)
            .setTasks(tasks(project));
}
 
Example #19
Source File: Wrapper.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@TaskAction
void generate() {
    File jarFileDestination = getJarFile();
    File unixScript = getScriptFile();
    FileResolver resolver = getServices().get(FileLookup.class).getFileResolver(unixScript.getParentFile());
    String jarFileRelativePath = resolver.resolveAsRelativePath(jarFileDestination);

    writeProperties(getPropertiesFile());

    URL jarFileSource = Wrapper.class.getResource("/gradle-wrapper.jar");
    if (jarFileSource == null) {
        throw new GradleException("Cannot locate wrapper JAR resource.");
    }
    GFileUtils.copyURLToFile(jarFileSource, jarFileDestination);

    StartScriptGenerator generator = new StartScriptGenerator();
    generator.setApplicationName("Gradle");
    generator.setMainClassName(GradleWrapperMain.class.getName());
    generator.setClasspath(WrapUtil.toList(jarFileRelativePath));
    generator.setOptsEnvironmentVar("GRADLE_OPTS");
    generator.setExitEnvironmentVar("GRADLE_EXIT_CONSOLE");
    generator.setAppNameSystemProperty("org.gradle.appname");
    generator.setScriptRelPath(unixScript.getName());
    generator.generateUnixScript(unixScript);
    generator.generateWindowsScript(getBatchScript());
}
 
Example #20
Source File: JavadocGenerator.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public WorkResult execute(JavadocSpec spec) {
    JavadocExecHandleBuilder javadocExecHandleBuilder = new JavadocExecHandleBuilder(execActionFactory);
    javadocExecHandleBuilder.setExecutable(spec.getExecutable());
    javadocExecHandleBuilder.execDirectory(spec.getWorkingDir()).options(spec.getOptions()).optionsFile(spec.getOptionsFile());

    ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
    if (spec.isIgnoreFailures()) {
        execAction.setIgnoreExitValue(true);
    }

    try {
        execAction.execute();
    } catch (ExecException e) {
        LOG.info("Problems generating Javadoc. The generated Javadoc options file used by Gradle has following contents:\n------\n{}------", GFileUtils.readFileQuietly(spec.getOptionsFile()));
        throw new GradleException(String.format("Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '%s'", spec.getOptionsFile()), e);
    }

    return new SimpleWorkResult(true);
}
 
Example #21
Source File: TarCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitFile(FileCopyDetails fileDetails) {
    try {
        TarEntry archiveEntry = new TarEntry(fileDetails.getRelativePath().getPathString());
        archiveEntry.setModTime(fileDetails.getLastModified());
        archiveEntry.setSize(fileDetails.getSize());
        archiveEntry.setMode(UnixStat.FILE_FLAG | fileDetails.getMode());
        tarOutStr.putNextEntry(archiveEntry);
        fileDetails.copyTo(tarOutStr);
        tarOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to TAR '%s'.", fileDetails, tarFile), e);
    }
}
 
Example #22
Source File: SimpleStateCache.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void serialize(T newValue) {
    try {
        OutputStreamBackedEncoder encoder = new OutputStreamBackedEncoder(new BufferedOutputStream(new FileOutputStream(cacheFile)));
        try {
            serializer.write(encoder, newValue);
        } finally {
            encoder.close();
        }
    } catch (Exception e) {
        throw new GradleException(String.format("Could not write cache value to '%s'.", cacheFile), e);
    }
}
 
Example #23
Source File: JUnitTestFramework.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void verifyJUnitCategorySupport() {
    if (!options.getExcludeCategories().isEmpty() || !options.getIncludeCategories().isEmpty()) {
        try {
            getTestClassLoader().loadClass("org.junit.experimental.categories.Category");
        } catch (ClassNotFoundException e) {
            throw new GradleException("JUnit Categories defined but declared JUnit version does not support Categories.");
        }
    }
}
 
Example #24
Source File: AbstractFileTreeElement.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean copyTo(File target) {
    validateTimeStamps();
    try {
        if (isDirectory()) {
            GFileUtils.mkdirs(target);
        } else {
            GFileUtils.mkdirs(target.getParentFile());
            copyFile(target);
        }
        chmod.chmod(target, getMode());
        return true;
    } catch (Exception e) {
        throw new GradleException(String.format("Could not copy %s to '%s'.", getDisplayName(), target), e);
    }
}
 
Example #25
Source File: ZipCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDir(FileCopyDetails dirDetails) {
    try {
        // Trailing slash in name indicates that entry is a directory
        ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/');
        archiveEntry.setTime(dirDetails.getLastModified());
        archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode());
        zipOutStr.putNextEntry(archiveEntry);
        zipOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e);
    }
}
 
Example #26
Source File: DefaultFileCopyDetails.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void adaptPermissions(File target) {
    final Integer specMode = getMode();
    if(specMode !=null){
        try {
            getChmod().chmod(target, specMode);
        } catch (IOException e) {
            throw new GradleException(String.format("Could not set permission %s on '%s'.", specMode, target), e);
        }
    }
}
 
Example #27
Source File: DefaultAntBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void importBuild(Object antBuildFile) {
    File file = gradleProject.file(antBuildFile);
    final File baseDir = file.getParentFile();

    Set<String> existingAntTargets = new HashSet<String>(getAntProject().getTargets().keySet());
    File oldBaseDir = getAntProject().getBaseDir();
    getAntProject().setBaseDir(baseDir);
    try {
        getAntProject().setUserProperty(MagicNames.ANT_FILE, file.getAbsolutePath());
        ProjectHelper.configureProject(getAntProject(), file);
    } catch (Exception e) {
        throw new GradleException("Could not import Ant build file '" + String.valueOf(file) + "'.", e);
    } finally {
        getAntProject().setBaseDir(oldBaseDir);
    }

    // Chuck away the implicit target. It has already been executed
    getAntProject().getTargets().remove("");

    // Add an adapter for each newly added target
    Set<String> newAntTargets = new HashSet<String>(getAntProject().getTargets().keySet());
    newAntTargets.removeAll(existingAntTargets);
    for (String name : newAntTargets) {
        Target target = getAntProject().getTargets().get(name);
        AntTarget task = gradleProject.getTasks().create(target.getName(), AntTarget.class);
        task.setTarget(target);
        task.setBaseDir(baseDir);
        addDependencyOrdering(target.getDependencies());
    }
}
 
Example #28
Source File: ExecuteActionsTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    listener.beforeActions(task);
    state.setExecuting(true);
    try {
        GradleException failure = executeActions(task, state, context);
        state.executed(failure);
    } finally {
        state.setExecuting(false);
        listener.afterActions(task);
    }
}
 
Example #29
Source File: GoogleServicesTask.java    From play-services-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Handle project_info/project_number for @string/gcm_defaultSenderId, and fill the res map with
 * the read value.
 *
 * @param rootObject the root Json object.
 * @throws IOException
 */
private void handleProjectNumberAndProjectId(JsonObject rootObject, Map<String, String> resValues)
    throws IOException {
  JsonObject projectInfo = rootObject.getAsJsonObject("project_info");
  if (projectInfo == null) {
    throw new GradleException("Missing project_info object");
  }

  JsonPrimitive projectNumber = projectInfo.getAsJsonPrimitive("project_number");
  if (projectNumber == null) {
    throw new GradleException("Missing project_info/project_number object");
  }

  resValues.put("gcm_defaultSenderId", projectNumber.getAsString());

  JsonPrimitive projectId = projectInfo.getAsJsonPrimitive("project_id");

  if (projectId == null) {
    throw new GradleException("Missing project_info/project_id object");
  }
  resValues.put("project_id", projectId.getAsString());

  JsonPrimitive bucketName = projectInfo.getAsJsonPrimitive("storage_bucket");
  if (bucketName != null) {
    resValues.put("google_storage_bucket", bucketName.getAsString());
  }
}
 
Example #30
Source File: InputPropertiesSerializer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void write(Encoder encoder, Map<String, Object> properties) throws Exception {
    try {
        serializer.write(encoder, properties);
    } catch (MapSerializer.EntrySerializationException e) {
        throw new GradleException(format("Unable to store task input properties. Property '%s' with value '%s' cannot be serialized.", e.getKey(), e.getValue()), e);
    }
}