I am trying to get a simple Gradle project (the one that is created by eclipse automatically) with static code analysis made by Sonar to run on our continuous integration. Our CI server is behind a proxy and i have to access the Gradle plugin repository over an internal Nexus server.
As described in the userguide i have added the following to my settings.gradle
pluginRepositories {
maven {
url 'http://link.to.my.nexus'
}
gradlePluginPortal()
}
rootProject.name = 'GradleTestProject'
my build.gradle looks like this:
plugins {
id "org.sonarqube" version "2.0.1"
}
apply plugin: 'java'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
testCompile 'junit:junit:4.12'
}
When i run this on Jenkins, i get the following error message:
FAILURE: Build failed with an exception.
* Where:
Settings file '/opt/hudson/jobs/GradleTestProject/workspace/settings.gradle' line: 1
* What went wrong:
A problem occurred evaluating settings 'workspace'.
> Could not find method pluginRepositories() for arguments [settings_20tc2o9xuj82hi1fvpe4wvcvt$_run_closure1#52b56c40] on settings 'workspace'.
I have looked at other examples in the web. They all do it the same way as i described.
BTW: I am using Gradle 2.12
I'm in version 4.0.1.
I had the same error, found your question without answer and finally I found and tried this in settings.gradle and now it works.
pluginManagement {
repositories {
gradlePluginPortal()
}
}
Related
Can Anyone tell me how to resolve these compilation errors. Facing these issues while integrating Analytics & Push Kit in React Native?
Could not determine the dependencies of task ':app:preDebugBuild'.
Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
Could not resolve org.codehaus.mojo:animal-sniffer-annotations:1.17.
Required by:
project :app
> Could not resolve org.codehaus.mojo:animal-sniffer-annotations:1.17.
> Could not get resource 'http://developer.huawei.com/repo/org/codehaus/mojo/animal-sniffer-annotations/1.17/animal-sniffer-annotations-1.17.jar'.
> Could not HEAD 'http://developer.huawei.com/repo/org/codehaus/mojo/animal-sniffer-annotations/1.17/animal-sniffer-annotations-1.17.jar'.
> Read timed out
Could not resolve org.codehaus.mojo:animal-sniffer-annotations:1.17.
Required by:
project :app > io.grpc:grpc-core:1.16.1
> Could not resolve org.codehaus.mojo:animal-sniffer-annotations:1.17.
> Could not get resource 'http://developer.huawei.com/repo/org/codehaus/mojo/animal-sniffer-annotations/1.17/animal-sniffer-annotations-1.17.jar'.
> Could not HEAD 'http://developer.huawei.com/repo/org/codehaus/mojo/animal-sniffer-annotations/1.17/animal-sniffer-annotations-1.17.jar'.
> Read timed out
> Could not resolve com.parse.bolts:bolts-applinks:1.4.0.
> Could not get resource 'http://developer.huawei.com/repo/com/parse/bolts/bolts-applinks/1.4.0/bolts-applinks-1.4.0.jar'.
> Could not HEAD 'http://developer.huawei.com/repo/com/parse/bolts/bolts-applinks/1.4.0/bolts-applinks-1.4.0.jar'.
> Read timed out
There could be below reasons for this issue
Integration issue
Linking issue
For Integration issue, please make sure that all the integration steps been followed as provided in the guides below.
https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/integrate-rn-sdk-0000001050159021
For liking issue, i would recommend you please use npm link command and try which will help you to link with the node modules.
this seems more likely to be an android/gradle configuration issue than a react-native issue. I do not have your source code so I cannot be sure, but I suspect you are missing something in the root level build.gradle
If you are migrating your app to HMS, I'd suggest you to cross reference your original project and simply add the line
maven {url 'http://developer.huawei.com/repo/'}
to the buildscript/repositories and allprojects/repositories blocks.
Following is a sample build.gradle file that can successfully resolve the problematic modules in your description:
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
maven {url 'http://developer.huawei.com/repo/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.huawei.agconnect:agcp:1.2.1.301'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
maven {url 'http://developer.huawei.com/repo/'}
}}
Im using lombok in my gradle project and want to create a jar file but everytime im executing the jar task (no matter if triggered in my console or eclipse ide) im getting the error that my lombok imports cant be found in those classes where im using lombok annotations. Example output:
... other lombok related error messages ...
/test/entity/geo/Region.java:11: error: package lombok does not exist
import lombok.EqualsAndHashCode;
^
/test/entity/geo/Region.java:12: error: package lombok does not exist
import lombok.NoArgsConstructor;
^
/test/entity/geo/Region.java:37: error: cannot find symbol
#Data
^
symbol: class Data
100 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJpaModelgen'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
After searching a while i found out there is a plugin for gradle and lombok but isn't really needed for compiling with newer gradle versions. My gradle version is 3.4.1 and lombok 1.6.18.
In another thread i found probably a similar error but with maven.
I would like to try this in my build.gradle but i dont have an idea how to write/define this...
Starting and running my spring boot app withing my Eclipse ide works fine; only the gradle compileJava task seems to have a problem with lombok while compiling.
This is my build.gradle:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:+") }
}
plugins {
id 'at.comm_unity.gradle.plugins.jpamodelgen' version '1.1.3'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'at.comm_unity.gradle.plugins.jpamodelgen'
apply plugin: 'war'
war {
baseName = 'test'
version = '0.0.1'
}
repositories { mavenCentral() }
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-data-rest"
compile("org.springframework.boot:spring-boot-devtools")
compile"org.springframework.boot:spring-boot-starter-test"
compile 'org.postgresql:postgresql:42.1.1'
compile 'javax.validation:validation-api:2.0.0.CR2'
compile 'org.hibernate:hibernate-java8:5.2.10.Final'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.8.9'
compileOnly('javax.servlet:jstl')
compile('org.apache.tomcat.embed:tomcat-embed-jasper')
compile('org.springframework.boot:spring-boot-starter-tomcat')
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.16.18'
compile "com.google.guava:guava"
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
sourceSets {
generated { java.srcDir "${buildDir}/generated/src/java/" }
}
ext['hibernate.version'] = '5.2.10.Final'
jpaModelgen {
library = "org.hibernate:hibernate-jpamodelgen:5.2.10.Final"
jpaModelgenSourcesDir = "src/generated/java"
}
compileJava.options.compilerArgs += ["-proc:none"]
compileJava.options.compilerArgs += [
"-proc:only",
]
I am trying to setup JUnit testing in my Gluon JavaFX Application. I am using the Gluon Eclipse Plugin with Gradle and Java 8.
My build.gradle file looks like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b10'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
}
dependencies {
compile 'com.gluonhq:ignite-dagger:1.0.0'
compile 'org.elasticsearch:elasticsearch:1.6.0'
compile 'ch.qos.logback:logback-classic:1.1.5'
testCompile 'junit:junit:4.12'
}
mainClassName = 'com.me.MyApplication'
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
}
}
Resolving the dependency is no problem, but when running the 'test' task, gradle throws an error like this:
When running gradle with java 8, you must set the path to the old jdk, either with property retrolambda.oldJdk or environment variable JAVA6_HOME/JAVA7_HOME
Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip'.
I already tried to add the retrolambda plugin to gradle according to the plugin's README on GitHub, but it doesn't work so far. Could someone tell me what to do to configure my Gluon project so that I am able to run my JUnit tests with Gradle?
Some important addidtions:
For the plugin version it says: Gluon Tools 1.0.0.201508201514
I think I fogot to mention that I want to use Dagger dependency injection with Gluon Ignite which might be the real problem in my case as it requires Java 8 and might conflict with javafxports or something else. However, I'm not able to make full sense of the various error messages I've seen.
My tests are empty, but they aren't even run, because it fails before.
Your problem seems like a retroLambda configuration issue. If you go through the configuration page for the plugin, it states that if you don't have an environment variable set for JAVA6_HOME or JAVA7_HOME than you need to explicitly define oldJdk for the plugin to work properly.
My build.gradle script:
apply plugin: 'groovy'
apply plugin: 'eclipse'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
dependencies {
compile (
'org.apache.camel:camel-core:2.14.1',
'org.apache.camel:camel-mail:2.14.1'
)
}
When I run gradle eclipse I see:
:myapp:eclipseClasspath
:myapp:eclipseJdt
:myapp:eclipseProject
:myapp:eclipse
BUILD SUCCESSFUL
Total time: 3.694 secs
When I run gradle clean build I get a similar BUILD SUCCESSFUL message. But when I refresh my project in Eclipse, I don't see a Referenced Libraries folder with Camel Core or Camel Mail in it, instead under the Problems tab I see 3 problems:
Project 'myapp' is missing required library: 'D:\workspace\myapp\unresolved dependency - org.apache.camel camel-core 2.14.1'
Project 'myapp' is missing required library: 'D:\workspace\myapp\unresolved dependency - org.apache.camel camel-mail 2.14.1'
The project cannot be built until build path errors are resolved
What is going on here? On a perhaps-somewhat-related note, I am on Eclipse Juno, and going into Properties >> Java >> Compiler, I don't seem to have an option to set my Eclipse Java Compiler to 1.8, only 1.7. Perhaps my Eclipse instance is too old to handle Java 8?
If that's your full build script, you're missing repository definitions (where to go get the artifacts). Try adding:
repositories {
mavenCentral()
}
Here's the backing class for repositories {} in case you need to add a custom URL.
I used Gradle plugin dev to upload my plugin to jCenter. But now I do not know how to use it in gradle.
It fail finding the classpath. I build it like this:
groupId:artifactId:version
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.fuzz.skeleton:app:1.0.0.RELEASE'
}
}
My project can be found here.
You have to request that your package be included in JCenter. Specifically, you have not accomplished step 3 of this process. Additionally, you'll want to request inclusion in the Gradle plugins repository so that your plugin will be available on the Gradle plugin portal.