Importing jetty libraries - java

I wanna use jetty in my project. I'm building it with Gradle. IntelliJ tells "Cannot resolve symbol jetty" in the following row import org.eclipse.jetty.server.Server; How to fix this? Here are my project directories and gradle dependencies:

Use maven central to grab jetty dependencies. Put the following in your build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'org.eclipse.jetty:jetty-webapp:9.4.0.v20161208'
}

Related

Gradle find wrong maven repository url in eclipse

this is my build.gradle
repositories {
mavenCentral()
maven{url 'http://example.com/repository/maven-public/'}
}
dependencies {
compile group: 'com.example', name: 'example-commlib', version: '1.0'
}
and the link http://example.com/repository/maven-public/ is build from Nexus Repository Manager which can accessable.
and when I click Refresh Gradle Project in eclipse.
I can see the link is point to
https://repo.maven.apache.org/..../example-commlib-1.0.pom
I think the right url is
http://example.com/repository/maven-public/.../example-commlib-1.0.pom
I've check the gradle setting and maven setting in eclipse. It seems fine.
So what's the problem?
Do you have other dependencies on this project? It is possible that the "pom.xml" file of one of the packages you are pulling references example-commlib as a dependency and has the Apache Maven URL hardcoded, and resolves the URL beforehand. You can use gradle dependencies to show the dependency tree and find which version is affected. The answers in this post have suggestions on how to force a specific dependency as well: How can I force Gradle to set the same version for two dependencies?

Gradle could not find retrofit dependencies

I need some retrofit2 dependencies for my java project.
In build.gradle additional repositories are declared:
repositories
{
jcenter()
mavenCentral()
mavenLocal()
}
In dependencies section I declared:
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-jackson:2.1.0'
So Gradle could not find them.
I used project-report plugin to analyze dependency tree. I got next report:
Interesting thing that before I used 2.0.2 versions for retrofit libraries and Gradle found them.
Any help will be appreciated.
Gradle version 2.12
If using IntelliJ you can include plugin idea or include plugin eclipse, which gives you an option to run gradle idea or gradle eclipseClasspath tasks and refresh the project with updated/freshly added dependencies.
IDE's are not yet ideal supporting gradle.

How to import maven into my Android Studio project?

There is a library that I would like to use for my Android App: ez Vcard. However this library uses Maven, which I'm not familiar with. I checked online and my Import Project objection doesn't offer pom.xml soo, how can I add the dependency
<dependency>
<groupId>com.googlecode.ez-vcard</groupId>
<artifactId>ez-vcard</artifactId>
<version>0.9.9</version>
</dependency>
into my project and specifically where?
You don't need a maven project, you can use maven dependencies in gradle projects, you'll just have to use a gradle format of the dependency.
This library appears to be hosted on maven central, so you have to link to this repository host in your global build.gradle:
allprojects {
repositories {
mavenCentral()
}
}
To import this dependency into your project, in your module-local build.gradle file input the following lines:
dependencies {
compile 'com.googlecode.ez-vcard:ez-vcard:0.9.9'
// all the other dependencies...
}
You can actually see here all the different dependency formats (under 'Dependency Information'), from maven to gradle, ivy, sbt and so on, they are all compatible with the repository.

gradle idea plugin: libraries marked as "unresolved dependencies"

When trying to run the idea plugin for my gradle project, a number of my intellij libraries are in error with Library: 'gradle: unresolved_dependency_blah_blah' has broken classes path. the library itself is marked as "unresolved dependencies"
My gradle project is a multi module, I have applied the idea plugin to allprojects.
Intellij version is #IU-134.1007
gradle version is 1.11
Any help would be appreciated.
UPDATE: these are an example of some of the dependencies i have:
apply plugin: 'groovy'
dependencies {
compile 'org.eclipse.jgit:org.eclipse.jgit:3.2.0.201312181205-r'
compile 'org.codehaus.groovy:groovy:2.2.1'
testCompile 'org.junit:junit:4.11'
}
all three have the errors
Solved...
The issue was that i had not declared any repositories. (thank you peter)
adding the following to my root project resolved the dependencies correctly:
allprojects {
repositories { mavenCentral() }
}

Maven dependency in a Gradle project

I'm developing a project with gradle. My build file is almost empty so far:
apply plugin: 'java'
apply plugin: 'eclipse'
version = '0.1'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
}
My project depends on a Maven project. Precisely this project: http://git.eclipse.org/c/bpmn2/tree/org.eclipse.bpmn2
I've cloned this project into my workspace, but I don't know the best way to declare the dependency in my build.gradle file. This is what I've done so far:
dependencies {
compile files ("C:/path/to/org.eclipse.bpmn2-0.7.0-SNAPSHOT.jar")
}
But this way I have to manually build the maven project. Does somebody know a better way of doing this dependency management?
I'm using Eclipse Gradle Integration and I've noticed an interesting eclipse project property:
Gradle - Dependency Management
[x] Remap Jars to maven projects (requires Gradle 1.1 and m2e)
This seems to do what I need. But I don't know how to use this feature...
Thanks in advance.
If the Maven project is not available in any Maven repo, Gradle can't find it anywhere, so you'll have to build it. I would at least mvn install it, and tell Gradle to look for artifacts in your local Maven repo rather than in a specific directory, using
repositories {
mavenLocal()
}
The eclipse-integration-gradle plugin replaces the mavenLocal() jar dependency with a Eclipse project dependency. This is the easiest way I've found so far. See: http://forum.springsource.org/showthread.php?139634-How-to-use-quot-remap-Jars-to-maven-projects-quot-feature

Categories