I am making an IntelliJ project of Serenity BDD that will use Java 10. The exact project I am using is built from the maven command, (Using option 3 for just Selenium-Junit):
mvn archetype:generate -Dfilter=serenity
So far I have corrected for the JAXB exception when building/running in Java 10 with the following dependencies in my build.gradle
compile 'javax.xml.bind:jaxb-api:2.3.0'
compile 'com.sun.xml.bind:jaxb-impl:2.3.0'
compile 'org.glassfish.jaxb:jaxb-runtime:2.3.0'
compile 'javax.activation:activation:1.1.1'
I have also installed the Java 10 Jdk (jdk-10.0.1_windows-x64_bin), and pointed my project to that Jdk. I've also found instruction to update my Gradle to version 4.8, and have done so as well
I'm trying to handle any other compatibility issues, and I'm trying to understand the gradle dependencies process better. With my entire build.gradle posted below, What else do I need to change to ensure that my build.gradle is helping to maintain Java 10?
repositories {
jcenter()
mavenLocal()
}
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:1.8.3")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'net.serenity-bdd.aggregator'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile 'net.serenity-bdd:serenity-core:1.8.3'
compile 'net.serenity-bdd:serenity-junit:1.8.3'
compile 'javax.xml.bind:jaxb-api:2.3.0'
compile 'com.sun.xml.bind:jaxb-impl:2.3.0'
compile 'org.glassfish.jaxb:jaxb-runtime:2.3.0'
compile 'javax.activation:activation:1.1.1'
compile 'net.serenity-bdd:serenity-rest-assured:1.2.5-rc.11'
testCompile 'org.slf4j:slf4j-simple:1.7.7'
testCompile('junit:junit:4.12')
}
gradle.startParameter.continueOnFailure = true
Related
I have a java project that write in kotlin ,i use intelliJ IDEA to develop this project. I have trouble on the dependencies setting (multiple project). I already read lot of examples , but I can't find the workaround , here is my dependencies setting code,
it can be build in java class correctly , but the kotlin class will get lot of error 'Unresolved reference' . Is that any wrong about my setting or gradle is not suitable with kotlin .
PS : when i only build core project , build process will successful , but build at test project will get the reference unresolved error
allprojects {
apply plugin: 'java'
apply plugin: 'kotlin'
group 'testProject'
version '1.0'
}
subprojects{
apply plugin: 'java'
apply plugin: 'kotlin'
def defaultEncoding = 'UTF-8'
compileJava.options.encoding = defaultEncoding
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
// Kotlin
compile "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
}
project(':test') {
dependencies {
compile project(':core')
compile project(':testTwo')
}
project(':testTwo'){
dependencies{
compile project(':core')
}
setting.gradle
include 'test','testTwo','core'
The kotlin-gradle-plugin is not a dependency of your subprojects, it is a dependency of the buildscript itself.
Follow the instructions on Plugin and Versions
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
}
I have a root gradle project and 10 subprojects. I want 5 dependencies to be specified in root project only, without copy-pasting them to all 10 modules. If I write:
subprojects{
dependencies{
compile 'org.codehaus.groovy:groovy-all:2.3.11'
compile 'org.springframework:spring-core:4.1.2.RELEASE'
compile 'org.springframework:spring-context:4.1.2.RELEASE'
}
}
it says to me that compile() method has not been found. How to make it work so I should specify deps only in one place?
Have you applied java plugin with:
allprojects {
apply plugin: 'java'
}
or:
subprojects {
apply plugin: 'java'
}
?
Please remember that you also need to add repositories block. It will be:
repositories {
mavenCentral()
jcenter()
}
Gradle Doc Reference: 8.2. Declaring your dependencies
You must wrap the compile dependencies with the dependencies keyword like so:
subprojects {
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
compile 'org.springframework:spring-core:4.1.2.RELEASE'
compile 'org.springframework:spring-context:4.1.2.RELEASE'
}
}
This applies to your root-only libraries as well.
I've got an Android project split into a pure Java library and the Android application. I'm using Gradle Retrolambda so I can write Java 8 code.
Android Studio 1.3 correctly recognises the android.compileOptions.sourceCompatibility in the Android module that I've set to JavaVersion.VERSION_1_8.
Now I'd like Android Studio to realise the Java module is also Java 8. I've tried (in the root of the Gradle script, after apply plugin 'java':
sourceCompatibility = 1.8 But doesn't work. Gradle correctly compiles, but Android Studio shows a warning ("Assignment not used") and assumes Java 6.
sourceCompatibility 1.8 doesn't compile.
How can I get Android Studio to recognise this without resorting to the "Set source version" quick fix? Or is it unimplemented for now?
EDIT
To clarify, the whole project does compile with ./gradlew assembleDebug. The problem is with Android Studio source highlighting.
My Java module build.gradle is as follows:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.0'
}
}
repositories {
jcenter()
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'me.tatarka.retrolambda'
sourceCompatibility = JavaVersion.VERSION_1_8
dependencies {
compile 'io.reactivex:rxjava:1.0.12'
compile 'io.reactivex:rxjava-string:1.0.0'
compile 'joda-time:joda-time:2.8.1'
testCompile 'junit:junit:4.12'
}
retrolambda {
jdk System.getenv("JAVA_HOME")
defaultMethods true
incremental false
}
And here's what Android Studio gives me:
in your java module build.gradle write code like this:
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "me.tatarka:gradle-retrolambda:3.2.0"
}
}
apply plugin: 'java'
apply plugin: 'me.tatarka.retrolambda'
repositories {
mavenCentral()
}
dependencies {
}
retrolambda {
jdk System.getenv("JAVA8_HOME")
defaultMethods true
incremental false
}
It would appear (thanks #Anand Singh) that Android Studio doesn't handle this yet, so you need to apply the quick fix.