Class PublishExtension

java.lang.Object
io.github.intisy.gradle.github.extension.PublishExtension

public class PublishExtension extends Object
Extension for configuring the publishGithub task.

All fields are optional and fall back to auto-detection when null:

  • owner / repo — parsed from the git remote origin URL
  • version — taken from project.version
  • jar — the shadow/fat JAR in build/libs/, or the first regular JAR

Single-JAR shorthand (backward-compatible):

 publishGithub {
     owner   = "my-org"
     repo    = "my-repo"
     version = "2.0.0"
     jar     = file("build/libs/my-lib.jar")
 }
 

Multi-JAR with classifiers:

 publishGithub {
     artifacts {
         artifact { classifier = "";    jar = file("build/libs/my-lib.jar") }
         artifact { classifier = "api"; jar = file("build/libs/my-lib-api.jar") }
         artifact { classifier = "fat"; jar = file("build/libs/my-lib-fat.jar") }
     }
 }
 
  • Constructor Details

    • PublishExtension

      public PublishExtension()
  • Method Details

    • setOwner

      public void setOwner(String owner)
      Override the GitHub repository owner. When null (default) the owner is auto-detected from the git remote origin.
      Parameters:
      owner - the repository owner
    • getOwner

      public String getOwner()
      Returns:
      the overridden owner, or null to auto-detect
    • setRepo

      public void setRepo(String repo)
      Override the GitHub repository name. When null (default) the repo name is auto-detected from the git remote origin.
      Parameters:
      repo - the repository name
    • getRepo

      public String getRepo()
      Returns:
      the overridden repo name, or null to auto-detect
    • setVersion

      public void setVersion(String version)
      Override the release version tag. When null (default) the version is taken from project.version.
      Parameters:
      version - the version tag to use for the GitHub release
    • getVersion

      public String getVersion()
      Returns:
      the overridden version, or null to use project.version
    • setTag

      public void setTag(String tag)
      Override the git tag pushed to GitHub for this release. When null (default) the tag equals getVersion() (after fallback to project.version). Use this to prefix or format the tag independently of the version string, e.g. tag = "v1.0" while version = "1.0".
      Parameters:
      tag - the tag name, e.g. "v2.0.0"
    • getTag

      public String getTag()
      Returns:
      the overridden tag, or null to use the resolved version string
    • setReleaseName

      public void setReleaseName(String releaseName)
      Override the human-readable release title shown on GitHub. When null (default) the title equals the resolved tag. Use this to set a descriptive name, e.g. releaseName = "Release 1.0".
      Parameters:
      releaseName - the release title
    • getReleaseName

      public String getReleaseName()
      Returns:
      the overridden release title, or null to use the resolved tag
    • setJar

      public void setJar(File jar)
      Override the single JAR file to upload. Ignored when getArtifacts() is non-empty. When null (default) the task auto-selects the shadow/fat JAR from build/libs/, or falls back to the first regular JAR found there.
      Parameters:
      jar - the JAR file to upload
    • getJar

      public File getJar()
      Returns:
      the overridden JAR file, or null to auto-select
    • getArtifacts

      public List<ArtifactEntry> getArtifacts()
      Returns the list of explicit artifacts to upload. When non-empty this list takes precedence over the single getJar() field.
      Returns:
      mutable list of ArtifactEntry instances
    • artifact

      public void artifact(org.gradle.api.Action<? super ArtifactEntry> action)
      Adds a single artifact entry, configured by the given Gradle action.
      Parameters:
      action - action that receives and configures an ArtifactEntry
    • artifact

      public void artifact(groovy.lang.Closure<?> closure)
      Adds a single artifact entry, configured by the given Groovy closure.
      Parameters:
      closure - closure that configures an ArtifactEntry
    • artifacts

      public void artifacts(org.gradle.api.Action<? super PublishExtension> action)
      Opens a configuration block in which multiple artifact(org.gradle.api.Action<? super io.github.intisy.gradle.github.extension.ArtifactEntry>) calls can be made. This is a convenience wrapper so users can write artifacts { artifact { } }.
      Parameters:
      action - action that calls artifact(org.gradle.api.Action<? super io.github.intisy.gradle.github.extension.ArtifactEntry>) one or more times on this extension
    • artifacts

      public void artifacts(groovy.lang.Closure<?> closure)
      Opens a Groovy-DSL configuration block for multiple artifact entries.
      Parameters:
      closure - closure in which artifact { } calls are made