Package com.konfigyr.gradle
Class ArtifactoryService
java.lang.Object
com.konfigyr.gradle.ArtifactoryService
- All Implemented Interfaces:
org.gradle.api.services.BuildService<@NonNull com.konfigyr.gradle.ArtifactoryService.Parameters>
public abstract class ArtifactoryService
extends Object
implements org.gradle.api.services.BuildService<@NonNull com.konfigyr.gradle.ArtifactoryService.Parameters>
Gradle
BuildService for interacting with the Konfigyr Artifactory REST API.- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.konfigyr.artifactory.ArtifactMetadatacreateArtifactMetadata(com.konfigyr.artifactory.Artifact artifact, File metadata) Creates anArtifactMetadatainstances for the givenArtifactby loading the serialized configuration metadata from the givenFile.@NonNull com.konfigyr.artifactory.ManifestDownload the manifest for the current Gradle project that matches the Konfigyr service.@NonNull com.konfigyr.artifactory.ReleasegetRelease(@NonNull com.konfigyr.artifactory.Artifact artifact) Retrieves the release state for the uploadedArtifactMetadata.List<com.konfigyr.artifactory.PropertyDescriptor> parsePropertyDescriptors(Iterable<? extends com.konfigyr.ArtifactMetadataResource> metadata, Iterable<? extends File> classpath) Attempts to parse the given collection ofArtifactMetadataResources into a list ofPropertyDescriptors.voidpublish(@NonNull Collection<? extends com.konfigyr.artifactory.Artifact> artifacts) Attempts to publish a newManifestfor the current Gradle project.List<com.konfigyr.artifactory.ArtifactMetadata> readArtifactMetadata(File manifest, File directory) ReadsArtifactMetadatafrom the given directory that are present in the artifact manifest list.voidupload(@NonNull com.konfigyr.artifactory.ArtifactMetadata metadata) Starts the upload process for the givenArtifactMetadata.writeArtifactMetadata(com.konfigyr.artifactory.ArtifactMetadata metadata, File targetDirectory) Writes the givenArtifactMetadatato the given directory.voidwritePropertyDescriptorMetadata(Iterable<? extends com.konfigyr.ArtifactMetadataResource> metadata, Iterable<? extends File> classpath, File target) Generates and writesPropertyDescriptormetadata extracted from the given collection ofArtifactMetadataResources to the given targetFile.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.services.BuildService
getParameters
-
Constructor Details
-
ArtifactoryService
public ArtifactoryService()Creates a newArtifactoryServiceinstance.
-
-
Method Details
-
parsePropertyDescriptors
public List<com.konfigyr.artifactory.PropertyDescriptor> parsePropertyDescriptors(Iterable<? extends com.konfigyr.ArtifactMetadataResource> metadata, Iterable<? extends File> classpath) Attempts to parse the given collection ofArtifactMetadataResources into a list ofPropertyDescriptors.This method would create a
ClassLoaderthat can resolve the Java types to construct theJsonSchemafor each property using the specified collection of classpath files, usually jars.- Parameters:
metadata- the collection of Spring Boot configuration metadata resources, cannot be null.classpath- the collection of files used to create aClassLoader, cannot be null.- Returns:
- list of parsed
PropertyDescriptor, never null.
-
writePropertyDescriptorMetadata
public void writePropertyDescriptorMetadata(Iterable<? extends com.konfigyr.ArtifactMetadataResource> metadata, Iterable<? extends File> classpath, File target) Generates and writesPropertyDescriptormetadata extracted from the given collection ofArtifactMetadataResources to the given targetFile.This method would create a
ClassLoaderthat can resolve the Java types to construct theJsonSchemafor each property using the specified collection of classpath files, usually jars.- Parameters:
metadata- the collection of Spring Boot configuration metadata resources, cannot be null.classpath- the collection of files used to create aClassLoader, cannot be null.target- the target file where the metadata should be written, cannot be null.
-
createArtifactMetadata
public com.konfigyr.artifactory.ArtifactMetadata createArtifactMetadata(com.konfigyr.artifactory.Artifact artifact, File metadata) Creates anArtifactMetadatainstances for the givenArtifactby loading the serialized configuration metadata from the givenFile.- Parameters:
artifact- the artifact for which the metadata is created, cannot be null.metadata- the file containing the serialized configuration metadata, cannot be null.- Returns:
- the artifact metadata that should be published, never null.
-
writeArtifactMetadata
public String writeArtifactMetadata(com.konfigyr.artifactory.ArtifactMetadata metadata, File targetDirectory) Writes the givenArtifactMetadatato the given directory. The file that would be created, or updated, would be using the following file name format:${groupId}-${artifactId}-${version}.json- Parameters:
metadata- artifact metadata to be writtentargetDirectory- the target directory where the metadata should be written- Returns:
- the name of the file that was written, never null.
-
readArtifactMetadata
public List<com.konfigyr.artifactory.ArtifactMetadata> readArtifactMetadata(File manifest, File directory) throws IOException ReadsArtifactMetadatafrom the given directory that are present in the artifact manifest list.This method should collect all the filenames in the artifact manifest file and then attempt to deserialize the metadata files from the given output directory.
- Parameters:
manifest- the manifest file that contains the list of metadata files to be uploadeddirectory- the directory where the metadata files are located- Returns:
- list of artifact metadata, never null.
- Throws:
IOException- if an I/O error occurs while reading the metadata files.
-
getManifest
public @NonNull com.konfigyr.artifactory.Manifest getManifest()Download the manifest for the current Gradle project that matches the Konfigyr service.This manifest is used to check if this plugin should upload a new state of configuration metadata for the Konfigyr service.
- Returns:
- the current manifest, never null.
-
getRelease
public @NonNull com.konfigyr.artifactory.Release getRelease(@NonNull com.konfigyr.artifactory.Artifact artifact) Retrieves the release state for the uploadedArtifactMetadata.- Parameters:
artifact- the artifact for which release is retrieved, cannot be null.- Returns:
- the release state, never null.
-
publish
Attempts to publish a newManifestfor the current Gradle project.- Parameters:
artifacts- the artifacts to be added to the new manifest, cannot be null.
-
upload
public void upload(@NonNull com.konfigyr.artifactory.ArtifactMetadata metadata) Starts the upload process for the givenArtifactMetadata. This method would post the metadata to the Konfigyr Artifactory and then poll the service until the release state is either successfully released or failed.- Parameters:
metadata- the artifact metadata to upload, cannot be null.- Throws:
org.gradle.api.artifacts.PublishException- if the poll process timed out or the artifact metadata upload fails.
-