Corrections for 1.20 support.
This commit is contained in:
@@ -411,7 +411,7 @@ export class ForgeGradle3Adapter extends ForgeResolver {
|
|||||||
|
|
||||||
const targetLocalPath = join(
|
const targetLocalPath = join(
|
||||||
libDir,
|
libDir,
|
||||||
MavenUtil.mavenComponentsToPath(entry.group, entry.artifact, entry.version, _classifier)
|
MavenUtil.mavenComponentsAsNormalizedPath(entry.group, entry.artifact, entry.version, _classifier)
|
||||||
)
|
)
|
||||||
|
|
||||||
targetLocations.push(targetLocalPath)
|
targetLocations.push(targetLocalPath)
|
||||||
|
|||||||
@@ -20,21 +20,21 @@ export abstract class BaseMavenRepo extends BaseFileStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getArtifactById(mavenIdentifier: string, extension?: string): string {
|
public getArtifactById(mavenIdentifier: string, extension?: string): string {
|
||||||
return resolve(this.containerDirectory, MavenUtil.mavenIdentifierToString(mavenIdentifier, extension))
|
return resolve(this.containerDirectory, MavenUtil.mavenIdentifierAsPath(mavenIdentifier, extension))
|
||||||
}
|
}
|
||||||
|
|
||||||
public getArtifactByComponents(
|
public getArtifactByComponents(
|
||||||
group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
||||||
): string {
|
): string {
|
||||||
return resolve(this.containerDirectory,
|
return resolve(this.containerDirectory,
|
||||||
MavenUtil.mavenComponentsToString(group, artifact, version, classifier, extension))
|
MavenUtil.mavenComponentsAsPath(group, artifact, version, classifier, extension))
|
||||||
}
|
}
|
||||||
|
|
||||||
public getArtifactUrlByComponents(
|
public getArtifactUrlByComponents(
|
||||||
baseURL: string, group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
baseURL: string, group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
||||||
): string {
|
): string {
|
||||||
return new URL(join(this.relativeRoot,
|
return new URL(join(this.relativeRoot,
|
||||||
MavenUtil.mavenComponentsToString(group, artifact, version, classifier, extension)), baseURL).toString()
|
MavenUtil.mavenComponentsAsPath(group, artifact, version, classifier, extension)), baseURL).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
public async artifactExists(path: string): Promise<boolean> {
|
public async artifactExists(path: string): Promise<boolean> {
|
||||||
@@ -42,14 +42,14 @@ export abstract class BaseMavenRepo extends BaseFileStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async downloadArtifactById(url: string, mavenIdentifier: string, extension?: string): Promise<void> {
|
public async downloadArtifactById(url: string, mavenIdentifier: string, extension?: string): Promise<void> {
|
||||||
return this.downloadArtifactBase(url, MavenUtil.mavenIdentifierToString(mavenIdentifier, extension) as string)
|
return this.downloadArtifactBase(url, MavenUtil.mavenIdentifierAsPath(mavenIdentifier, extension) as string)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async downloadArtifactByComponents(
|
public async downloadArtifactByComponents(
|
||||||
url: string, group: string, artifact: string, version: string, classifier?: string, extension?: string
|
url: string, group: string, artifact: string, version: string, classifier?: string, extension?: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this.downloadArtifactBase(url,
|
return this.downloadArtifactBase(url,
|
||||||
MavenUtil.mavenComponentsToString(group, artifact, version, classifier, extension))
|
MavenUtil.mavenComponentsAsPath(group, artifact, version, classifier, extension))
|
||||||
}
|
}
|
||||||
|
|
||||||
private async downloadArtifactBase(url: string, relative: string): Promise<void> {
|
private async downloadArtifactBase(url: string, relative: string): Promise<void> {
|
||||||
@@ -75,14 +75,14 @@ export abstract class BaseMavenRepo extends BaseFileStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async headArtifactById(url: string, mavenIdentifier: string, extension?: string): Promise<boolean> {
|
public async headArtifactById(url: string, mavenIdentifier: string, extension?: string): Promise<boolean> {
|
||||||
return this.headArtifactBase(url, MavenUtil.mavenIdentifierToString(mavenIdentifier, extension) as string)
|
return this.headArtifactBase(url, MavenUtil.mavenIdentifierAsPath(mavenIdentifier, extension) as string)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async headArtifactByComponents(
|
public async headArtifactByComponents(
|
||||||
url: string, group: string, artifact: string, version: string, classifier?: string, extension?: string
|
url: string, group: string, artifact: string, version: string, classifier?: string, extension?: string
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
return this.headArtifactBase(url,
|
return this.headArtifactBase(url,
|
||||||
MavenUtil.mavenComponentsToString(group, artifact, version, classifier, extension))
|
MavenUtil.mavenComponentsAsPath(group, artifact, version, classifier, extension))
|
||||||
}
|
}
|
||||||
|
|
||||||
private async headArtifactBase(url: string, relative: string): Promise<boolean> {
|
private async headArtifactBase(url: string, relative: string): Promise<boolean> {
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
import { normalize } from 'path'
|
import { normalize } from 'path'
|
||||||
import { URL } from 'url'
|
import { URL } from 'url'
|
||||||
|
|
||||||
|
export interface MavenComponents {
|
||||||
|
group: string
|
||||||
|
artifact: string
|
||||||
|
version: string
|
||||||
|
classifier?: string
|
||||||
|
extension: string
|
||||||
|
}
|
||||||
|
|
||||||
export class MavenUtil {
|
export class MavenUtil {
|
||||||
|
|
||||||
public static readonly ID_REGEX = /(.+):(.+):([^@]+)()(?:@{1}(.+)$)?/
|
public static readonly ID_REGEX = /([^@:]+):([^@:]+):?([^@:]+)?:?(?:([^@:]+))?:?(?:@{1}([^@:]+))?/
|
||||||
public static readonly ID_REGEX_WITH_CLASSIFIER = /(.+):(.+):(?:([^@]+)(?:-([a-zA-Z]+)))(?:@{1}(.+)$)?/
|
|
||||||
|
|
||||||
public static mavenComponentsToIdentifier(
|
public static mavenComponentsToIdentifier(
|
||||||
group: string,
|
group: string,
|
||||||
@@ -16,35 +23,39 @@ export class MavenUtil {
|
|||||||
return `${group}:${artifact}:${version}${classifier != null ? `:${classifier}` : ''}${extension != null ? `@${extension}` : ''}`
|
return `${group}:${artifact}:${version}${classifier != null ? `:${classifier}` : ''}${extension != null ? `@${extension}` : ''}`
|
||||||
}
|
}
|
||||||
|
|
||||||
public static isMavenIdentifier(id: string): boolean {
|
public static mavenComponentsToExtensionlessIdentifier(
|
||||||
return MavenUtil.ID_REGEX.test(id) || MavenUtil.ID_REGEX_WITH_CLASSIFIER.test(id)
|
group: string,
|
||||||
|
artifact: string,
|
||||||
|
version: string,
|
||||||
|
classifier?: string
|
||||||
|
): string {
|
||||||
|
return MavenUtil.mavenComponentsToIdentifier(group, artifact, version, classifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getMavenComponents(id: string, extension = 'jar'): {
|
public static mavenComponentsToVersionlessIdentifier(
|
||||||
group: string
|
group: string,
|
||||||
artifact: string
|
artifact: string
|
||||||
version: string
|
): string {
|
||||||
classifier?: string
|
return `${group}:${artifact}`
|
||||||
extension: string
|
}
|
||||||
} {
|
|
||||||
|
public static isMavenIdentifier(id: string): boolean {
|
||||||
|
return MavenUtil.ID_REGEX.test(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getMavenComponents(id: string, extension = 'jar'): MavenComponents {
|
||||||
if (!MavenUtil.isMavenIdentifier(id)) {
|
if (!MavenUtil.isMavenIdentifier(id)) {
|
||||||
throw new Error('Id is not a maven identifier.')
|
throw new Error('Id is not a maven identifier.')
|
||||||
}
|
}
|
||||||
|
|
||||||
let result
|
const result = MavenUtil.ID_REGEX.exec(id)
|
||||||
|
|
||||||
if (MavenUtil.ID_REGEX_WITH_CLASSIFIER.test(id)) {
|
|
||||||
result = MavenUtil.ID_REGEX_WITH_CLASSIFIER.exec(id)
|
|
||||||
} else {
|
|
||||||
result = MavenUtil.ID_REGEX.exec(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return {
|
return {
|
||||||
group: result[1],
|
group: result[1],
|
||||||
artifact: result[2],
|
artifact: result[2],
|
||||||
version: result[3],
|
version: result[3],
|
||||||
classifier: result[4] || undefined,
|
classifier: result[4],
|
||||||
extension: result[5] || extension
|
extension: result[5] || extension
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,38 +63,38 @@ export class MavenUtil {
|
|||||||
throw new Error('Failed to process maven data.')
|
throw new Error('Failed to process maven data.')
|
||||||
}
|
}
|
||||||
|
|
||||||
public static mavenIdentifierToString(id: string, extension = 'jar'): string {
|
public static mavenIdentifierAsPath(id: string, extension = 'jar'): string {
|
||||||
const tmp = MavenUtil.getMavenComponents(id, extension)
|
const tmp = MavenUtil.getMavenComponents(id, extension)
|
||||||
|
|
||||||
return MavenUtil.mavenComponentsToString(
|
return MavenUtil.mavenComponentsAsPath(
|
||||||
tmp.group, tmp.artifact, tmp.version, tmp.classifier, tmp.extension
|
tmp.group, tmp.artifact, tmp.version, tmp.classifier, tmp.extension
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static mavenComponentsToString(
|
public static mavenComponentsAsPath(
|
||||||
group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
||||||
): string {
|
): string {
|
||||||
return `${group.replace(/\./g, '/').replace(/:/g, '/')}/${artifact}/${version}/${artifact}-${version}${classifier != null ? `-${classifier}` : ''}.${extension}`
|
return `${group.replace(/\./g, '/')}/${artifact}/${version}/${artifact}-${version}${classifier != null ? `-${classifier}` : ''}.${extension}`
|
||||||
}
|
}
|
||||||
|
|
||||||
public static mavenIdentifierToUrl(id: string, extension = 'jar'): URL {
|
public static mavenIdentifierToUrl(id: string, extension = 'jar'): URL {
|
||||||
return new URL(MavenUtil.mavenIdentifierToString(id, extension))
|
return new URL(MavenUtil.mavenIdentifierAsPath(id, extension))
|
||||||
}
|
}
|
||||||
|
|
||||||
public static mavenComponentsToUrl(
|
public static mavenComponentsToUrl(
|
||||||
group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
||||||
): URL {
|
): URL {
|
||||||
return new URL(MavenUtil.mavenComponentsToString(group, artifact, version, classifier, extension))
|
return new URL(MavenUtil.mavenComponentsAsPath(group, artifact, version, classifier, extension))
|
||||||
}
|
}
|
||||||
|
|
||||||
public static mavenIdentifierToPath(id: string, extension = 'jar'): string {
|
public static mavenIdentifierToPath(id: string, extension = 'jar'): string {
|
||||||
return normalize(MavenUtil.mavenIdentifierToString(id, extension))
|
return normalize(MavenUtil.mavenIdentifierAsPath(id, extension))
|
||||||
}
|
}
|
||||||
|
|
||||||
public static mavenComponentsToPath(
|
public static mavenComponentsAsNormalizedPath(
|
||||||
group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
|
||||||
): string {
|
): string {
|
||||||
return normalize(MavenUtil.mavenComponentsToString(group, artifact, version, classifier, extension))
|
return normalize(MavenUtil.mavenComponentsAsPath(group, artifact, version, classifier, extension))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,14 +4,14 @@ export class MinecraftVersion {
|
|||||||
|
|
||||||
private readonly major: number
|
private readonly major: number
|
||||||
private readonly minor: number
|
private readonly minor: number
|
||||||
private readonly revision: number
|
private readonly revision: number | undefined
|
||||||
|
|
||||||
constructor(version: string) {
|
constructor(version: string) {
|
||||||
const res = MinecraftVersion.MINECRAFT_VERSION_REGEX.exec(version)
|
const res = MinecraftVersion.MINECRAFT_VERSION_REGEX.exec(version)
|
||||||
if(res != null) {
|
if(res != null) {
|
||||||
this.major = Number(res[1])
|
this.major = Number(res[1])
|
||||||
this.minor = Number(res[2])
|
this.minor = Number(res[2])
|
||||||
this.revision = Number(res[3]) ?? undefined
|
this.revision = res[3] != null ? Number(res[3]) : undefined
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`${version} is not a valid minecraft version!`)
|
throw new Error(`${version} is not a valid minecraft version!`)
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,8 @@ export class MinecraftVersion {
|
|||||||
|
|
||||||
public getMajor(): number { return this.major }
|
public getMajor(): number { return this.major }
|
||||||
public getMinor(): number { return this.minor }
|
public getMinor(): number { return this.minor }
|
||||||
public getRevision(): number|undefined { return this.revision }
|
public getRevision(): number | undefined { return this.revision }
|
||||||
|
|
||||||
public toString(): string { return `${this.major}.${this.minor}${this.revision? '.'+this.revision:''}`}
|
public toString(): string { return `${this.major}.${this.minor}${this.revision != null ? '.' + this.revision : ''}`}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ export class VersionUtil {
|
|||||||
'latest'
|
'latest'
|
||||||
]
|
]
|
||||||
|
|
||||||
public static readonly MINECRAFT_VERSION_REGEX = /(\d+).(\d+).?(\d+)?/
|
public static readonly MINECRAFT_VERSION_REGEX = /(\d+).(\d+).(\d+)?/
|
||||||
|
|
||||||
public static isVersionAcceptable(version: MinecraftVersion, acceptable: number[]): boolean {
|
public static isVersionAcceptable(version: MinecraftVersion, acceptable: number[]): boolean {
|
||||||
if (version.getMajor() === 1) {
|
if (version.getMajor() === 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user