I am trying to setup error prone using gradle, however everything ive tried gives me some kind of error:
To test I have setup a simple hello world java program using gradle, which without error prone compiles fine.
Then I read: https://github.com/tbroyer/gradle-errorprone-plugin
found from the install guide and tried this in the build.gradle:
plugins {
id 'java'
id("net.ltgt.errorprone") version "2.3.3"
}
group 'test'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
errorprone("com.google.errorprone:error_prone_core:2.3.3")
}
This gave me this error:
Plugin [id: 'net.ltgt.errorprone', version: '2.3.3'] was not found in any of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
Plugin Repositories (could not resolve plugin artifact 'net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:2.3.3')
Searched in the following repositories:
Gradle Central Plugin Repository
I changed 2.3.3 to latest.version and got the same error
Then I found this https://plugins.gradle.org/plugin/net.ltgt.errorprone and tried version number 0.8.1.
I need to be able to use java11 so can't use gradle 4.x as far as I understand.
Also if anybody knows of an actual repository that has used error prone with gradle that I could look at I would be very grateful :)
My gradle wrapper properties is set to use gradle version 5.4.1
Solved as below
Add Gradle plugin to build.gradle file
plugins {
id("net.ltgt.errorprone") version "1.1.0"
}
Release versions
Add dependency to error_prone_core in build.gradle file
dependencies {
errorprone("com.google.errorprone:error_prone_core:2.3.3")
}
Releases
3. Build project, this will add errorprone configuration namespace
4. If you are using java-8, need to add additional dependency too.
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
along with dependency in step-2.
5. you can customize/enable/disable it by tasks
tasks.withType(JavaCompile).configureEach {
options.errorprone.disableWarningsInGeneratedCode = true
options.errorprone.enabled = false // change it to true to enable
}
Note: As mentioned in OP comment by #jb-nizet, gralde plugin and error_prone_core has different versions and independent release cycles.
my build.gradle file
buildscript {
ext{
errorproneVersion = '2.3.3'
}
repositories {
mavenLocal()
mavenCentral()
}
}
plugins {
id "java"
id("net.ltgt.errorprone") version "1.1.0"
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
errorprone("com.google.errorprone:error_prone_core:$errorproneVersion")
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
}
tasks.withType(JavaCompile).configureEach {
options.errorprone.disableWarningsInGeneratedCode = true
options.errorprone.enabled = false
}
Ref
Github-error-prone
Related
my gradle version is 5.6.3.
while I run a spring boot project of 2.3.3.RELEASE with 'gradle clean build' it shows me following error:
* What went wrong:
Plugin [id: 'org.springframework.boot', version: '2.3.3.RELEASE'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.3.3.RELEASE')
Searched in the following repositories:
Gradle Central Plugin Repository
Updating my question:
my build.gradle :
plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'war'
}
group = 'net.project'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
and my settings.gradle contains just the root project name
Spring boot 2.3.3.RELEASE definitely exists on gradle central plugin repository as I can see here. You're most probably building behind a corporate firewall with outgoing URL disabled. Had the same issue earlier, which I solved it by asking the IT Operations team(nicely) to allow https://plugins.gradle.org/ requests to go through. For security reasons if they don't allow this then you can ask them to create a local mirror server as instructed here
I am trying to import tensorflow-lite to my Java - Gradle Project but when I import the dependency IntelliJ tells me: "Unable to resolve org.tensorflow-lite:0.0.0-nightly"
How can I import tensorflow-lite to this simple Project?
this is my build.gradle:
plugins {
id 'java'
}
group 'com.example'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'
}
Using maven repository as reference you should put your graddle reference like this
compile group: 'org.tensorflow', name: 'tensorflow-lite', version: '0.0.0-nightly'
reference:
https://mvnrepository.com/artifact/org.tensorflow/tensorflow-lite/0.0.0-nightly
You really wanna use the nightly version? This version is unstable like a "beta version"
I'm newbie to Hyperledger Fabric. When i instantiate the chaincode written in java after installed on peers from the cli container, there is something wrong:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find com.github.everit-org.json-schema:org.everit.json.schema:1.11.1.
Searched in the following locations:
file:/root/.m2/repository/com/github/everit-org/json-schema/org.everit.json.schema/1.11.1/org.everit.json.schema-1.11.1.pom
file:/root/.m2/repository/com/github/everit-org/json-schema/org.everit.json.schema/1.11.1/org.everit.json.schema-1.11.1.jar
https://repo.maven.apache.org/maven2/com/github/everit-org/json-schema/org.everit.json.schema/1.11.1/org.everit.json.schema-1.11.1.pom
https://repo.maven.apache.org/maven2/com/github/everit-org/json-schema/org.everit.json.schema/1.11.1/org.everit.json.schema-1.11.1.jar
Required by:
project : > org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:1.4.2
I thought it might be the maven repository's issue, but when i use gradle in my host's terminal, it runs ok like:
fabric#ubuntu:~/fabric1.4/fabric-samples/chaincode/master-liuqi/java$ sudo /opt/gradle/bin/gradle -b build.gradle build
Task :compileJava
Note: /home/fabric/fabric1.4/fabric-samples/chaincode/master-liuqi/java/src/main/java/org/hyperledger/fabric/example/SimpleChaincode.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 executed
below is my build.gradle, It is the same as the hyperleger's example chaincode.
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.3'
id 'java'
}
group 'org.hyperledger.fabric-chaincode-java'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.+'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
shadowJar {
baseName = 'chaincode'
version = null
classifier = null
manifest {
attributes 'Main-Class': 'org.hyperledger.fabric.example.SimpleChaincode'
}
}
Is there any way to solve this problem? and what is the difference in running gradle build within host and container?
Actually, you should use
repositories {
mavenLocal()
mavenCentral()
maven {
maven { url 'https://jitpack.io' }
}
}
repo instead of repo from the other answer, since this repo is recommended in official json-schema documentation.
Quote:
Add the JitPack repository and the dependency to your pom.xml as
follows:
(see: https://github.com/everit-org/json-schema)
I searched the maven repository(https://mvnrepository.com/artifact/org.hyperledger.fabric-chaincode-java/fabric-chaincode-shim/1.4.2), found that this dependency is not in maven central repository. After adding repository in build.gradle as follows:
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://repository.mulesoft.org/nexus/content/repositories/public/"
}
}
it works well now. since i am not familar with gradle, i still wonder why i can build successfully in host while failed in cli container ?
I am using OpenSSL for my Java GRPC project which uses gradle.
I read the documetation which mentions that we should make security settings as mentioned in this link.
I have included the osdetector plugin in the build.gradle file.
But when I build the project, gradle is not able to resolve the osdetector plugin and throwing error
> Failed to apply plugin [id 'com.google.protobuf']
> Plugin with id 'osdetector' not found.
My gradle file is as follows:
def neo4jVersion = "2.3.3"
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'com.google.protobuf'
apply plugin: 'idea'
apply plugin: 'com.google.osdetector'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.3'
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
}
}
protobuf {
protoc {
// The version of protoc must match protobuf-java. If you don't depend on
// protobuf-java directly, you will be transitively depending on the
// protobuf-java version that grpc depends on.
artifact = "com.google.protobuf:protoc:3.0.0-beta-2"
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:0.12.0'
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
generatedFilesBaseDir = "$projectDir/src/generated"
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile 'io.grpc:grpc-all:0.12.0'
compile "org.neo4j:neo4j:${neo4jVersion}"
compile "org.neo4j:neo4j-ogm-core:2.0.1"
compile "org.neo4j:neo4j-ogm-http-driver:2.0.1"
compile 'com.google.apis:google-api-services-storage:v1-rev71-1.22.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork14:' + osdetector.classifier
}
The compile dependency alone is getting resolved however.
I think I am missing something basic here. Please let me know the solution.
Updated
protobuf-gradle-plugin is not compatible with osdetector-gradle-plugin-1.4.0, since that version changed the name of the plugin. Swapping to version osdetector 1.2.1 should fix the problem.
How to control H2 driver version in Grails/Gradle project?
Having problems with running Grails 3 app with H2 I found this answer: Grails accessing H2 TCP server hangs stating it may be caused by driver version difference.
My IDE reports Grails app uses 1.3.176 version of H2, while my server has 1.4.190. So, I would like to upgrade app's H2, but can't find where it is defined. I sought all project files and found no version definition.
UPDATE
My current build.gradle:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0'
classpath "org.grails.plugins:hibernate:4.3.10.5"
}
}
plugins {
id "io.spring.dependency-management" version "0.5.2.RELEASE"
}
version "0.1"
group "multipleparentsgrails"
apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
assets {
minifyJs = true
minifyCss = true
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:hibernate"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:scaffolding"
runtime "org.grails.plugins:asset-pipeline"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'
console "org.grails:grails-console"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
You should be able to specify it like any other dependency
runtime "com.h2database:h2:1.4.190"
There are many dependencies which may use H2. grails, hibernate, others.
I would go into your project. Let's say it's $HOME/projects/myproj.
1) Do a dependency report. Pipe it into grep so you don't have to wade through a 1,000 line report, and see what versions of H2 are being used.
cd $HOME/projects/myproj
./gradlew dependencies | grep 'H2'
2) Find the highest version number, and then explicitly include this in your build.gradle to force every dependency to use the most current version:
dependencies {
// all the other dependencies
runtime "com.h2database:h2:1.4.190" // where 1.4.190 is the most
// current version. as i
// type this it is 1.4.191
// according to maven central
}