org.springframework.boot.cli.compiler

Class DependencyCustomizer



  • public class DependencyCustomizer
    extends Object
    Customizer that allows dependencies to be added during compilation. Adding a dependency results in a @Grab annotation being added to the primary class is the module that's being customized.

    This class provides a fluent API for conditionally adding dependencies. For example: dependencies.ifMissing("com.corp.SomeClass").add(module).

    Author:
    Phillip Webb, Andy Wilkinson
    • Constructor Detail

      • DependencyCustomizer

        public DependencyCustomizer(groovy.lang.GroovyClassLoader loader,
                                    org.codehaus.groovy.ast.ModuleNode moduleNode,
                                    DependencyResolutionContext dependencyResolutionContext)
        Create a new DependencyCustomizer instance.
        Parameters:
        loader - the current classloader
        moduleNode - the current module
        dependencyResolutionContext - the context for dependency resolution
    • Method Detail

      • add

        public DependencyCustomizer add(String module,
                                        boolean transitive)
        Add a single dependency and, optionally, all of its dependencies. The group ID and version of the dependency are resolved from the module using the customizer's ArtifactCoordinatesResolver.
        Parameters:
        module - the module ID
        transitive - true if the transitive dependencies should also be added, otherwise false
        Returns:
        this DependencyCustomizer for continued use
      • add

        public DependencyCustomizer add(String module,
                                        String classifier,
                                        String type,
                                        boolean transitive)
        Add a single dependency with the specified classifier and type and, optionally, all of its dependencies. The group ID and version of the dependency are resolved from the module by using the customizer's ArtifactCoordinatesResolver.
        Parameters:
        module - the module ID
        classifier - the classifier, may be null
        type - the type, may be null
        transitive - true if the transitive dependencies should also be added, otherwise false
        Returns:
        this DependencyCustomizer for continued use
      • canAdd

        protected boolean canAdd()
        Strategy called to test if dependencies can be added. Subclasses override as required. Returns true by default.
        Returns:
        true if dependencies can be added, otherwise false