Skip to content

Commit

Permalink
Added maven metadata fetching for latest versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
xtrm-en committed Sep 5, 2024
1 parent 50ce52f commit d42b312
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.polyfrost.oneconfig.loader.base.Capabilities;
import org.polyfrost.oneconfig.loader.base.LoaderBase;
import org.polyfrost.oneconfig.loader.stage1.dependency.ArtifactManager;
import org.polyfrost.oneconfig.loader.stage1.dependency.impl.maven.MavenArtifactDependency;
import org.polyfrost.oneconfig.loader.stage1.dependency.impl.maven.MavenArtifactManager;
import org.polyfrost.oneconfig.loader.stage1.dependency.model.Artifact;
import org.polyfrost.oneconfig.loader.stage1.dependency.model.ArtifactDeclaration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@
import java.nio.file.Path;
import java.nio.file.Paths;

import lombok.AllArgsConstructor;
import lombok.Data;

import lombok.Getter;

import org.polyfrost.oneconfig.loader.stage1.dependency.model.ArtifactDeclaration;

/**
* @author xtrm
* @since 1.1.0
*/
@AllArgsConstructor
public @Data class MavenArtifactDeclaration implements ArtifactDeclaration {
@Getter
private final String groupId;
@Getter
private final String artifactId;
@Getter
private final String version;
private String actualVersion;
private final String classifier;
@Getter
private final String extension;

@Override
public String getVersion() {
if (actualVersion == null) {
return version;
}
return actualVersion;
}

@Override
public String getDeclaration() {
return String.format(
"%s:%s:%s",
groupId, artifactId, version
groupId, artifactId, actualVersion
) + (classifier == null ? "" : ":" + classifier)
+ (extension == null ? "" : "@" + extension);
}
Expand All @@ -40,14 +40,14 @@ public Path getRelativePath() {
return Paths.get(
groupId.replace('.', '/'),
artifactId,
version,
actualVersion,
getFileName()
);
}

@Override
public String getFileName() {
return artifactId + "-" + version
return artifactId + "-" + actualVersion
+ (classifier == null ? "" : "-" + classifier)
+ "." + (extension == null ? "jar" : extension);
}
Expand Down
Loading

0 comments on commit d42b312

Please sign in to comment.