Skip to content

Commit

Permalink
Fixed `Could not generate a decorated class for type PluginArtifactRe…
Browse files Browse the repository at this point in the history
…pository.` when creating a custom plugin repository.
  • Loading branch information
hsz committed Oct 9, 2024
1 parent 1763cd2 commit 215e202
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
9 changes: 8 additions & 1 deletion api/IntelliJPlatformGradlePlugin.api
Original file line number Diff line number Diff line change
Expand Up @@ -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 <init> (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 <init> (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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
*
Expand All @@ -66,11 +70,15 @@ abstract class PluginArtifactRepository @Inject constructor(
* @param action The action used to configure the credentials.
*/
override fun <T : Credentials?> credentials(credentialsType: Class<T>, action: Action<in T>) {
val credentialsValue = instantiateCredentials(credentialsType)
val credentialsValue = requireNotNull(instantiateCredentials(credentialsType))
action.execute(credentialsValue)
credentials = credentialsValue
}

override fun credentials(action: Action<in PasswordCredentials>) = credentials(PasswordCredentials::class.java, action)

override fun credentials(credentialsType: Class<out Credentials?>) = throw UnsupportedOperationException()

/**
* Instantiates a specific type of credentials based on the provided credential type.
*
Expand All @@ -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<in AuthenticationContainer>) = throw UnsupportedOperationException()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class IntelliJPlatformRepositoriesHelper(
repositoryType: CustomPluginRepositoryType,
action: IvyRepositoryAction = {},
): PluginArtifactRepository {
val repository = objects.newInstance<PluginArtifactRepository>(repositoryName, URI(repositoryUrl), repositoryType)
val repository = objects.newInstance<PluginArtifactRepository>(repositoryName, URI(repositoryUrl), repositoryType, true)
val shimServer = shimManager.get().start(repository)

flowScope.always(StopShimServerAction::class) {
Expand Down

0 comments on commit 215e202

Please sign in to comment.