I am trying to get a SNAPSHOT of a plugin that may fix our issue, but the I cannot get the library:
plugins {
kotlin("jvm") version "1.7.10"
id("maven-publish")
id("org.jetbrains.kotlin.plugin.serialization") version "1.7.10"
id("org.openapi.generator") version "6.1.0-SNAPSHOT"
}
I have already added all the necessary repositories, but still get this error:
Plugin [id: 'org.openapi.generator', version: '6.1.0-SNAPSHOT'] was not found in any of the following sources
(If I use the released 6.0.1 version, everything works fine)
Attempt 2: I have tried to get the plugin in another way.
buildscript {
repositories {
maven("https://companyserver.io/company-maven-snapshot")
// or, via Gradle Plugin Portal:
// url
}
dependencies {
classpath ("org.openapitools:openapi-generator-gradle-plugin:6.0.1")
}
}
apply(plugin="org.openapi.generator")
This seems to find the plugin, but I still get an error on the first line of:
openApiGenerate {
generatorName.set("kotlin")
inputSpec.set("$projectDir/mapi-open-api-spec.json")
modelPackage.set("mapi.generated.models")
apiPackage.set("mapi.generated.apis")
invokerPackage.set("mapi.generated.invokers")
configOptions.put("library", "multiplatform")
typeMappings.put("kotlin.Any", "kotlin.String") // change autogenerated data type of generated templates
kotlin.sourceSets["main"].kotlin.srcDir("$buildDir/generate-resources/main/src/main/kotlin")
}
The error:
.../build.gradle.kts:75:1: Unresolved reference: openApiGenerate
I am a bit stuck now, any ideas?
Related
It looks like there are two ways of declaring some Kotlin plugins using plugins DSL: Using the id() method and the kotlin() method. For example, the android plugin can be added using either id("kotlin-android") or kotlin("android"). This is also the case for kapt but not for parcelize. Why can't this be kotlin("parcelize")? Is there a reason for this discrepancy? I tried to look up relevant documentation but that didn't get me very far.
TL;DR: Take the Gradle plugin ID for Parcelize and use everything after org.jetbrains.kotlin.
plugins {
kotlin("plugin.parcelize") version "1.6.10"
}
The kotlin(...) function is part of the Gradle Kotlin DSL. It is an extension function that extends
PluginDependenciesSpec, the plugins {} block
DependencyHandler, the dependencies {} block
I'm going to focus on the Plugin extension function. Some of this answer is applicable to the Dependency extension.
kotlin(...) source code
It's generated so it's difficult to see the source code. I dug through GitHub and found it in GenerateKotlinDependencyExtensions.kt
fun PluginDependenciesSpec.kotlin(module: String): PluginDependencySpec =
id("org.jetbrains.kotlin.$module")
(edited, to show the end result)
kotlin(...) = id("org.jetbrains.kotlin.$module")
So it's nothing special. It's a Kotlin-specific shortcut for id(...). So if you
take the plugin ID for Parcelize, org.jetbrains.kotlin.plugin.parcelize,
and remove the bits that the kotlin(...) function adds (org.jetbrains.kotlin.),
you're left with plugin.parcelize.
NOTE Because this is in the plugins {} block, it's working on the Gradle plugin ID (org.jetbrains.kotlin.plugin.parcelize), not the Maven coordinates (org.jetbrains.kotlin:kotlin-gradle-plugin).
plugins {
// these two are equivalent
// id("org.jetbrains.kotlin.plugin.parcelize")
kotlin("plugin.parcelize")
}
Oh wait... it doesn't work??
FAILURE: Build failed with an exception.
* Where:
Build file '/.../build.gradle.kts' line: 3
* What went wrong:
Plugin [id: 'org.jetbrains.kotlin.plugin.parcelize'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
"Build failed with an exception" - Plugin version
That's because unlike the DependencyHandler.kotlin(...) extension, the PluginDependenciesSpec.kotlin(...) doesn't include the version. It says that in the error message: "plugin dependency must include a version number"
So to resolve it, add a version number.
plugins {
kotlin("plugin.parcelize") version "1.6.10"
}
Other Kotlin plugins
The same goes for the other Kotlin plugins. For example...
plugins {
// https://kotlinlang.org/docs/all-open-plugin.html
kotlin("plugin.allopen") version "1.6.10"
// https://kotlinlang.org/docs/all-open-plugin.html#spring-support
kotlin("plugin.spring") version "1.6.10"
// https://kotlinlang.org/docs/no-arg-plugin.html
kotlin("plugin.noarg") version "1.6.10"
// I can't find a Gradle Plugin ID for
// https://kotlinlang.org/docs/sam-with-receiver-plugin.html
// so this won't work!
// kotlin("kotlin-sam-with-receiver") version "1.6.10"
}
when migrating to gradle 7.x getting below error
* What went wrong:
An exception occurred applying plugin request [id: 'no.nils.wsdl2java', version: '0.12']
> Failed to apply plugin 'no.nils.wsdl2java'.
> Configuration with name 'compile' not found.
Below is wsdl2java added in build.gradle
plugins {
id("no.nils.wsdl2java") version "0.12"
`java-library`
}
buildscript {
dependencies {
classpath("no.nils:wsdl2java:0.12")
}
}
how to fix this?
no.nils.wsdl2java is not compatible with Gradle 7 and is no longer maintained. See the README in the project. The compile configuration has long been deprecated and was finally removed in Gradle 7.
You can use io.mateo.cxf-codegen in place of no.nils.wsdl2java. It is a Gradle port of the Maven CXF codegen plugin.
plugins {
id "io.mateo.cxf-codegen" version "1.0.1"
}
https://github.com/ciscoo/cxf-codegen-gradle
https://ciscoo.github.io/cxf-codegen-gradle/docs/current/user-guide/
Note, I am the author of the plugin.
I have a gradle Project where I have a dependency on "hudson-core 3.3.3"
compile group: 'org.eclipse.hudson', name: 'hudson-core', version: '3.3.3'
This works without a problem when using Gradle 5.6.2
When I upgrade to Gradle 6.0.1 I receive the following error:
Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
Required by:
project : > org.eclipse.hudson:hudson-core:3.3.3
project : > org.eclipse.hudson:hudson-core:3.3.3 > org.eclipse.hudson:hudson-cli:3.3.3
> Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
> inconsistent module metadata found. Descriptor: org.eclipse.hudson:hudson-remoting:3.0.4-SNAPSHOT Errors: bad version: expected='3.0.3' found='3.0.4-SNAPSHOT'
The Repository is always the same:
repositories {
mavenCentral()
maven {
url 'http://repo.jenkins-ci.org/public/'
}
}
Any Ideas why this error happens?
As said by #ToYonos, the problem is in the dependency itself.
Not perfect solutions, but 2 workarounds can be done as explained in Gradle's documentation (v6.7.1):
Exclude that transitive dependency, for example in the current Gradle versions using implementation instead of compile:
implementation('org.eclipse.hudson:hudson-core:3.3.3') {
exclude group: 'org.eclipse.hudson'
exclude module: 'hudson-remoting'
}
Override that transitive dependency version:
implementation('org.eclipse.hudson:hudson-remoting') {
version {
strictly '3.0.2' // As 3.0.3 is having the issue
}
}
In the pom.xml file of hudson-remoting 3.0.3, the version is <version>3.0.4-SNAPSHOT</version>
The issue is quite clear.
I tried with an old Gradle 4.4.1 and I am having the exact same issue. Likewise with Gradle 5.1.1 and your version, 5.6.2
I'm quite sure that if you clean your artefact cache for Gradle 5.6.2, it won't work anymore.
The error is on the repository side.
Another option is to define a repository that will download only a jar:
repositories {
mavenCentral() {
name = "Download only jar repo"
metadataSources { artifact() }
content {
// Use this repository only for org.eclipse.hudson:hudson-remoting
includeVersion("org.eclipse.hudson", "hudson-remoting", "3.0.3")
}
}
mavenCentral()
}
Also since pom is not downloaded you would have to add hudson-remoting dependencies by hand to build.gradle. But luckily for this particular case hudson-core already contains the only dependency commons-codec:commons-codec:1.4 that hudson-remoting needs, so this is not needed.
Note: the order of repositories is important, although in that case it will work either way. If you don't want to care about the order when using repositories with filter check exclusive content filtering.
I am using Gradle version 4.10.3 (need Android support) and am trying to put a test precompiled script into my buildSrc folder for use with various modules within the project. Here is my basic code setup:
//maven-deploy.gradle.kts, a custom precompiled plugin under
// buildSrc\src\main\kotlin\maven-deploy.gradle.kts
plugins {
maven
signing
}
//a test task
tasks {
register("hello") {
doLast {
println("hello")
}
}
}
//buildSrc build.gradle.kts
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}
repositories {
jcenter()
}
//main project root's build.gradle.kts
plugins {
base
kotlin("jvm") version Vof.kotlin apply false
kotlin("android") version Vof.kotlin apply false
kotlin("android.extensions") version Vof.kotlin apply false
id("kotlinx-serialization") version Vof.kotlin apply false
id("maven-deploy")
}
and I'm getting this error:
error:Plugin [id: 'maven-deploy'] was not found in any of the following sources:
- Gradle Core Plugins (not a core plugin, please see https://docs.gradle.org/4.10.3/userguide/standard_plugins.html for available core plugins)
- Plugin Repositories (plugin dependency must include a version number for this source)
Am I doing this incorrectly? I am following this guide on the Gradle website. Is this outdated? Any help is appreciated!
EDIT: I got this working by adding java-gradle-plugin (with tildes) to the buildSrc's build.gradle.kts file under plugins. Not sure if that is the correct way to go about this, however.
I'm trying to use the gradle plugin gradle-bintray-plugin.
Currently using Gradle 4.4
Following the tutorial in the github page I should add the plugin in this way:
plugins {
...
id "com.jfrog.bintray" version "1.+"
}
I'm receiving this error message and not being able to continue:
Plugin [id: 'com.jfrog.bintray', version: '1.+'] was not found in any
of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
Plugin Repositories (dynamic plugin versions are not supported) Open File
Dynamic versions were maybe authorized in the past for the plugins block (as the tutorial gives it as an example) but now it's forbidden
if (versionSelectorScheme.parseSelector(markerVersion).isDynamic()) {
result.notFound(SOURCE_NAME, "dynamic plugin versions are not supported");
return;
}
But it's not the case for the old buildscript way and the below code is working fine with Gradle 4.10
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+'
}
}
I just find out the solution. Looks like it just works specifying the exact version that you want to use.
So changing this:
plugins {
...
id "com.jfrog.bintray" version "1.+"
}
To this:
plugins {
...
id "com.jfrog.bintray" version "1.8.4" // exact version!
}
Now Works!