I am new to gradle, and have written the following configuration and dependency. When I compile using eclipse, it gives me errors because it is not importing the jars mentioned in "acceptanceTestCompile".
Am I missing anything? Any help appreciated. Don't want to move to NetBeans (which is picking up the dependencies without issue :))
sourceSets {
acceptanceTest {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
configurations {
acceptanceTestCompile.extendsFrom testCompile
acceptanceTestRuntime.extendsFrom testRuntime
}
dependencies {
acceptanceTestCompile 'org.gebish:geb-spock:0.10.0',
'org.spockframework:spock-core:0.7-groovy-2.0',
'org.seleniumhq.selenium:selenium-java:2.45.0',
'org.seleniumhq.selenium:selenium-firefox-driver:2.43.1',
'org.seleniumhq.selenium:selenium-ie-driver:2.43.1',
'org.seleniumhq.selenium:selenium-support:2.43.1',
'org.jfairy:jfairy:0.3.0'
}
Thank you
Karthik
Related
I have project that uses gradle, scala, scalatest and the gradle-scalatest-plugin.
I have several tests and they are compiled. But when the run part of them is executed, the gradle is stuck on "Dicovery starting." infinitely.
So I used gradle --debug test to see what is happening. But besides the status information about memory of jvm and lock acquiring, there is no information why it is stuck.
build.gradle File:
buildscript {
ext.scala_version = "2.12"
ext.akka_version = "2.5"
ext.monocle_version = "1.5.0"
ext.circe_version = "0.8+"
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.diffplug.gradle:goomph:3.9.0"
}
}
plugins {
id "java"
id "scala"
id "com.github.maiflai.scalatest" version "0.19"
id "com.athaydes.osgi-run" version "1.5.4"
id "org.dm.bundle" version "0.10.0"
// For interoperability with Other Company Eclipse P2 Repository
id "com.diffplug.gradle.p2.asmaven" version "3.9.0"
}
group "project.scalatest"
version 0.1
repositories {
mavenCentral()
jcenter()
}
sourceSets {
test {
java {
srcDirs = ['test/main/java']
}
scala {
srcDirs = ['test/main/scala']
}
}
}
runOsgi {
bundles += project
}
bundle {
instruction '-dsannotations', '*'
}
test {
}
// Adding the Other Company Eclipse P2 project Core Repo as dependency
p2AsMaven {
group 'project', {
repo 'https://other-company.de/p2/'
iu 'de.other-company.project.core'
}
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar', '*.java'])
compile "org.osgi:org.osgi.core:6.0+"
compile "org.osgi:org.osgi.service.log:1.3+"
compile "org.osgi:org.osgi.service.component:1.3+"
compile "org.osgi:org.osgi.service.component.annotations:1.3+"
compile "project:de.other-company.project.core:+"
// Include the program repository code as dependency
//compile fileTree(dir: "../repository")
compile "org.scala-lang:scala-library:$scala_version+"
compile "com.typesafe.akka:akka-osgi_$scala_version:$akka_version+"
compile "io.circe:circe-core_$scala_version:$circe_version"
compile "io.circe:circe-generic_$scala_version:$circe_version"
compile "io.circe:circe-parser_$scala_version:$circe_version"
compile "io.circe:circe-optics_$scala_version:$circe_version"
compile "com.github.julien-truffaut:monocle-core_$scala_version:$monocle_version"
compile "com.github.julien-truffaut:monocle-macro_$scala_version:$monocle_version"
compile "org.slf4j:slf4j-api:1.7.+"
compile "org.slf4j:slf4j-simple:1.7.+"
compile "org.slf4j:osgi-over-slf4j:1.7.+"
testCompile "com.typesafe.akka:akka-testkit_$scala_version:$akka_version+"
testCompile "org.scalatest:scalatest_$scala_version:3.2+"
testCompile "org.scalactic:scalactic_$scala_version:3.2+"
testCompile "org.scalacheck:scalacheck_$scala_version:1.13+"
testCompile "org.mockito:mockito-core:2.+"
testRuntime "org.pegdown:pegdown:1.4+"
osgiRuntime "org.apache.felix:org.apache.felix.configadmin:1.8+"
osgiRuntime "org.apache.felix:org.apache.felix.scr:2.0+"
osgiRuntime "org.apache.felix:org.apache.felix.log:1.0+"
}
So I found the solution myself :)
I did some crappy solution to find and use files in the test.
After a research how to do it properly getClass.getResource("...") the problem went away.
Does somebody understands what is a problem? Why my IDE doesn't see classes from dependencies? Idea version: 17.2.2
The root build.gradle:
subprojects.each {
apply plugin: 'idea'
}
The root setting.gradle:
include 'client'
include 'api'
rootProject.name = 'app-1-akka-reactjs'
My build.gradle of api project:
apply plugin: 'play'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.iatoki:gradle-play-idea:0.4.1'
}
}
apply plugin: 'org.iatoki.play-idea'
repositories {
jcenter()
ivy {
url "https://repo.typesafe.com/typesafe/ivy-releases/"
layout "pattern", {
ivy "[organisation]/[module]/[revision]/ivys/ivy.xml"
artifact "[organisation]/[module]/[revision]/jars/[artifact].[ext]"
}
}
}
model {
components {
play {
platform play: '2.5.8', scala: '2.11', java: '1.8'
injectedRoutesGenerator = true
}
}
}
dependencies {
play 'com.typesafe.play:play-slick_2.11:2.1.0'
play 'com.typesafe.play:play-slick-evolutions_2.11:2.1.0'
play 'org.postgresql:postgresql:9.4-1200-jdbc41'
}
The build.gradle of client is empty for now.
To generate idea's files I've used:
gradle cleanIdea idea
I faced a similar issue. I could resolve it by moving/copying the settings.xml file from $MVN_HOME/conf to ~/.m2 folder. As MVN_HOME was not detected by Idea it could not resolve the settings.xml from MVN_HOME.
I created a Libgdx project without the freetype font extension, and later realized that i needed it.
I added the dependencies to the build.gradle file and resfreshed the gradle build (in eclipse, for each project, right click->Gradle->Refresh Gradle Project) but still can't use the library. When trying to import something, i get "The import com.badlogic.gdx.graphics.g2d.freetype cannot be resolved".
What am i doing wrong or missing?
Here's my build.gradle file:
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "X"
gdxVersion = '1.9.0'
roboVMVersion = '1.12.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.7.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
}
}
tasks.eclipse.doLast {
delete ".project"
}
Thanks!
You need to refresh Gradle dependencies
Right click on your project -> Gradle -> Refresh All
I have created additional source set called "integration-test" in my gradle project. Ewerything works fine, but eclipse cannot see dependency classes defined exactly for this source set.
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
repositories {
mavenCentral()
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.10.19'
integrationTestCompile 'org.springframework:spring-test:4.1.7.RELEASE'
compile 'org.springframework:spring-context:4.1.7.RELEASE'
compile 'org.springframework:spring-core:4.1.7.RELEASE'
}
task integrationTest(type: Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
check.dependsOn integrationTest
integrationTest.mustRunAfter test
version = '1.0'
}
When i build this project by command "build gradle", project is build, the only problem is with eclipse. If I change dependency 'org.springframework:spring-test:4.1.7.RELEASE' from "integrationTestCompile" to "testCompile", problem is gone.
It is a little late to answer your question, but I just found a solution to this, since I had the exact same problem.
Adding this:
eclipse {
classpath {
plusConfigurations.add configurations.integrationTestCompile
plusConfigurations.add configurations.integrationTestRuntime
}
}
to the gradle file solved the problem. I hope it does the same for you.
An approach that I found that worked really well for me is this test sets plugin: https://plugins.gradle.org/plugin/org.unbroken-dome.test-sets
It made it really easy to add integration tests to my module. And it works with the eclipse plugin automatically.
I am a complete noob with Gradle. I am writing an android application using Android Studio with a co-worker who is using Eclipse. we are sharing our files through git. It was created in eclipse without Gradle. My question is, is it possible to generate the gradle files for the project on my end without him having to export the project on his? I am trying to setup ActionBar Sherlock and its causing me all sorts of trouble I think the lack of a grable.build file might have something to do with it.
You can include abs in your project as a library.
Put a build.gradle in abs module:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+' // You can use also classpath 'com.android.tools.build:gradle:0.6.+' with gradle 1.8
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1" //use your build version
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
Then in your project module add in build.gradle:
dependencies {
compile project(':libraries:actionbarsherlock') //Use your name
}
You have to setting also setting.gradle
include ':MyApplication'
include ':libraries:actionbarsherlock'
You can see this post:
http://gmariotti.blogspot.it/2013/06/quick-tips-convert-to-new-gradle-based.html
Otherwise, you can ignore the library folder and only use in your project module this script in build.gradle.
Gradle will download from maven the aar format.
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
}
All you need is a simple build.gradle file for your ActionBarSherlock project. Here's one I've created:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}
android {
buildToolsVersion "17.0"
compileSdkVersion 17
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}