diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f641f071d..4835401113 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Fixed issue #1778 by removing a hash of the absolute artifact path appended to the end of the version string. That hash made artifact version different on different PCs and also breaks Gradle dependency locking. - Add the missing `org.jetbrains.kotlin.platform.type=jvm` attribute to the `intellijPlatformRuntimeClasspath` configuration manually as it's not inherited from the `runtimeClasspath`. +- Fixed `Could not generate a decorated class for type PluginArtifactRepository.` when creating a custom plugin repository. ## [2.1.0] diff --git a/api/IntelliJPlatformGradlePlugin.api b/api/IntelliJPlatformGradlePlugin.api index e7b0787b6a..771bc0a4fa 100644 --- a/api/IntelliJPlatformGradlePlugin.api +++ b/api/IntelliJPlatformGradlePlugin.api @@ -410,8 +410,15 @@ public abstract class org/jetbrains/intellij/platform/gradle/artifacts/repositor public abstract class org/jetbrains/intellij/platform/gradle/artifacts/repositories/PluginArtifactRepository : org/jetbrains/intellij/platform/gradle/artifacts/repositories/BaseArtifactRepository, org/gradle/api/artifacts/repositories/AuthenticationSupported { public fun (Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/internal/reflect/Instantiator;Ljava/lang/String;Ljava/net/URI;Lcom/jetbrains/plugin/structure/intellij/repository/CustomPluginRepositoryListingType;Z)V - public synthetic fun (Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/internal/reflect/Instantiator;Ljava/lang/String;Ljava/net/URI;Lcom/jetbrains/plugin/structure/intellij/repository/CustomPluginRepositoryListingType;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun authentication (Lorg/gradle/api/Action;)Ljava/lang/Void; + public synthetic fun authentication (Lorg/gradle/api/Action;)V + public fun credentials (Ljava/lang/Class;)Ljava/lang/Void; + public synthetic fun credentials (Ljava/lang/Class;)V public fun credentials (Ljava/lang/Class;Lorg/gradle/api/Action;)V + public fun credentials (Lorg/gradle/api/Action;)V + public fun getAuthentication ()Ljava/lang/Void; + public synthetic fun getAuthentication ()Lorg/gradle/api/artifacts/repositories/AuthenticationContainer; + public fun getCredentials ()Lorg/gradle/api/artifacts/repositories/PasswordCredentials; public fun getCredentials (Ljava/lang/Class;)Lorg/gradle/api/credentials/Credentials; public final fun getType ()Lcom/jetbrains/plugin/structure/intellij/repository/CustomPluginRepositoryListingType; } diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/artifacts/repositories/PluginArtifactRepository.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/artifacts/repositories/PluginArtifactRepository.kt index ff285282d8..f94ad39ca4 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/artifacts/repositories/PluginArtifactRepository.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/artifacts/repositories/PluginArtifactRepository.kt @@ -4,6 +4,7 @@ package org.jetbrains.intellij.platform.gradle.artifacts.repositories import org.gradle.api.Action import org.gradle.api.GradleException +import org.gradle.api.artifacts.repositories.AuthenticationContainer import org.gradle.api.artifacts.repositories.AuthenticationSupported import org.gradle.api.artifacts.repositories.PasswordCredentials import org.gradle.api.credentials.Credentials @@ -16,6 +17,7 @@ import org.jetbrains.intellij.platform.gradle.CustomPluginRepositoryType import org.jetbrains.intellij.platform.gradle.shim.Shim import java.net.URI import javax.inject.Inject +import kotlin.Throws /** * Represents a repository used for handling custom plugin repositories with authentication support. @@ -36,11 +38,13 @@ abstract class PluginArtifactRepository @Inject constructor( name: String, url: URI, val type: CustomPluginRepositoryType, - allowInsecureProtocol: Boolean = true, + allowInsecureProtocol: Boolean, ) : BaseArtifactRepository(name, url, allowInsecureProtocol), AuthenticationSupported { private val credentials = objects.property(Credentials::class) + override fun getCredentials() = getCredentials(PasswordCredentials::class.java) + /** * Retrieves the credentials of the specified type for the repository. * @@ -66,11 +70,15 @@ abstract class PluginArtifactRepository @Inject constructor( * @param action The action used to configure the credentials. */ override fun credentials(credentialsType: Class, action: Action) { - val credentialsValue = instantiateCredentials(credentialsType) + val credentialsValue = requireNotNull(instantiateCredentials(credentialsType)) action.execute(credentialsValue) credentials = credentialsValue } + override fun credentials(action: Action) = credentials(PasswordCredentials::class.java, action) + + override fun credentials(credentialsType: Class) = throw UnsupportedOperationException() + /** * Instantiates a specific type of credentials based on the provided credential type. * @@ -85,6 +93,10 @@ abstract class PluginArtifactRepository @Inject constructor( HttpHeaderCredentials::class.java.isAssignableFrom(credentialType) -> credentialType.cast(instantiator.newInstance(HttpHeaderCredentials::class.java)) else -> throw IllegalArgumentException("Unrecognized credential type: ${credentialType.getName()}") } + + override fun getAuthentication() = throw UnsupportedOperationException() + + override fun authentication(action: Action) = throw UnsupportedOperationException() } /** diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformRepositoriesHelper.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformRepositoriesHelper.kt index 9258ea0985..8477c2d453 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformRepositoriesHelper.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformRepositoriesHelper.kt @@ -96,7 +96,7 @@ class IntelliJPlatformRepositoriesHelper( repositoryType: CustomPluginRepositoryType, action: IvyRepositoryAction = {}, ): PluginArtifactRepository { - val repository = objects.newInstance(repositoryName, URI(repositoryUrl), repositoryType) + val repository = objects.newInstance(repositoryName, URI(repositoryUrl), repositoryType, true) val shimServer = shimManager.get().start(repository) flowScope.always(StopShimServerAction::class) {