I try to add some import for groovy file.
import groovyx.net.http.RESTClient
import org.apache.http.auth.AuthScope
import org.apache.http.auth.NTCredentials
Try to use option "Find jar on web". As a result I see message "No libraries found for groovyx.net.http.RESTClient".
Same problem was for java projects with adding junit and jsoup libraries, but I just downloaded them.
Where can be a problem?
https://repo1.maven.org/maven2
https://repository.jboss.org/nexus/content/repositories/public/
are used as remote jar repositories
build.gradle file content:
apply plugin: "groovy"
group = "ru.ftc.cs.test"
version = "1.0.0"
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
maven { url "http://diesel.ftc.ru:8080/nexus/content/groups/public/" }
}
dependencies {
testCompile group: "org.codehaus.groovy" , name: "groovy-all" , version: "2.4.5"
testCompile group: "org.codehaus.groovy.modules.http-builder" , name: "http-builder", version: "0.7.1"
testCompile group: "org.spockframework" , name: "spock-core" , version: "1.0-groovy-2.4"
}
Decision:
I need only to run build.gradle correct way to solve a problem.
Related
I have the following Gradle file:
I had this working fine, but all of the sudden it seems like this JPA package cannot be found. I have added it compile("org.springframework.boot:spring-boot-starter-dao-jpa")
Every time I try and build, it complains about this. I check the dependency graph and it has a red underline to show it's missing. What can I do?
buildscript {
ext {
springBootVersion = '2.0.1.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven'
group = 'com.remindful'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-jersey')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-web-services')
compile('org.springframework.boot:spring-boot-starter-websocket')
compile('org.springframework.session:spring-session-core')
compile("org.springframework.boot:spring-boot-starter-dao-jpa")
compile("com.h2database:h2:1.4.191")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile group: 'com.google.guava', name: 'guava', version: '11.0.2'
compile group: 'com.h2database', name: 'h2', version: '1.4.197'
testCompile 'junit:junit:4.12'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.0.1.RELEASE'
}
// To force debug on application boot, switch suspend to y
bootRun {
systemProperties System.properties
jvmArgs=["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"]
}
There is no sign of spring-boot-starter-dao-jpa in the Spring Maven Repository, so I suspect it doesn't exist. Try removing the line.
Maybe this was a copy & paste error from the spring-boot-starter-data-jpa dependency two lines below...?
It looks like when I refactored my project structure, intellij got clever and renamed the dependencies. Be careful on that one!
Running the IDEA IDE I want to add a gradle dependency for the jUnit v5.
Here is my build.gradle file, I used this answer as a guide.
apply plugin: 'java'
sourceCompatibility = 1.8
repositories { mavenCentral() }
apply plugin: 'org.junit.platform.gradle.plugin'
dependencies {
testCompile 'junit:junit:4.12'
compile 'junit:junit:4.12'
testRuntime("org.junit.vintage:junit-vintage-engine:4.12.0-M4")
testCompile("org.junit.jupiter:junit-jupiter-api:5.0.0-M4")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.0.0-M4")
// Enable use of the JUnitPlatform Runner within the IDE
testCompile("org.junit.platform:junit-platform-runner:1.0.0-M4")
compile ("org.junit.jupiter:junit-jupiter-api:5.0.0-M4")
}
sourceSets {
main {
java {
srcDir 'src'
}
}
}
junitPlatform {
details 'tree'
}
The problem here is that the jUnit4 annotations are resolved by import but all the v5 annotations are not resolved.
One example:
#ParameterizedTest
public void testExample() {
// My annotations is not resolved
}
What is the right way to add a jUnit5 dependency using gradle?
EDIT
I started a new gradle java project from scratch to get to the bottom of this.
Here is my current build.gradle.
group 'com.iay0361'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories { mavenCentral() }
apply plugin: 'org.junit.platform.gradle.plugin'
dependencies {
testCompile group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '4.12.0-RC3'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.0.0-RC3'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.0.0-RC3'
compile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.0.0-RC3'
testCompile group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.0.0-RC3'
}
sourceSets {
main {
java {
srcDir 'src'
}
}
}
junitPlatform {
details 'tree'
}
I wrote the #Test annotation in a new class file under test after which it asked me to "add the 'jUnit5' to classpath
which I did and this time selected the Copy 'jUnit5' libraries to... instead of using the IDEA distributor.
Now it added these files in module:
The file is still RC2 but in build.gradle it is RC3.
There are also no jUnit jars in "External Library" directory
What am I missing, the problem is still that the IDE cannot resolve some jUnit5 annotations like #ParamiterizedTest.
Here is a quick sample on how to configure gradle with junit5. In your dependencies, remove the compile statement for the junit:4.12 artifact verison.
// If you also want to support JUnit 3 and JUnit 4 tests
testCompile("junit:junit:4.12")
In the buildscript() method, include these:
buildscript {
repositories { mavenCentral() }
dependencies { classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-RC3' }
}
I have created new Gradle Java project on IntelliJ and added the library like normally do in Android Studio.
Gradle is not getting the library and compiling it.
Build file.
group 'asynjava'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile "io.reactivex.rxjava2:rxjava:2.x.y"
}
I couldn't import the library inside my java files.
Is there any settings I have missed ?
compile 'io.reactivex.rxjava2:rxjava:2.1.2'
You have to specify the complete version info, the minor version numbers in particular.
I am trying to get the text color from the pdf document. I am loading PageDrawer.properties using ResourceLoader in constructor of the class as given below. I have defined pdfbox version to 1.5.0 in build.gradle but it is downloading pdfbox version 2.0.5
public PdfTest() throws IOException {
super(ResourceLoader.loadProperties(
"org/apache/pdfbox/resources/PageDrawer.properties", new Properties()));
super.setSortByPosition(true);
}
By above code I am not able to load property "import org.apache.fontbox.util.ResourceLoader".
Does anyone have any idea why pdfbox 2.0.5 is donloaded instead of 1.5.0? Also how to resolve ResourceLoader issue?
build.gradle
group 'abc'
version '1.0-SNAPSHOT'
apply plugin: 'groovy'
apply plugin: 'java'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '1.8.3'
}
I tried it with IntelliJ it was downloading 1.8.3, but on Android Studio(2.3.2) it was downloading 2.0.5.
I have problems with configure my build.gradle for download jar and pom from svn repository. For example, i have url:
https://svn.code.sf.net/p/springframework/svn/repos/repo-ext/javax/xml/crypto/xmldsig/1.0/
and i want did like this compile group: 'com.sun.xml.wss', name: 'xws-security', version: '3.0'
Also, manual download is wrong way.
UPD this is build.gradle file of backend project
apply plugin: 'java'
dependencies {
compile group: 'org.glassfish.metro', name: 'wssx-api', version: '2.1.1-b09'
compile group: 'com.sun.xml.wss', name: 'xws-security', version: '3.0'
compile project(':pp-backend')
}
If you're not downloading from maven central (which is configured in Gradle by default), you should configure the repository to download from using the 'repositories' closure:
repositories {
mavenCentral()
maven {
url 'https://svn.code.sf.net/p/springframework/svn/repos/repo-ext/'
}
}
Then, in the 'dependencies' closure, just add:
compile group: 'javax.xml.crypto', name: 'xmldsig', version: '1.0'
See more info in Dependency Management Basics