mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-11 15:30:38 -05:00
Use custom dependency resolution
- Use Apache Ivy to resolve artifact URLs - Update build model with full artifact IDs - Generate Maven module metadata to support dynamic version constraints - Resolve snapshot versions and generate snapshot metadata - Add test fixtures and rewrite Gradle plugin tests - Update dependencies
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api("com.squareup.moshi:moshi:+")
|
||||
api("com.squareup.okio:okio:+")
|
||||
kapt("com.squareup.moshi:moshi-kotlin-codegen:+")
|
||||
api("com.squareup.moshi:moshi:latest.release")
|
||||
kapt("com.squareup.moshi:moshi-kotlin-codegen:latest.release")
|
||||
implementation("net.swiftzer.semver:semver:latest.release")
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# This is a Gradle generated file for dependency locking.
|
||||
# Manual edits can break the build and are not advised.
|
||||
# This file is expected to be part of source control.
|
||||
com.squareup.moshi:moshi:1.9.1
|
||||
com.squareup.okio:okio:2.4.1
|
||||
org.jetbrains.kotlin:kotlin-reflect:1.3.41
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.41
|
||||
org.jetbrains.kotlin:kotlin-stdlib:1.3.50
|
||||
com.squareup.moshi:moshi:1.9.2
|
||||
com.squareup.okio:okio:1.16.0
|
||||
net.swiftzer.semver:semver:1.1.1
|
||||
org.jetbrains.kotlin:kotlin-reflect:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib:1.3.61
|
||||
org.jetbrains:annotations:13.0
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# This is a Gradle generated file for dependency locking.
|
||||
# Manual edits can break the build and are not advised.
|
||||
# This file is expected to be part of source control.
|
||||
com.squareup.moshi:moshi:1.9.1
|
||||
com.squareup.okio:okio:2.4.1
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50
|
||||
org.jetbrains.kotlin:kotlin-stdlib:1.3.50
|
||||
org.jetbrains:annotations:13.0
|
||||
com.squareup.moshi:moshi:1.9.2
|
||||
com.squareup.okio:okio:1.16.0
|
||||
net.swiftzer.semver:semver:1.1.1
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# This is a Gradle generated file for dependency locking.
|
||||
# Manual edits can break the build and are not advised.
|
||||
# This file is expected to be part of source control.
|
||||
com.squareup.moshi:moshi:1.9.1
|
||||
com.squareup.okio:okio:2.4.1
|
||||
org.jetbrains.kotlin:kotlin-reflect:1.3.41
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.41
|
||||
org.jetbrains.kotlin:kotlin-stdlib:1.3.50
|
||||
com.squareup.moshi:moshi:1.9.2
|
||||
com.squareup.okio:okio:1.16.0
|
||||
net.swiftzer.semver:semver:1.1.1
|
||||
org.jetbrains.kotlin:kotlin-reflect:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib:1.3.61
|
||||
org.jetbrains:annotations:13.0
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# This is a Gradle generated file for dependency locking.
|
||||
# Manual edits can break the build and are not advised.
|
||||
# This file is expected to be part of source control.
|
||||
com.squareup.moshi:moshi:1.9.1
|
||||
com.squareup.okio:okio:2.4.1
|
||||
org.jetbrains.kotlin:kotlin-reflect:1.3.41
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.41
|
||||
org.jetbrains.kotlin:kotlin-stdlib:1.3.50
|
||||
com.squareup.moshi:moshi:1.9.2
|
||||
com.squareup.okio:okio:1.16.0
|
||||
net.swiftzer.semver:semver:1.1.1
|
||||
org.jetbrains.kotlin:kotlin-reflect:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61
|
||||
org.jetbrains.kotlin:kotlin-stdlib:1.3.61
|
||||
org.jetbrains:annotations:13.0
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package org.nixos.gradle2nix
|
||||
|
||||
import com.squareup.moshi.JsonClass
|
||||
import net.swiftzer.semver.SemVer
|
||||
import java.io.Serializable
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class DefaultBuild(
|
||||
override val gradle: DefaultGradle,
|
||||
override val pluginDependencies: DefaultDependencies,
|
||||
override val pluginDependencies: List<DefaultArtifact>,
|
||||
override val rootProject: DefaultProject,
|
||||
override val includedBuilds: List<DefaultIncludedBuild>
|
||||
) : Build, Serializable {
|
||||
constructor(model: Build) : this(
|
||||
DefaultGradle(model.gradle),
|
||||
DefaultDependencies(model.pluginDependencies),
|
||||
model.pluginDependencies.map(::DefaultArtifact),
|
||||
DefaultProject(model.rootProject),
|
||||
model.includedBuilds.map { DefaultIncludedBuild(it) }
|
||||
model.includedBuilds.map(::DefaultIncludedBuild)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -52,8 +54,8 @@ data class DefaultProject(
|
||||
override val version: String,
|
||||
override val path: String,
|
||||
override val projectDir: String,
|
||||
override val buildscriptDependencies: DefaultDependencies,
|
||||
override val projectDependencies: DefaultDependencies,
|
||||
override val buildscriptDependencies: List<DefaultArtifact>,
|
||||
override val projectDependencies: List<DefaultArtifact>,
|
||||
override val children: List<DefaultProject>
|
||||
) : Project, Serializable {
|
||||
constructor(model: Project) : this(
|
||||
@@ -61,59 +63,75 @@ data class DefaultProject(
|
||||
model.version,
|
||||
model.path,
|
||||
model.projectDir,
|
||||
DefaultDependencies(model.buildscriptDependencies),
|
||||
DefaultDependencies(model.projectDependencies),
|
||||
model.buildscriptDependencies.map(::DefaultArtifact),
|
||||
model.projectDependencies.map(::DefaultArtifact),
|
||||
model.children.map { DefaultProject(it) }
|
||||
)
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class DefaultDependencies(
|
||||
override val repositories: DefaultRepositories,
|
||||
override val artifacts: List<DefaultArtifact>
|
||||
) : Dependencies, Serializable {
|
||||
constructor(model: Dependencies) : this(
|
||||
DefaultRepositories(model.repositories),
|
||||
model.artifacts.map { DefaultArtifact(it) }
|
||||
)
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class DefaultRepositories(
|
||||
override val maven: List<DefaultMaven>
|
||||
) : Repositories, Serializable {
|
||||
constructor(model: Repositories) : this(
|
||||
model.maven.map { DefaultMaven(it) }
|
||||
)
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class DefaultMaven(
|
||||
override val urls: List<String>
|
||||
) : Maven, Serializable {
|
||||
constructor(model: Maven) : this(
|
||||
model.urls.toList()
|
||||
)
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class DefaultArtifact(
|
||||
override val groupId: String,
|
||||
override val artifactId: String,
|
||||
override val version: String,
|
||||
override val classifier: String,
|
||||
override val extension: String,
|
||||
override val id: DefaultArtifactIdentifier,
|
||||
override val name: String,
|
||||
override val path: String,
|
||||
override val timestamp: String? = null,
|
||||
override val build: Int? = null,
|
||||
override val urls: List<String>,
|
||||
override val sha256: String
|
||||
) : Artifact, Comparable<DefaultArtifact>, Serializable {
|
||||
constructor(model: Artifact) : this(
|
||||
model.groupId,
|
||||
model.artifactId,
|
||||
model.version,
|
||||
model.classifier,
|
||||
model.extension,
|
||||
DefaultArtifactIdentifier(model.id),
|
||||
model.name,
|
||||
model.path,
|
||||
model.timestamp,
|
||||
model.build,
|
||||
model.urls,
|
||||
model.sha256
|
||||
)
|
||||
|
||||
override fun toString() = "$groupId:$artifactId:$version:$classifier:$extension"
|
||||
override fun compareTo(other: DefaultArtifact): Int = toString().compareTo(other.toString())
|
||||
override fun toString() = id.toString()
|
||||
override fun compareTo(other: DefaultArtifact): Int = id.compareTo(other.id)
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class DefaultArtifactIdentifier(
|
||||
override val group: String,
|
||||
override val name: String,
|
||||
override val version: String,
|
||||
override val type: String,
|
||||
override val extension: String = type,
|
||||
override val classifier: String? = null
|
||||
) : ArtifactIdentifier, Comparable<DefaultArtifactIdentifier>, Serializable {
|
||||
constructor(model: ArtifactIdentifier) : this(
|
||||
model.group,
|
||||
model.name,
|
||||
model.version,
|
||||
model.type,
|
||||
model.extension,
|
||||
model.classifier
|
||||
)
|
||||
|
||||
@delegate:Transient
|
||||
private val semver: SemVer? by lazy {
|
||||
try {
|
||||
SemVer.parse(version)
|
||||
} catch (_: IllegalArgumentException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun compareTo(other: DefaultArtifactIdentifier): Int {
|
||||
return group.compareTo(other.group).takeUnless { it == 0 }
|
||||
?: name.compareTo(other.name).takeUnless { it == 0 }
|
||||
?: other.semver?.let { semver?.compareTo(it) }?.takeUnless { it == 0 }
|
||||
?: type.compareTo(other.type).takeUnless { it == 0 }
|
||||
?: other.classifier?.let { classifier?.compareTo(it) }?.takeUnless { it == 0 }
|
||||
?: 0
|
||||
}
|
||||
|
||||
override fun toString(): String = buildString {
|
||||
append("$group:$name:$version")
|
||||
if (classifier != null) append(":$classifier")
|
||||
append("@$type")
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package org.nixos.gradle2nix
|
||||
|
||||
interface Build {
|
||||
val gradle: Gradle
|
||||
val pluginDependencies: Dependencies
|
||||
val pluginDependencies: List<Artifact>
|
||||
val rootProject: Project
|
||||
val includedBuilds: List<IncludedBuild>
|
||||
}
|
||||
@@ -25,29 +25,26 @@ interface Project {
|
||||
val version: String
|
||||
val path: String
|
||||
val projectDir: String
|
||||
val buildscriptDependencies: Dependencies
|
||||
val projectDependencies: Dependencies
|
||||
val buildscriptDependencies: List<Artifact>
|
||||
val projectDependencies: List<Artifact>
|
||||
val children: List<Project>
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
val repositories: Repositories
|
||||
val artifacts: List<Artifact>
|
||||
}
|
||||
|
||||
interface Repositories {
|
||||
val maven: List<Maven>
|
||||
}
|
||||
|
||||
interface Maven {
|
||||
val urls: List<String>
|
||||
}
|
||||
|
||||
interface Artifact {
|
||||
val groupId: String
|
||||
val artifactId: String
|
||||
val version: String
|
||||
val classifier: String
|
||||
val extension: String
|
||||
val id: ArtifactIdentifier
|
||||
val name: String
|
||||
val path: String
|
||||
val timestamp: String?
|
||||
val build: Int?
|
||||
val urls: List<String>
|
||||
val sha256: String
|
||||
}
|
||||
|
||||
interface ArtifactIdentifier {
|
||||
val group: String
|
||||
val name: String
|
||||
val version: String
|
||||
val type: String
|
||||
val extension: String
|
||||
val classifier: String?
|
||||
}
|
||||
Reference in New Issue
Block a user