Class JkMavenPublication

java.lang.Object
dev.jeka.core.api.depmanagement.publication.JkMavenPublication

public final class JkMavenPublication extends Object
Publication specific information to include in POM file in order to be published of a Maven repository. This information contains :
  • The artifacts to be published (main artifact and artifacts with classifiers)
  • Information about describing the project as some public repositories require
  • Field Details

    • pomMetadata

      public final JkPomMetadata pomMetadata
      Represents the Maven metadata for a publication.
    • preActions

      public final JkRunnables preActions
      Collection of runnables that are executed before publishing to M2 repos.
    • postActions

      public final JkRunnables postActions
      Collection of runnables that are executed after publishing to M2 repos.
  • Method Details

    • of

      public static JkMavenPublication of(JkArtifactLocator artifactLocator)
      Creates a JkMavenPublication with the specified artifact locator.
      Parameters:
      artifactLocator - The artifact locator for locating the artifact files to publish.
    • of

      public static JkMavenPublication of(JkBuildable buildable)
      Creates a JkMavenPublication for a given buildable object, configuring it based on the specified buildable's properties such as artifacts, module information, version, dependencies, and repositories.
      Parameters:
      buildable - The buildable object used to configure the Maven publication.
      Returns:
      A configured JkMavenPublication instance based on the given buildable object.
    • ofPomOnly

      public static JkMavenPublication ofPomOnly()
      Creates a JkMavenPublication that can contains only a POM, and no artifacts. The typical usage is to publish BOMs.
    • copy

      public JkMavenPublication copy()
    • setPomPublicationOnly

      public JkMavenPublication setPomPublicationOnly()
      Configures the publication to include only the POM file, without any additional artifacts. This is typically used for scenarios such as creating and publishing Bill of Materials (BOM) files.
    • customizeDependencies

      public JkMavenPublication customizeDependencies(Function<JkDependencySet,JkDependencySet> modifier)
      Configure the dependencies that will be exported with the published module.
      By default, JeKa computes it from the compile and runtime dependencies. This method allows to customize these dependencies by adding/removing or changing their transitivity.
    • addManagedDependenciesInPom

      public JkMavenPublication addManagedDependenciesInPom(String moduleId, String version)
      Adds the specified moduleId and version in the dependencyManagement of the POM file to be published. This is the way to create BOM file.
    • getDependencies

      public JkDependencySet getDependencies()
      Returns the dependencies to be included in POM as transitive dependencies.
    • setModuleIdSupplier

      public JkMavenPublication setModuleIdSupplier(Supplier<JkModuleId> moduleIdSupplier)
      Sets the supplier providing the moduleId (group + artifactName) for this publication.
    • setModuleId

      public JkMavenPublication setModuleId(String moduleId)
      Sets the moduleId (group + artifactName) for this publication.
      See Also:
    • setVersionSupplier

      public JkMavenPublication setVersionSupplier(Supplier<JkVersion> versionSupplier)
      Sets the supplier providing the version of the artifacts to publish.
    • setVersion

      public JkMavenPublication setVersion(String version)
      Sets the version of the artifacts to publish.
      See Also:
    • setBomResolutionRepos

      public JkMavenPublication setBomResolutionRepos(Supplier<JkRepoSet> repoSupplier)
      Sets the supplier providing the download repositories used to resolve BOMs.
    • getModuleId

      public JkModuleId getModuleId()
      Returns the moduleId (group + artifact name) for this publication.
    • getVersion

      public JkVersion getVersion()
      Returns the version of the artifacts for this publication.
    • getDefaultSigner

      public JkFileSigner getDefaultSigner()
      Returns the default file signer for this publication.

      Normally, each publish repository can define its own signer. Conveniently we can specify a file signer for repositories which don't have.

    • setDefaultSigner

      public JkMavenPublication setDefaultSigner(JkFileSigner defaultSigner)
      Sets the default file signer to use for this publication.
      See Also:
    • getRepos

      public JkRepoSet getRepos()
      Returns the repositories where this publication will be published.
    • setRepos

      public JkMavenPublication setRepos(JkRepoSet repoSet)
      Sets the repositories where this publication will be published.
    • addRepos

      public JkMavenPublication addRepos(JkRepo... repoArgs)
      Adds the specified repositories to the publication repositories.
      See Also:
    • putArtifact

      public JkMavenPublication putArtifact(JkArtifactId artifactId, Consumer<Path> artifactFileMaker)
      Adds the specified artifact to the publication. If the artifact file is not present, this one will be created using the specified artifact file maker.
      Parameters:
      artifactId - The artifactId to add to publication.
      artifactFileMaker - A Consumer creating the artifact file at the provided location.
    • putArtifact

      public JkMavenPublication putArtifact(JkArtifactId artifactId)
      Adds the specified artifact to the publication assuming the artifact file will exist when publish() will be invoked. If the artifact file is not present, an exception will be raised.
    • putArtifactIf

      public JkMavenPublication putArtifactIf(boolean condition, JkArtifactId artifactId)
      Adds the specified artifact to the publication assuming the artifact file will exist when publish() will be invoked. If the artifact file is not present, an exception will be raised.
    • removeArtifact

      public JkMavenPublication removeArtifact(JkArtifactId artifactId)
      Removes the specified artifact from this publication.
    • removeAllArtifacts

      public JkMavenPublication removeAllArtifacts()
      Removes all published artifacts. Suitable for publishing POM only.
    • publish

      public JkMavenPublication publish()
      Publishes this publication to its defined repositories
    • publishLocal

      public JkMavenPublication publishLocal()
      Publishes this publication on the JeKa local repository
    • publishLocalM2

      public JkMavenPublication publishLocalM2()
      Publishes this publication on the M2 local repository
    • info

      public String info()
      Returns a string representation of the information for this JkMavenPublication.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • findFirstNonLocalRepo

      public JkRepo findFirstNonLocalRepo()
      Shorthand to get the first declared publication repository.
    • computeMavenPublishDependencies

      public static JkDependencySet computeMavenPublishDependencies(JkDependencySet compileDeps, JkDependencySet runtimeDeps, JkCoordinate.ConflictStrategy strategy)
      Computes the published transitive dependencies from the specified compile and runtime dependencies of the project that we are publishing artifacts for.