Java Code Examples for org.gradle.util.GUtil#isTrue()

The following examples show how to use org.gradle.util.GUtil#isTrue() . 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: XmlTransformer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void printNode(Node node, Writer writer) {
    final PrintWriter printWriter = new PrintWriter(writer);
    if (GUtil.isTrue(publicId)) {
        printWriter.format("<!DOCTYPE %s PUBLIC \"%s\" \"%s\">%n", node.name(), publicId, systemId);
    }
    IndentPrinter indentPrinter = new IndentPrinter(printWriter, indentation) {
        @Override
        public void println() {
            printWriter.println();
        }
    };
    XmlNodePrinter nodePrinter = new XmlNodePrinter(indentPrinter);
    nodePrinter.setPreserveWhitespace(true);
    nodePrinter.print(node);
    printWriter.flush();
}
 
Example 2
Source File: ProgressLogEventGenerator.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void completeHeader() {
    boolean hasDescription = GUtil.isTrue(loggingHeader);
    switch (state) {
        case None:
            if (hasDescription) {
                listener.onOutput(new StyledTextOutputEvent(startTime, category, LogLevel.LIFECYCLE, loggingHeader + EOL));
            }
            break;
        case HeaderStarted:
            listener.onOutput(new StyledTextOutputEvent(startTime, category, LogLevel.LIFECYCLE, EOL));
            break;
        case HeaderCompleted:
            return;
        default:
            throw new IllegalStateException();
    }
    state = State.HeaderCompleted;
}
 
Example 3
Source File: ClassPageRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void renderFailures(SimpleHtmlWriter htmlWriter) throws IOException {
    for (TestResult test : getResults().getFailures()) {
        htmlWriter.startElement("div").attribute("class", "test")
            .startElement("a").attribute("name", test.getId().toString()).characters("").endElement() //browsers dont understand <a name="..."/>
            .startElement("h3").attribute("class", test.getStatusClass()).characters(test.getName()).endElement();
        for (TestFailure failure : test.getFailures()) {
            String message;
            if (GUtil.isTrue(failure.getMessage()) && !failure.getStackTrace().contains(failure.getMessage())) {
                message = failure.getMessage() + SystemProperties.getLineSeparator() + SystemProperties.getLineSeparator() + failure.getStackTrace();
            } else {
                message = failure.getStackTrace();
            }
            codePanelRenderer.render(message, htmlWriter);
        }
        htmlWriter.endElement();
    }
}
 
Example 4
Source File: DefaultArtifactRepositoryContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T extends ArtifactRepository> T addWithUniqueName(T repository, String defaultName, Action<? super T> insertion) {
    String repositoryName = repository.getName();
    if (!GUtil.isTrue(repositoryName)) {
        repository.setName(uniquifyName(defaultName));
    } else {
        repository.setName(uniquifyName(repositoryName));
    }

    assertCanAdd(repository.getName());
    insertion.execute(repository);
    cast(ArtifactRepositoryInternal.class, repository).onAddToContainer(this);
    return repository;
}
 
Example 5
Source File: ScalaDoc.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
protected void generate() {
    ScalaDocOptions options = getScalaDocOptions();
    if (!GUtil.isTrue(options.getDocTitle())) {
        options.setDocTitle(getTitle());
    }
    getAntScalaDoc().execute(getSource(), getDestinationDir(), getClasspath(), getScalaClasspath(), options);
}
 
Example 6
Source File: DefaultArtifactRepositoryContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DependencyResolver addBefore(Object userDescription, final String afterResolverName, Closure configureClosure) {
    if (!GUtil.isTrue(afterResolverName)) {
        throw new InvalidUserDataException("You must specify afterResolverName");
    }
    DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.addBefore()");
    final ArtifactRepository after = getByName(afterResolverName);
    return addCustomDependencyResolver(userDescription, configureClosure, new Action<ArtifactRepository>() {
        public void execute(ArtifactRepository repository) {
            DefaultArtifactRepositoryContainer.super.add(indexOf(after), repository);
        }
    });
}
 
Example 7
Source File: AbstractArchiveTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private String maybe(String prefix, String value) {
    if (GUtil.isTrue(value)) {
        if (GUtil.isTrue(prefix)) {
            return String.format("-%s", value);
        } else {
            return value;
        }
    }
    return "";
}
 
Example 8
Source File: DefaultArtifactRepositoryContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T extends ArtifactRepository> T addWithUniqueName(T repository, String defaultName, Action<? super T> insertion) {
    String repositoryName = repository.getName();
    if (!GUtil.isTrue(repositoryName)) {
        repository.setName(uniquifyName(defaultName));
    } else {
        repository.setName(uniquifyName(repositoryName));
    }

    assertCanAdd(repository.getName());
    insertion.execute(repository);
    return repository;
}
 
Example 9
Source File: DependencyResolverIvyPublisher.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Artifact createIvyArtifact(IvyArtifact ivyArtifact, ModuleRevisionId moduleRevisionId) {
    Map<String, String> extraAttributes = new HashMap<String, String>();
    if (GUtil.isTrue(ivyArtifact.getClassifier())) {
        extraAttributes.put(Dependency.CLASSIFIER, ivyArtifact.getClassifier());
    }
    return new DefaultArtifact(
            moduleRevisionId,
            null,
            GUtil.elvis(ivyArtifact.getName(), moduleRevisionId.getName()),
            ivyArtifact.getType(),
            ivyArtifact.getExtension(),
            extraAttributes);
}
 
Example 10
Source File: DependencyResolverIvyPublisher.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Artifact createIvyArtifact(IvyArtifact ivyArtifact, ModuleRevisionId moduleRevisionId) {
    Map<String, String> extraAttributes = new HashMap<String, String>();
    if (GUtil.isTrue(ivyArtifact.getClassifier())) {
        extraAttributes.put(Dependency.CLASSIFIER, ivyArtifact.getClassifier());
    }
    return new DefaultArtifact(
            moduleRevisionId,
            null,
            GUtil.elvis(ivyArtifact.getName(), moduleRevisionId.getName()),
            ivyArtifact.getType(),
            ivyArtifact.getExtension(),
            extraAttributes);
}
 
Example 11
Source File: DefaultTaskContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Task resolveTask(Object path) {
    if (!GUtil.isTrue(path)) {
        throw new InvalidUserDataException("A path must be specified!");
    }
    if (!(path instanceof CharSequence)) {
        DeprecationLogger.nagUserOfDeprecated(
                String.format("Converting class %s to a task dependency using toString()", path.getClass().getName()),
                "Please use org.gradle.api.Task, java.lang.String, org.gradle.api.Buildable, org.gradle.tasks.TaskDependency or a Closure to declare your task dependencies"
        );
    }
    return getByPath(path.toString());
}
 
Example 12
Source File: DefaultMavenPublication.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public String determinePackagingFromArtifacts() {
    for (MavenArtifact mavenArtifact : mavenArtifacts) {
        if (!GUtil.isTrue(mavenArtifact.getClassifier()) && GUtil.isTrue(mavenArtifact.getExtension())) {
            return mavenArtifact.getExtension();
        }
    }
    return "pom";
}
 
Example 13
Source File: ArtifactResolveException.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static String format(ComponentIdentifier component, String message) {
    StringBuilder builder = new StringBuilder();
    builder.append("Could not determine artifacts for component '");
    builder.append(component.getDisplayName());
    builder.append("'");
    if (GUtil.isTrue(message)) {
        builder.append(": ");
        builder.append(message);
    }
    return builder.toString();
}
 
Example 14
Source File: DependencyResolverIvyPublisher.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Artifact createIvyArtifact(IvyArtifact ivyArtifact, ModuleRevisionId moduleRevisionId) {
    Map<String, String> extraAttributes = new HashMap<String, String>();
    if (GUtil.isTrue(ivyArtifact.getClassifier())) {
        extraAttributes.put(Dependency.CLASSIFIER, ivyArtifact.getClassifier());
    }
    return new DefaultArtifact(
            moduleRevisionId,
            null,
            GUtil.elvis(ivyArtifact.getName(), moduleRevisionId.getName()),
            ivyArtifact.getType(),
            ivyArtifact.getExtension(),
            extraAttributes);
}
 
Example 15
Source File: TaskFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TaskInternal createTask(Map<String, ?> args) {
    Map<String, Object> actualArgs = new HashMap<String, Object>(args);
    checkTaskArgsAndCreateDefaultValues(actualArgs);

    String name = actualArgs.get(Task.TASK_NAME).toString();
    if (!GUtil.isTrue(name)) {
        throw new InvalidUserDataException("The task name must be provided.");
    }

    Class<? extends TaskInternal> type = (Class) actualArgs.get(Task.TASK_TYPE);
    Boolean generateSubclass = Boolean.valueOf(actualArgs.get(GENERATE_SUBCLASS).toString());
    TaskInternal task = createTaskObject(project, type, name, generateSubclass);

    Object dependsOnTasks = actualArgs.get(Task.TASK_DEPENDS_ON);
    if (dependsOnTasks != null) {
        task.dependsOn(dependsOnTasks);
    }
    Object description = actualArgs.get(Task.TASK_DESCRIPTION);
    if (description != null) {
        task.setDescription(description.toString());
    }
    Object group = actualArgs.get(Task.TASK_GROUP);
    if (group != null) {
        task.setGroup(group.toString());
    }
    Object action = actualArgs.get(Task.TASK_ACTION);
    if (action instanceof Action) {
        Action<? super Task> taskAction = (Action<? super Task>) action;
        task.doFirst(taskAction);
    } else if (action != null) {
        Closure closure = (Closure) action;
        task.doFirst(closure);
    }

    return task;
}
 
Example 16
Source File: AbstractArchiveTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private String maybe(String prefix, String value) {
    if (GUtil.isTrue(value)) {
        if (GUtil.isTrue(prefix)) {
            return String.format("-%s", value);
        } else {
            return value;
        }
    }
    return "";
}
 
Example 17
Source File: ArtifactResolveException.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static String format(ComponentIdentifier component, String message) {
    StringBuilder builder = new StringBuilder();
    builder.append("Could not determine artifacts for component '");
    builder.append(component.getDisplayName());
    builder.append("'");
    if (GUtil.isTrue(message)) {
        builder.append(": ");
        builder.append(message);
    }
    return builder.toString();
}
 
Example 18
Source File: GradlePluginLord.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static String getMessage(Throwable throwable) {
    String message = throwable.getMessage();
    if (!GUtil.isTrue(message)) {
        message = String.format("%s (no error message)", throwable.getClass().getName());
    }

    if (throwable.getCause() != null) {
        message += "\nCaused by: " + getMessage(throwable.getCause());
    }

    return message;
}
 
Example 19
Source File: ScalaDoc.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
protected void generate() {
    ScalaDocOptions options = getScalaDocOptions();
    if (!GUtil.isTrue(options.getDocTitle())) {
        options.setDocTitle(getTitle());
    }
    AntScalaDoc antScalaDoc = new AntScalaDoc(getAntBuilder());
    antScalaDoc.execute(getSource(), getDestinationDir(), getClasspath(), getScalaClasspath(), options);
}
 
Example 20
Source File: ProgressLogEventGenerator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private Operation(String category, String loggingHeader, long startTime) {
    this.category = category;
    this.loggingHeader = loggingHeader;
    this.startTime = startTime;
    hasLoggingHeader = GUtil.isTrue(loggingHeader);
}