I'm trying to use Gradle with this 'org.jopendocument:jOpenDocument:1.3b1' a obtain this Error:
this Gradle file (1) fail with this error:
Error:(21, 0) Gradle DSL method not found: 'complie()'
Possible causes:
The project '' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper
file The build file may be missing a Gradle plugin.
Apply Gradle plugin
Gradle file (1)
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
..//
compile 'org.mariadb.jdbc:mariadb-java-client:1.1.7'
complie 'org.jopendocument:jOpenDocument:1.3b1'
}
but add this one to test compile 'org.apache.felix:org.apache.felix.scr.annotations:1.9.12' and it works well
Gradle file (2)
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
..//
compile 'org.mariadb.jdbc:mariadb-java-client:1.1.7'
//complie 'org.jopendocument:jOpenDocument:1.3b1'
compile 'org.apache.felix:org.apache.felix.scr.annotations:1.9.12'
}
but want to use complie 'org.jopendocument:jOpenDocument:1.3b1', does not work, I have dealt with:
'org.jopendocument:jOpenDocument:1.3b1'
'org.jopendocument:jOpenDocument:1.3'
'org.jopendocument:jOpenDocument:1.+'
'org.jopendocument:jOpenDocument:1.1'
but it does not work, someone can tell me if I'm doing something wrong
http://mvnrepository.com/artifact/org.jopendocument/jOpenDocument/1.3b1
http://repo.gradle.org/gradle/repo/org/jopendocument/jOpenDocument/1.3/
Seems like a typing mistake: you need compile, but not complie.
That line in first gradle file:
complie 'org.jopendocument:jOpenDocument:1.3b1'
Related
Consider the following line in a dependencies gradle file:
compile group: 'com.sun.xml.ws', name: 'jaxws-rt', version: '2.2.10', ext: 'pom'
I would like to translate it into the following shorthand instead:
compile 'com.sun.xml.ws:jaxws-rt:2.2.10' ext: 'pom'
However, this does not work because of the ext section.
What is the correct syntax to add that part in the shorthand?
Use this:
compile com.sun.xml.ws:jaxws-rt:2.2.10#pom
See the related section of the Users Guide.
Good luck!
I start with software testing - using Cucumber, Java, gradle.
I try to learn this with the book "The Cucumber for Java Book"
But I try to do I with gradle instead of maven... But now I have some problems...
I stick on page 149. I have to give so dependecies:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>
I try to "translate" this to gradle
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'io.cucumber:cucumber-java:2.4.0'
testCompile 'io.cucumber:cucumber-junit:2.4.0'
testCompile group: 'info.cukes', name: 'cucumber-picocontainer', version: '1.2.5'
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'
}
Is this right?
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'
After that I have to run:
mvn exec:java -Dexec.mainClass="nicebank.AtmServer"
But how can I do this with gradle?
I hope someone can help me :)
Your dependency looks good. Just one note: consider using implementation over compile as it improves the performance. Read about compile deprecation here.
You can also put your properties in gradle.properties file and reference them in the build script:
gradle.properties:
jettyVersion=9.4.12.v20180830
build.gradle:
implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: jettyVersion
Jetty team also published BOMs: — org.eclipse.jetty:jetty-bom:9.4.12.v20180830 in your case. If you use multiple projects of the same version you can import the BOM and skip the version completely:
dependencies {
implementation 'org.eclipse.jetty:jetty-bom:9.4.12.v20180830'
implementation 'org.eclipse.jetty:jetty-webapp'
implementation 'org.eclipse.jetty:jetty-runner'
}
As for the "exec" task: if you have only one main class in your project, like nicebank.AtmServer, consider using Gradle's Application Plugin:
plugins {
id 'application'
}
mainClassName = 'nicebank.AtmServer'
This way you don't need to create "exec" task manually, you'll get one (run) from the plugin. As a bonus you'll get two "distribution" tasks that will create a ready-for-distribution archive with your app: distZip and distTar.
As I said in my comment, the dependency for jetty-webapp seems OK but you should use implementation instead of compile ( compile has been deprecated, see Java dependency configurations):
implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'
or
implementation "org.eclipse.jetty:jetty-webapp:9.4.12.v20180830"
For the equivalent of "maven exec:java" in Gradle , you could use the Gradle JavaExec task type: try to define a task in your build as follows:
task runApp(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'nicebank.AtmServer'
}
(not tested, you migth have to adapt it) , and run it with
gradle runApp
You could alternatively use Gretty plugin to run your webapp (no need to define your own JavaExec task in this case), as documented here and here:
plugins{
// your existing plugins
id "org.gretty" version "2.2.0"
}
You can then run the application with:
gradle appRun
I am doing a simple gradle build and I have deployed a particular artifact to my internal sonatype maven repo
My build.gradle file looks like this:
apply plugin: 'java'
sourceCompatibility = 1.8
version = '1.0'
repositories {
mavenCentral()
maven {url "http://maven.ebay.com/nexus/content/repositories/sre-snapshots/"}
}
dependencies {
compile group: "com.typesafe", name: "config", version: "1.3.0"
//compile project(':metrics')
compile group: 'com.ebay.telemetry', name: 'client-library', version: '0.1-SNAPSHOT'
compile group: "org.slf4j", name: "slf4j-jdk14", version: "1.7.12"
testCompile group: 'junit', name: 'junit', version: '4.11'
}
I run this command on the command line: gradle build
I get this error:
> Could not find net.alchim31:metrics-influxdb:0.7.1-ebay-SNAPSHOT.
Searched in the following locations:
https://repo1.maven.org/maven2/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/metrics-influxdb-0.7.1-ebay-20150708.054833-4.pom
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/metrics-influxdb-0.7.1-ebay-20150708.054833-4.jar
However when I go to http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/
I see the following files :
metrics-influxdb-0.7.1-ebay-20150708.054830-3.pom
metrics-influxdb-0.7.1-ebay-20150708.054830-3.jar
So why is gradle looking for metrics-influxdb-0.7.1-ebay-20150708.054833-4.jar when my repo has metrics-influxdb-0.7.1-ebay-20150708.054830-3.jar
It seems like you have declared another dependency besides the one you showed above. It should probably look something like this:
compile group: 'net.alchim31', name: 'metrics-influxdb', version: '0.7.1-ebay-SNAPSHOT'
If you find this dependency declaration, you might also find the source of the problem.
The second possibility is, that your maven-metadata.xml (at http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml) is messed up and points towards the nonexisting build 4.
I've set up an Gradle App Engine project and ported over my code that was working perfectly well. But on building the project through Gradle I get the following error:
20:28:32.036 [INFO] [org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler] Compiling with JDK Java compiler API.
20:28:32.088 [ERROR] [system.err] D:\Projects\WordBuzzIntegrated\wordbuzzserver\src\com\wrc\wordbuzzweb\service\Login.java:21: error: cannot access QueryResultIterable
20:28:32.088 [ERROR] [system.err] User user = ofy().load().type(User.class).id(facebookUser.id).now();
20:28:32.089 [ERROR] [system.err] ^
20:28:32.089 [ERROR] [system.err] class file for com.google.appengine.api.datastore.QueryResultIterable not found
I don't really have a clue what's causing the problem and Googling the error returns zero results. My dependencies list is as follows:
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.15'
providedCompile 'javax.servlet:servlet-api:2.5'
testCompile group: 'junit', name: 'junit', version: '4.11'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.4.3'
compile 'com.googlecode.objectify:objectify:5.1.1'
}
If anyone has any idea what might be going on here then your help would be greatly appreciated.
There are other App Engine dependencies that need to be included in the Gradle build. I ended up including all of the following for good measure - although I'm not sure all are required:
dependencies {
appengineSdk "com.google.appengine:appengine-java-sdk:$appEngineVersion"
compile "com.google.appengine:appengine-api-1.0-sdk:$appEngineVersion"
compile "com.google.appengine:appengine-endpoints:$appEngineVersion"
compile "com.google.appengine:appengine-endpoints-deps:$appEngineVersion"
compile "com.googlecode.objectify:objectify:5.1.1"
compile group: "com.google.guava", name: "guava", version: "18.0"
}
If using IntelliJ be sure to add the jars to your artifact for deployment.
If you want to run unit tests (junit included below) then you'll also need to add the following
testCompile group: "junit", name: "junit", version: "4.11"
testCompile "com.google.appengine:appengine-testing:$appEngineVersion"
testCompile "com.google.appengine:appengine-api-labs:$appEngineVersion"
testCompile "com.google.appengine:appengine-api-stubs:$appEngineVersion"
You'll also need to include the following in your Gradle script to set the app engine version. (Check what the latest version is)
ext.appEngineVersion = '1.9.21'
The Problem can be solved by adding the following dependendy in Gradle:
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.21'
You do not need to have the dependency for Cloud Endpoints if you are not using it, although it will also solve the problem as it has itself a dependeny on the missing one.
Ran into the same issue when generating a module with Android Studio which did not include this API. I could not even find any information on it in the documentation.
When IntelliJ opens a build.gradle file it will generate an IntelliJ project with the Gradle dependencies resolved and added to the project scope. This works great for the "compile" source set and the "test" source set, however I can not get this to work for custom source sets.
I want to have IntelliJ resolve the dependencies for my componentTest source set. How do I tell IntelliJ to resolve these dependencies and add them to scope?
dependencies {
// main source set, "compile" scope in IntelliJ
compile(group: 'com.google.guava', name: 'guava', version: '18.0')
// test source set, "test" scope in IntelliJ
testCompile(group: 'junit', name: 'junit', version: '4.11')
// my custom source set, not added to any scope in IntelliJ
componentTestCompile(group: 'org.springframework', name: 'spring', version: '3.0.7')
}
Details: IntelliJ 13.1.2, Gradle 1.11
This is described in Gradle user guide - http://www.gradle.org/docs/current/userguide/idea_plugin.html and http://www.gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html
You will need to add something like:
idea {
module {
scopes.TEST.plus += [ configurations.componentTestCompile ]
}
}
to your build.gradle file.