Skip to content

Commit

Permalink
Attempt to fix snapshot publishing for Maven
Browse files Browse the repository at this point in the history
  • Loading branch information
melix committed Oct 8, 2021
1 parent 5e560c8 commit f02f2f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ public abstract class GeneratePluginDescriptor extends MavenTask {
@Internal
public abstract DirectoryProperty getCommonRepository();

@Internal
public abstract DirectoryProperty getLocalRepository();

public GeneratePluginDescriptor() {
getArguments().set(Arrays.asList("-q", "org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor"));
}

@Override
protected void prepareSpec(JavaExecSpec spec) {
spec.systemProperty("common.repo.uri", getCommonRepository().getAsFile().get().toURI().toString());
spec.systemProperty("seed.repo.uri", getLocalRepository().get().getAsFile().toURI().toASCIIString());
}

@Override
Expand Down
13 changes: 7 additions & 6 deletions native-maven-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ publishing {
}
}

val localRepositoryDir = project.layout.buildDirectory.dir("maven-seeded-repo")

tasks {
generatePluginDescriptor {
commonRepository.set(repoDirectory)
localRepository.set(localRepositoryDir)
}
}

Expand All @@ -111,19 +114,17 @@ val prepareSeedingProject = tasks.register<Sync>("prepareSeedingProject") {
outputs.upToDateWhen { false }
}

val localRepository = project.layout.buildDirectory.dir("maven-seeded-repo")

val prepareMavenLocalRepo = tasks.register<MavenTask>("prepareMavenLocalRepo") {
dependsOn(prepareSeedingProject)
projectDirectory.set(prepareSeedingProject.map { seedingDir.get() })
settingsFile.set(layout.projectDirectory.file("config/settings.xml"))
pomFile.set(seedingDir.map { it.file("pom.xml") })
mavenEmbedderClasspath.from(configurations.mavenEmbedder)
outputDirectory.set(localRepository)
outputDirectory.set(localRepositoryDir)
arguments.set(listOf(
"-q",
"-Dproject.build.directory=${File(temporaryDir, "target")}",
"-Dmaven.repo.local=${localRepository.get().asFile.absolutePath}",
"-Dmaven.repo.local=${localRepositoryDir.get().asFile.absolutePath}",
"-Djunit.jupiter.version=${libs.versions.junitJupiter.get()}",
"-Dnative.maven.plugin.version=${libs.versions.nativeBuildTools.get()}",
"-Djunit.platform.native.version=${libs.versions.nativeBuildTools.get()}",
Expand All @@ -136,7 +137,7 @@ val prepareMavenLocalRepo = tasks.register<MavenTask>("prepareMavenLocalRepo") {
)

doFirst {
GFileUtils.deleteDirectory(localRepository.get().asFile)
GFileUtils.deleteDirectory(localRepositoryDir.get().asFile)
}
}

Expand All @@ -154,7 +155,7 @@ tasks {
systemProperty("native.maven.plugin.version", libs.versions.nativeBuildTools.get())
systemProperty("junit.platform.native.version", libs.versions.nativeBuildTools.get())
systemProperty("common.repo.uri", repoDirectory.get().asFile.toURI().toASCIIString())
systemProperty("seed.repo.uri", localRepository.get().asFile.toURI().toASCIIString())
systemProperty("seed.repo.uri", localRepositoryDir.get().asFile.toURI().toASCIIString())
systemProperty("maven.classpath", configurations.mavenEmbedder.get().asPath)
systemProperty("maven.settings", layout.projectDirectory.file("config/settings.xml").asFile.absolutePath)
systemProperty("java.executable", javaLauncher.get().executablePath.asFile.absolutePath)
Expand Down

0 comments on commit f02f2f4

Please sign in to comment.