Class MvnRepoLookup

java.lang.Object
org.jdrupes.builder.core.AbstractProvider
org.jdrupes.builder.mvnrepo.MvnRepoLookup
All Implemented Interfaces:
ResourceProvider

public class MvnRepoLookup extends AbstractProvider implements ResourceProvider

Depending on the request, this provider provides two types of resources.

  1. The artifacts to be resolved as Resources<MvnRepoDependency>. The artifacts to be resolved are those added with resolve(java.lang.String...). Note that the result also includes the MvnRepoBoms.

  2. The CompilationResources<LibraryJarFile> or RuntimeResources<LibraryJarFile> (depending on the request) that result from resolving the artifacts to be resolved. The resources returned implement the additional marker interface MvnRepoJarFile.

  • Constructor Details

    • MvnRepoLookup

      public MvnRepoLookup()
      Instantiates a new mvn repo lookup.
  • Method Details

    • snapshotRepository

      Sets the Maven snapshot repository URI.
      Parameters:
      uri - the snapshot repository URI
      Returns:
      the mvn repo lookup
    • snapshotRepository

      Returns the snapshot repository. Defaults to https://central.sonatype.com/repository/maven-snapshots/.
      Returns:
      the uri
    • bom

      public MvnRepoLookup bom(String... coordinates)
      Add a bill of materials. The coordinates are resolved as a dependency with scope import which is added to the dependencyManagement section.
      Parameters:
      coordinates - the coordinates
      Returns:
      the mvn repo lookup
    • resolve

      public MvnRepoLookup resolve(String... coordinates)
      Add artifacts, specified by their coordinates (groupId:artifactId:version) as resources.
      Parameters:
      coordinates - the coordinates
      Returns:
      the mvn repo lookup
    • resolve

      public MvnRepoLookup resolve(Stream<? extends MvnRepoResource> resources)
      Add artifacts. The method handles MvnRepoBoms correctly.
      Parameters:
      resources - the resources
      Returns:
      the mvn repo lookup
    • probe

      public MvnRepoLookup probe()

      Failing to resolve the dependencies normally results in a BuildException, because the requested artifacts are assumed to be required for the built.

      By invoking this method the provider enters probe mode and returns an empty result stream instead of throwing an exception if the resolution fails.

      Returns:
      the mvn repo lookup
    • downloadSources

      public MvnRepoLookup downloadSources(boolean enable)
      Whether to also download the sources. Defaults to true.
      Parameters:
      enable - the enable
      Returns:
      the mvn repo lookup
    • downloadJavadoc

      public MvnRepoLookup downloadJavadoc(boolean enable)
      Whether to also download the javadoc. Defaults to true.
      Parameters:
      enable - the enable
      Returns:
      the mvn repo lookup
    • doProvide

      protected <T extends Resource> Stream<T> doProvide(ResourceRequest<T> requested)
      Provide.
      Specified by:
      doProvide in class AbstractProvider
      Type Parameters:
      T - the generic type
      Parameters:
      requested - the requested resources
      Returns:
      the stream