Slackbot
03/17/2023, 2:45 PMmelix
03/17/2023, 2:46 PMio.micronaut.application
, io.micronaut.lbrary
, io.micronaut.docker
, etcmelix
03/17/2023, 2:46 PMmelix
03/17/2023, 2:47 PMmelix
03/17/2023, 2:47 PMwithPluginClasspath()
.melix
03/17/2023, 2:48 PMmelix
03/17/2023, 2:48 PMmelix
03/17/2023, 2:49 PMmelix
03/17/2023, 2:50 PMpublishAllPublicationsToBuildRepository
2. patch the build under test settings file to add a plugin repository pointing to that build repositorymelix
03/17/2023, 2:50 PMmelix
03/17/2023, 2:50 PMmelix
03/17/2023, 2:51 PMpublishAllPublicationsToBuildRepository
will always publish, even if there were no changes to the projectmelix
03/17/2023, 2:51 PMmelix
03/17/2023, 2:52 PMmelix
03/17/2023, 2:53 PMmelix
03/17/2023, 2:53 PMVampire
03/17/2023, 3:01 PMmelix
03/17/2023, 3:02 PMmelix
03/17/2023, 3:02 PMVampire
03/17/2023, 3:06 PMmelix
03/17/2023, 3:11 PMChris Lee
03/17/2023, 3:13 PMmelix
03/17/2023, 3:13 PMwithPluginClasspath
, you get a different classloader setup, and this alone breaks testsChris Lee
03/17/2023, 3:14 PMmelix
03/17/2023, 3:14 PMChris Lee
03/17/2023, 3:17 PMmelix
03/17/2023, 3:17 PMmelix
03/17/2023, 3:18 PMbuildscript { ... }
instead of plugins
?Chris Lee
03/17/2023, 3:18 PMmelix
03/17/2023, 3:19 PMChris Lee
03/17/2023, 3:19 PMmelix
03/17/2023, 3:23 PMmelix
03/17/2023, 3:23 PMVampire
03/17/2023, 3:24 PMmelix
03/17/2023, 3:24 PMmelix
03/17/2023, 3:25 PM<info organisation="io.micronaut.gradle" module="micronaut-minimal-plugin" revision="4.0.0-SNAPSHOT" status="integration" publication="20230317162336"/>
melix
03/17/2023, 3:25 PMVampire
03/17/2023, 3:25 PMVampire
03/17/2023, 3:25 PMmelix
03/17/2023, 3:25 PMChris Lee
03/17/2023, 3:26 PMmelix
03/17/2023, 3:30 PMpublications.withType(IvyPublication).configureEach {
descriptor.withXml {
asNode().info.@publication = "20230101000000"
}
}
melix
03/17/2023, 3:42 PMmelix
03/17/2023, 3:43 PMmelix
03/17/2023, 3:44 PMmelix
03/17/2023, 3:52 PMmelix
03/17/2023, 3:52 PM› :warning:cannot serialize object of type org.gradle.api.internal.artifacts.repositories.DefaultIvyArtifactRepository:clipboard:, a subtype of org.gradle.api.artifacts.repositories.ArtifactRepository:clipboard:, as these are not supported with the configuration cache. ?
melix
03/17/2023, 3:53 PMmelix
03/17/2023, 3:53 PMVampire
03/17/2023, 4:01 PMmelix
03/17/2023, 4:03 PMmelix
03/17/2023, 4:03 PMmelix
03/17/2023, 4:03 PMmelix
03/17/2023, 4:03 PMVampire
03/17/2023, 4:07 PMmelix
03/17/2023, 4:08 PMVampire
03/17/2023, 4:08 PMmelix
03/17/2023, 4:08 PMmelix
03/17/2023, 4:23 PMmelix
03/17/2023, 4:23 PMMultiple publications with coordinates 'io.micronaut.gradlemicronaut minimal plugin4.0.0-DUMMY' are published to repository 'project'. The publications 'localComponentPluginPluginMarkerMaven' in project ':micronaut-minimal-plugin' and 'localPluginMaven' in project ':micronaut-minimal-plugin' will overwrite each other!
melix
03/17/2023, 4:23 PMmelix
03/17/2023, 4:23 PMVampire
03/17/2023, 4:31 PMmelix
03/17/2023, 4:38 PMmelix
03/17/2023, 4:38 PMmelix
03/17/2023, 4:40 PMproject.afterEvaluate {
groupId = pub.groupId
artifactId = pub.artifactId
}
melix
03/17/2023, 4:51 PMmelix
03/17/2023, 4:51 PMmelix
03/17/2023, 4:55 PMalias = true
Vampire
03/17/2023, 4:59 PMVampire
03/17/2023, 4:59 PMmelix
03/17/2023, 5:00 PMVampire
03/17/2023, 5:06 PMmelix
03/17/2023, 5:09 PMmelix
03/17/2023, 5:09 PMAdam
03/17/2023, 5:10 PMVampire
03/17/2023, 5:12 PMmelix
03/17/2023, 5:13 PMAdam
03/17/2023, 5:14 PM./m2/repository
directory - all artifacts get published to a project-local dirVampire
03/17/2023, 5:15 PMmavenLocal
that Maven rapes itself.
if you have a didicated one for such tests it is probably ok.Adam
03/17/2023, 5:16 PMmelix
03/17/2023, 5:16 PMAdam
03/17/2023, 5:17 PMmelix
03/17/2023, 5:18 PMVampire
03/17/2023, 5:18 PMmavenLocal
and have a post-processing or followup task that copies your exact artifacts out into a new directory. 🙂melix
03/17/2023, 5:19 PMmelix
03/17/2023, 5:19 PMAdam
03/17/2023, 5:21 PM$rootDir/build/test-maven-repo
:)Vampire
03/17/2023, 5:25 PMAdam
03/17/2023, 5:26 PMmelix
03/17/2023, 5:31 PMbuildscript.dependencies.components.all {
throw new GradleException("Eh!")
if (id.version.endsWith("-DUMMY")) {
throw new GradleException("\$id")
changing = true
}
}
doesn't throw in settings.gradle
...Adam
03/17/2023, 5:32 PMVampire
03/17/2023, 7:01 PMVampire
03/17/2023, 7:01 PMVampire
03/17/2023, 7:10 PMDefaultMavenLocalArtifactRepository
?
Could have been so easy:
publishing {
repositories {
mavenLocal {
name = "foo"
setUrl(layout.buildDirectory.dir("foo-repo"))
}
}
}
melix
03/17/2023, 7:11 PMAdam
03/17/2023, 7:13 PMmelix
03/17/2023, 7:14 PMSNAPSHOT
, was painfulmelix
03/17/2023, 7:14 PMfile
repository, so the artifacts are not cachedAdam
03/17/2023, 7:15 PMpublishing {
publications.create<MavenPublication>("test") {
this.version = "CUSTOM"
}
}
melix
03/17/2023, 7:29 PMAdam
03/17/2023, 8:35 PMAdam
03/27/2023, 1:45 PMbuild/tmp/.maven-publish-test
2. for each MavenPublication, create a task that creates a file containing the MavenPublication’s artifacts (MavenPublication.getArtifacts()
), and compute an md5 checksum, and save it to disk
3. in any PublishToMavenRepository
task that publishes to build/tmp/.maven-publish-test
, again compute the checksum of the current artifacts, and inside an onlyIf {}
compare it against the checksums computed in step 2 (which won’t exist the first time round)
4. after the PublishToMavenRepository
task that publishes to build/test-publish-temp
has completed,
• sync the files from build/tmp/.maven-publish-test
to build/maven-publish-test
,
• re-compute the file-based checksums,
• delete the contents of build/tmp/.maven-publish-test
(to prevent aggregating SNAPSHOT spam)
And then in test projects, define the repo (the path can also be injected via a env/system/gradle property). It’s best to limit the group so Gradle doesn’t try to resolve a ‘live’ version from another repository.
repositories {
maven("/path/to/project/build/maven-publish-test/") {
mavenContent {
includeGroup("my.group")
}
}
}
The result is that even with a SNAPSHOT version the onlyIf {}
check will block publishing until the artifacts change, It doesn’t matter if Gradle appends a timestamp to the publication.
This also works across subprojects, given a couple of consumer/provider Configurations.
dependencies {
mavenPublishTest(projects.core)
mavenPublishTest(projects.plugins.base)
}
tasks.test {
dependsOn(tasks.updateMavenTestRepo)
environment(
"MAVEN_PUBLISH_TEST_REPO" to mavenPublishTest.testMavenRepo.asFile.get().invariantSeparatorsPath
)
}
I’ll publish and share the repo soonAdam
03/28/2023, 2:12 PM