Search in sources :

Example 41 with TreeFormatter

use of org.gradle.internal.logging.text.TreeFormatter in project gradle by gradle.

the class DefaultVariantTransformRegistry method registerTransform.

@Override
public <T extends TransformParameters> void registerTransform(Class<? extends TransformAction<T>> actionType, Action<? super TransformSpec<T>> registrationAction) {
    try {
        Class<T> parameterType = isolationScheme.parameterTypeFor(actionType);
        T parameterObject = parameterType == null ? null : parametersInstantiationScheme.withServices(services).instantiator().newInstance(parameterType);
        TypedRegistration<T> registration = Cast.uncheckedNonnullCast(instantiatorFactory.decorateLenient().newInstance(TypedRegistration.class, parameterObject, immutableAttributesFactory));
        registrationAction.execute(registration);
        register(registration, actionType, parameterObject);
    } catch (VariantTransformConfigurationException e) {
        throw e;
    } catch (Exception e) {
        TreeFormatter formatter = new TreeFormatter();
        formatter.node("Could not register artifact transform ");
        formatter.appendType(actionType);
        formatter.append(".");
        throw new VariantTransformConfigurationException(formatter.toString(), e);
    }
}
Also used : TreeFormatter(org.gradle.internal.logging.text.TreeFormatter) VariantTransformConfigurationException(org.gradle.api.artifacts.transform.VariantTransformConfigurationException) VariantTransformConfigurationException(org.gradle.api.artifacts.transform.VariantTransformConfigurationException)

Example 42 with TreeFormatter

use of org.gradle.internal.logging.text.TreeFormatter in project gradle by gradle.

the class SimpleGeneratedJavaClassCompiler method throwCompilationError.

private static void throwCompilationError(List<Diagnostic<? extends JavaFileObject>> diagnostics) {
    TreeFormatter formatter = new TreeFormatter();
    formatter.node("Unable to compile generated sources");
    formatter.startChildren();
    for (Diagnostic<? extends JavaFileObject> d : diagnostics) {
        JavaFileObject source = d.getSource();
        String srcFile = source == null ? "unknown" : new File(source.toUri()).getName();
        String diagLine = String.format("File %s, line: %d, %s", srcFile, d.getLineNumber(), d.getMessage(null));
        formatter.node(diagLine);
    }
    formatter.endChildren();
    throw new GeneratedClassCompilationException(formatter.toString());
}
Also used : JavaFileObject(javax.tools.JavaFileObject) TreeFormatter(org.gradle.internal.logging.text.TreeFormatter) File(java.io.File)

Example 43 with TreeFormatter

use of org.gradle.internal.logging.text.TreeFormatter in project gradle by gradle.

the class IncompatibleConfigurationSelectionException method generateMessage.

private static String generateMessage(AttributeContainerInternal fromConfigurationAttributes, AttributeMatcher attributeMatcher, ComponentResolveMetadata targetComponent, String targetConfiguration, boolean variantAware, AttributeDescriber describer) {
    TreeFormatter formatter = new TreeFormatter();
    formatter.node((variantAware ? "Variant '" : "Configuration '") + targetConfiguration + "' in " + style(StyledTextOutput.Style.Info, targetComponent.getId().getDisplayName()) + " does not match the consumer attributes");
    formatConfiguration(formatter, targetComponent, fromConfigurationAttributes, attributeMatcher, targetComponent.getConfiguration(targetConfiguration), variantAware, false, describer);
    return formatter.toString();
}
Also used : TreeFormatter(org.gradle.internal.logging.text.TreeFormatter)

Example 44 with TreeFormatter

use of org.gradle.internal.logging.text.TreeFormatter in project gradle by gradle.

the class DependencyInsightReporter method collectErrorMessages.

private static String collectErrorMessages(Throwable failure, Set<Throwable> alreadyReportedErrors) {
    TreeFormatter formatter = new TreeFormatter();
    collectErrorMessages(failure, formatter, alreadyReportedErrors);
    return formatter.toString();
}
Also used : TreeFormatter(org.gradle.internal.logging.text.TreeFormatter)

Example 45 with TreeFormatter

use of org.gradle.internal.logging.text.TreeFormatter in project gradle by gradle.

the class VersionCatalogProblem method reportInto.

public void reportInto(TreeFormatter output) {
    TreeFormatter formatter = new TreeFormatter();
    formatter.node("Problem: In " + uncapitalize(getWhere()) + ", " + maybeAppendDot(uncapitalize(getShortDescription())));
    getWhy().ifPresent(reason -> {
        formatter.blankLine();
        formatter.node("Reason: " + capitalize(maybeAppendDot(reason)));
    });
    List<Solution> possibleSolutions = getPossibleSolutions();
    int solutionCount = possibleSolutions.size();
    if (solutionCount > 0) {
        formatter.blankLine();
        if (solutionCount == 1) {
            formatter.node("Possible solution: " + capitalize(maybeAppendDot(possibleSolutions.get(0).getShortDescription())));
        } else {
            formatter.node("Possible solutions");
            formatter.startNumberedChildren();
            possibleSolutions.forEach(solution -> formatter.node(capitalize(maybeAppendDot(solution.getShortDescription()))));
            formatter.endChildren();
        }
    }
    getDocumentationLink().ifPresent(docLink -> {
        formatter.blankLine();
        formatter.node("Please refer to ").append(docLink).append(" for more details about this problem.");
    });
    output.node(formatter.toString());
}
Also used : TreeFormatter(org.gradle.internal.logging.text.TreeFormatter) Solution(org.gradle.problems.Solution)

Aggregations

TreeFormatter (org.gradle.internal.logging.text.TreeFormatter)46 ImmutableList (com.google.common.collect.ImmutableList)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Nullable (javax.annotation.Nullable)3 GradleException (org.gradle.api.GradleException)3 VariantTransformConfigurationException (org.gradle.api.artifacts.transform.VariantTransformConfigurationException)3 ResolvedVariant (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant)3 Lists (com.google.common.collect.Lists)2 File (java.io.File)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 InvalidUserDataException (org.gradle.api.InvalidUserDataException)2 ArtifactTransformRegistration (org.gradle.api.internal.artifacts.ArtifactTransformRegistration)2 ConfigurationMetadata (org.gradle.internal.component.model.ConfigurationMetadata)2 ClassGenerationException (org.gradle.internal.instantiation.ClassGenerationException)2 Solution (org.gradle.problems.Solution)2 ImmutableMap (com.google.common.collect.ImmutableMap)1