Class SourceBuilder

java.lang.Object
io.github.intisy.gradle.github.impl.source.SourceBuilder

public class SourceBuilder extends Object
Clones an arbitrary git URL and builds it, caching the resulting jar by commit, so a repeated request for the same commit never re-runs the build. Host-agnostic: the caller supplies the clone URL explicitly, so this class never assumes github.com or any other specific host.
Implementation Note:
GitHub carries a single ResourceSettings, hence a single repository identity, so a fresh GitHub is built per buildFromSource call (which buildFromGit(java.lang.String, java.lang.String) also goes through), scoped to the exact cloneUrl requested, rather than accepting one pre-built GitHub that could only ever be correctly configured for one repository.
  • Constructor Details

    • SourceBuilder

      public SourceBuilder(GitHubConfig config, GitHubLogger logger, File cacheDir, BuildInvoker invoker)
      Parameters:
      config - the access token and auth/cli/resilience settings used to clone/pull each checkout.
      logger - receives diagnostic output.
      cacheDir - the directory built jars are cached under, keyed by owner, repo, and resolved commit.
      invoker - runs the actual build against a checkout; injected so it can be stubbed in tests.
  • Method Details

    • buildFromGit

      public File buildFromGit(String cloneUrl, String ref) throws IOException
      Parameters:
      cloneUrl - the exact URL to clone from; any git host, not just github.com.
      ref - the branch, tag, or commit to build, or null for the remote's default branch.
      Returns:
      the cached jar for the resolved ref, built only when not already cached.
      Throws:
      IOException - if the clone, checkout, or build itself fails.
    • buildFromSource

      public File buildFromSource(String cloneUrl, String owner, String repo, String branch, String commitSha) throws IOException
      Parameters:
      cloneUrl - the exact URL to clone from; any git host, not just github.com.
      owner - an identity for the repository, used only for the checkout/cache directory and jar naming, never for URL construction.
      repo - an identity for the repository, used only for the checkout/cache directory and jar naming, never for URL construction.
      branch - the branch to clone or pull, or null for the current/default branch.
      commitSha - the commit to check out, or null to use the branch's latest commit.
      Returns:
      the cached jar for the resolved commit, built only when not already cached.
      Throws:
      IOException - if the clone/pull, checkout, or build itself fails.