After the migration from jcenter to maven-central repository, like
//from
repositories {
jcenter()
}
//to
repositories {
mavenCentral()
}
I got:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':my-module:compileJava'.
...
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':my-module:compileClasspath'.
...
project :my-module > org.junit.jupiter:junit-jupiter-api:5.7.1 > org.junit:junit-bom:5.7.1
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.junit.jupiter:junit-jupiter-params:5.7.1.
Caused by: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.MetaDataParseException: Could not parse module metadata https://everon.jfrog.io/everon/libs-release/org/junit/jupiter/junit-jupiter-params/5.7.1/junit-jupiter-params-5.7.1.module
How to fix it?
After the change, Gradle misused the metadata file and the solution would be to explicitly declare artifacts metadata sources:
repositories {
maven {
metadataSources {
mavenPom() //use maven pom
artifact() //look directly for the artifact
ignoreGradleMetadataRedirection() //it fixes the issue actually
}
}
}
See https://docs.gradle.org/current/userguide/dependency_management.html#sec:supported_metadata_sources for more
Related
I have a problem with resolving local dependency. I have a lib that I want to provide across my projects. So I've published it locally. The build.gradle looks like this:
...
plugins {
...
id("maven-publish")
...
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "com.wintermute.chatserver.core"
artifactId = "core"
version = "1.0"
from(components["java"])
}
}
}
In the other project, which is requiring the dependency I've added in the build.gradle this:
repositories {
mavenLocal()
mavenCentral()
}
But when I try to resolve the dependencies gradle complains about not resolvable dependency:
Could not resolve com.wintermute.chatserver.core:core:1.0.
Required by:
project :
It was successfull one time, then I've deleted the cache and since this it does not work anymore. Why is that? What I am doing wrong?
I am a pretty fresh in Gradle. I'm trying to build up a project Kotlin code with Gradle.
I have spent some time to learn that by following these instructions: https://kotlinlang.org/docs/reference/using-gradle.html
And so far, I have not succeeded in it and got some errors.
My build.gradle is shown below:
group = "kotlin"
version = "1.0-SNAPSHOT"
buildscript {
ext.kotlin_version = '1.2.50'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "kotlin"
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
And I got the following error
org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':classpath'.
....
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.50.
When trying to include the Oracle JDBC driver (ojdbc7.jar) in my JRuby Gradle project, I always get a "cannot load Java class oracle.jdbc.OracleDriver" at runtime. Here's my basic build.gradle:
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:[1.2.2,2.0)'
classpath 'com.github.jruby-gradle:jruby-gradle-plugin:%%VERSION%%'
classpath 'com.github.jruby-gradle:jruby-gradle-jar-plugin:1.3.3'
}
}
apply plugin: "com.github.jruby-gradle.jar"
repositories { jcenter() }
dependencies {
jrubyJar "rubygems:colorize:0.7.7+"
jrubyJar 'org.slf4j:slf4j-simple:1.7.12'
}
jrubyJar {
initScript "${projectDir}/entrypoint.rb"
}
And here's my entrypoint.rb:
require 'java'
java_import 'java.sql.DriverManager'
java_import 'oracle.jdbc.OracleDriver'
puts "Hello world"
Output of build + run steps:
frank$ ./gradlew jrubyJar
:prepareJRubyJar UP-TO-DATE
:jrubyJar UP-TO-DATE
BUILD SUCCESSFUL
Total time: 2.027 secs
frank$ java -jar build/libs/plsql-unit-tester-jruby.jar
NameError: cannot load Java class oracle.jdbc.OracleDriver
...
Following the advice in How to use oracle jdbc driver in gradle project, I tried adding this to my build.gradle:
dependencies {
compile files('lib/ojdbc7.jar')
}
But this causes an error at compile time:
Could not find method compile() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I then tried to add it as a runtime dependency as suggested in How to add OJDBC6.jar in build.gradle file?:
dependencies {
runtime files('lib/odjbc7.jar')
}
But this again raises a compile error:
Could not find method runtime() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
So I'm stuck - how can I correctly add odjbc7.jar (or any external jar) as a dependency in my JRuby Gradle project?
A workaround for the problem is to install the Oracle JDBC driver into the local Maven repository and add the mavenLocal() as repository and the driver jar as an additional dependency.
The driver can be installed like so:
mvn install:install-file -Dfile=ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.2 -Dpackaging=jar
The final build.gradle looks like this:
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.github.jruby-gradle:jruby-gradle-plugin:1.3.3'
classpath 'com.github.jruby-gradle:jruby-gradle-jar-plugin:1.3.3'
}
}
apply plugin: "com.github.jruby-gradle.jar"
repositories {
mavenLocal()
jcenter()
}
dependencies {
jrubyJar "rubygems:colorize:0.7.7+"
jrubyJar 'org.slf4j:slf4j-simple:1.7.12'
jrubyJar 'com.oracle:ojdbc7:12.1.0.2'
}
jrubyJar {
initScript "${projectDir}/entrypoint.rb"
}
I have a java library which I want to upload to jfrog artifactory. But no matter what I do I get a null pointer exception:
Execution failed for task :util-lib-java:artifactoryPublish.
java.lang.NullPointerException (no error message)
It worked perfectly fine on the 3rd October this year, and failed on the 10th. We then referenced version: classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.*" and what I can see jfrog updated their library from 4.4.5 to 4.47 between these dates. But now when I'm trying with various versions I only get the error specified above.
My build.gradle looks like:
buildscript {
repositories {
jcenter()
maven {
url "${artifactory_contextUrl}/plugins-release"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
dependencies {
//Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.2"
}
}
apply plugin: 'java'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
repositories
{
mavenCentral()
maven {
url "${artifactory_contextUrl}/libs-release-local"
}
maven {
url "${artifactory_contextUrl}/libs-snapshot-local"
}
}
// Android project is also using this library, so java version cannot be 1.8
sourceCompatibility = 1.7
targetCompatibility = 1.7
publishing {
publications {
mavenJava(MavenPublication) {
// Set the base name of the artifacts
artifactId 'util-lib-java'
groupId group
version version
from components.java
}
}
}
artifactory {
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
if ( project.version.endsWith('-SNAPSHOT') ) {
repoKey = 'libs-snapshot-local'
} else {
repoKey = 'libs-release-local'
}
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
and the top-level build.gradle looks like:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
version = '1.0'
group = 'com.companyname'
repositories {
jcenter()
}
}
We're using gradle-2.14.1-bin.zip wrapper.
Stacktrace from build:
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':util-lib-java:artifactoryPublish'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: java.lang.NullPointerException
at org.jfrog.gradle.plugin.artifactory.task.BuildInfoBaseTask.prepareAndDeploy(BuildInfoBaseTask.java:346)
at org.jfrog.gradle.plugin.artifactory.task.BuildInfoBaseTask.collectProjectBuildInfo(BuildInfoBaseTask.java:132)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
What am I missing here? This issue don't help me
Should be noted for folks stumbling across this issue that it should be resolved with the latest release: 4.4.10
https://github.com/JFrogDev/build-info/issues/101
For publishing you have to remove this lines in you gradle.properties or local.properties:
org.gradle.configureondemand=true
org.gradle.daemon=true
Also you have to add this in the main build.gradle file.
allprojects {
apply plugin: 'com.jfrog.artifactory'
...
}
After that the publishing should be work.
My demo has a Maven-Dependencies ,it contains an ojdbc6.jar.
I want to build a runnable jar with Gradle.
When i run:gradle build in command line.It works well,and create a Test.jar
In build/libs folder.when i run with:java -jar Test.jar. it shows: Unable to load class: oracle.jdbc.OracleDriverclass not found.
Any one can help me out?Thanks a lot!
Caused by: java.lang.ClassNotFoundException: Unable to load class: oracle.jdbc.OracleDriver from ClassLoader:org.springframework.boot.loader.LaunchedURLClass
ssLoader:org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$TcclSafeAggregatedClassLoader#60cbbfcd
at org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:56)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:268)
... 46 common frames omitted
Caused by: java.lang.ClassNotFoundException: Could not load requested class : oracle.jdbc.OracleDriver
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:230)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$TcclSafeAggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:456)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:38)
I have resolved it!
Download the ojdbc7.jar in F:\
please visit oracle.com to download!
Run "cmd",then input below command:
mvn install:install-file -Dfile=f:\ojdbc7.jar -DgroupId=com.oracle.weblogic -DartifactId=ojdbc7 -
Dversion=12.1.0.2.0 -Dpackaging=jar
If setup success,you will see ojdbc7 in the bellow path:
C:\Users\Administrator.m2\repository\com\oracle\weblogic\ojdbc7\12.1.0.2.0
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-
plugin:1.2.4.RELEASE")
}
}
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "spring-boot"
jar {
baseName = "Test"
version = "0.1.0"
}
repositories {
mavenCentral()
mavenLocal();
maven { url "http://repo.spring.io/libs-release" }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.flex:spring-flex-core:1.6.0.RC1")
compile("com.oracle.weblogic:ojdbc7:12.1.0.2.0")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
task wrapper(type: Wrapper) {
gradleVersion = "2.4"
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
The most important is add mavenLocal() to repositories