Caleb Cushing
10/07/2024, 9:57 PM* Where:
Precompiled script plugin '/home/xeno/IdeaProjects/gradle-convention/buildSrc/src/main/kotlin/our.javalibrary.gradle.kts' line: 1
* What went wrong:
An exception occurred applying plugin request [id: 'com.xenoterracide.gradle.convention.publish']
> Failed to apply plugin 'com.xenoterracide.gradle.convention.publish'.
> Cannot query the value of extension 'repositoryHost' property 'namespace' because it has no value available.
public interface RepositoryHostExtension {
Property<String> getNamespace();
default URI cloneUrl() {
return this.getHost().get().resolve(String.join("/", getNamespace().get(), getName().get(), getExtension().get()));
}
so, how can I apply the plugin to set up the extension so the values go into the plugin
pom.scm(scm -> {
scm.getConnection().set(repo.cloneUrl().toString());
entire plugin
https://github.com/xenoterracide/gradle-convention/blob/main/module/publish/src/ma[…]/com/xenoterracide/gradle/convention/publish/PublishPlugin.javaVampire
10/07/2024, 10:38 PMcloneUrl() should probably not eagerly evaluate those properties, but zip them together and return a Provider<URI>, so that it can be wired and evaluated lazyCaleb Cushing
10/07/2024, 10:41 PMVampire
10/07/2024, 10:42 PMhow should I get one in the extensionI don't understand the question
also, never used zip
providerOne.zip(providerTwo) { valueOfProvider1, valueOfProvider2 -> combinedValue }Caleb Cushing
10/07/2024, 10:43 PMpackageUrl well, at least not a base one...Caleb Cushing
10/07/2024, 10:44 PMVampire
10/07/2024, 10:44 PMpackageUrl is, first time you mention itCaleb Cushing
10/07/2024, 10:44 PMdefault URI packageUrl() {
return URI.create("<https://maven.pkg.github.com>").resolve(
String.join("/", this.getNamespace().get(), this.getName().get())
);
}Caleb Cushing
10/07/2024, 10:45 PMCaleb Cushing
10/07/2024, 10:45 PMVampire
10/07/2024, 10:47 PMI assume you're suggesting I use the properties as providers
Property is a subclass of Provider, so yes, that is how it is supposed to be used.
You wire properties and providers together combine them and so on and optimally only ever at execution time use get().
Whenever you use get() at configuration time you at least introduce a race condition.Caleb Cushing
10/07/2024, 10:52 PMvar publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.repositories(pubRepo -> {
pubRepo.maven(maven -> {
maven.setName("gh");
maven.setUrl(repo.packageUrl());
maven.credentials(PasswordCredentials.class);
});
});
maybe there's no hope for setting the repo url that way?Caleb Cushing
10/07/2024, 10:53 PMsetUrl(Object can also take a providerCaleb Cushing
10/07/2024, 11:09 PMCaleb Cushing
10/07/2024, 11:12 PMCaleb Cushing
10/07/2024, 11:12 PMCaleb Cushing
10/07/2024, 11:12 PMCaleb Cushing
10/07/2024, 11:23 PMObjectCaleb Cushing
10/07/2024, 11:32 PMCaleb Cushing
10/07/2024, 11:33 PMVampire
10/08/2024, 1:28 AMunless theiirc it is toString-lazy, so set it to an object that evaluates the value oncecan also take a providersetUrl(Object
toString() is called the first time
wait, zip mutates the 2nd argument?No,
Provider cannot be mutated.Caleb Cushing
10/08/2024, 2:03 AMCaleb Cushing
10/08/2024, 2:04 AMCaleb Cushing
10/08/2024, 2:05 AMCaleb Cushing
10/08/2024, 2:05 AMVampire
10/08/2024, 8:35 AMsetUrl can properly handle Provider, yes. At least from quickly clicking on the method and looking at the codeCaleb Cushing
10/08/2024, 12:38 PMCaleb Cushing
10/08/2024, 12:39 PMVampire
10/08/2024, 12:49 PMProject.uri(Object),
which says it is evaluated like Project.file(Object) but accepting URLs with other schemes than file:,
which says that Provider is supported,
so, ... 🙂Caleb Cushing
10/08/2024, 12:49 PMVampire
10/08/2024, 12:50 PMProject.file(Object)Caleb Cushing
10/08/2024, 12:52 PMVampire
10/08/2024, 12:53 PMCaleb Cushing
10/08/2024, 12:55 PM