Jcenter() exception in gradle 2.3 - grails

I am getting below exception when trying to run Soapui through gradle. I am using latest gradle 2.3
* What went wrong:
A problem occurred evaluating root project 'gradle-builds'.
> Could not find method JCenter() for arguments [] on repository container.
Belos is my build.gradle. First I ran without task wrapper gave me the same exception , then I added task wrapper but still getting the exception. Can someone help, pls?
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
buildscript {
repositories {
JCenter()
}
dependencies {
compile files('C:/.../SoapUI-5.0.0/bin/soapui-5.0.0.jar')
compile fileTree(dir: "C:/.../SoapUI-5.0.0/lib", include: '*.jar')
classpath 'com.lv.plugins:soapui-gradle-plugin:VERSION'
}
}
soapui {
test {
projectFile = 'C:/Users/.../soapui-project.xml'
printReport = true
junitReport = true
}
tool {
projectFile = 'C:/../soapui-project.xml'
iface = 'IOrderService'
tool = 'wsi,axis1,axis2'
}
}

It should be just:
jcenter()
all lowercase. See the docs.

Related

How to install the snapshot jar by Gradle?

For this project, I want to install the jar files into my local repository. So far, I modified the build.gradle to this:
buildscript {
dependencies {
classpath 'io.spring.gradle:spring-build-conventions:0.0.33.RELEASE'
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
classpath 'io.spring.nohttp:nohttp-gradle:0.0.5.RELEASE'
}
repositories {
mavenLocal() // 使用本地仓库
maven { url 'https://repo.spring.io/plugins-snapshot' }
maven { url 'https://plugins.gradle.org/m2/' }
}
}
plugins{
id 'maven-publish'
}
apply plugin: 'io.spring.nohttp'
apply plugin: 'locks'
apply plugin: 'io.spring.convention.root'
apply plugin: 'maven'
group = 'org.springframework.security.experimental'
description = 'Spring Authorization Server'
ext.snapshotBuild = version.contains("SNAPSHOT")
repositories {
mavenLocal() // 使用本地仓库
mavenCentral()
}
// 指定上传的路径
def localMavenRepo = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
// 上传Task,Gradle会生成并上传pom.xml文件。
uploadArchives {
repositories {
mavenDeployer {
repository(url: localMavenRepo)
//构造项目的Pom文件
pom.project {
name = project.name
packaging = 'jar'
description = 'description'
}
}
}
}
publishing {
// 配置发布的地址
repositories{
// 一. 这种方式是最简便的方式
mavenLocal()
}
}
dependencyManagementExport.projects = subprojects.findAll { !it.name.contains('-boot') }
subprojects {
plugins.withType(JavaPlugin) {
project.sourceCompatibility = "1.8"
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
}
nohttp {
allowlistFile = project.file("etc/nohttp/allowlist.lines")
}
When running gradle uploadArchives, this is the error I received:
Execution failed for task ':spring-security-oauth2-authorization-server:uploadArchives'.
Could not publish configuration 'archives'
Must specify a repository for deployment
Also, when running artifactory publishing, this is the error I received:
Execution failed for task ':artifactoryDeploy'.
java.io.IOException: Failed to deploy file. Status code: 401 Response message: Artifactory returned the following errors:
Artifactory configured to accept only encrypted passwords but received a clear text password, getting the encrypted password can be done via the WebUI. Status code: 401
Any idea?
The install task will deploy artifacts to Maven repositories, including local. See the Maven Plugin for details.
If you want to reference the snapshot jar for Spring Authorization Server then ensure you have the following in your gradle build file:
dependencies {
compile 'org.springframework.security.experimental:spring-security-oauth2-authorization-server:0.1.0-SNAPSHOT'
}
repositories {
maven { url 'https://repo.spring.io/snapshot' }
}
For additional details, see the Spring Security reference for Gradle setup.

Adding jcenter() in rootlevel repositories breaks my build

I have a project with a Gradle buildscript and I added the bmuschko/gradle-docker-plugin to create and push image on new builds.
However I cant use the plugin if I don't specify jcenter() in root level repositories, but that breaks my build, so im kinda lost.
If I add the root level jcenter() it fails the build with:
Could not resolve all dependencies for configuration ':compileClasspath'.
Could not find com.sleepycat:je:7.0.6. Searched in the following locations:
https://jcenter.bintray.com/com/sleepycat/je/7.0.6/je-7.0.6.pom
https://jcenter.bintray.com/com/sleepycat/je/7.0.6/je-7.0.6.jar
https://repo1.maven.org/maven2/com/sleepycat/je/7.0.6/je-7.0.6.pom
https://repo1.maven.org/maven2/com/sleepycat/je/7.0.6/je-7.0.6.jar
https://nexus.company.com/content/groups/public/com/sleepycat/je/7.0.6/je-7.0.6.pom
https://nexus.company.com/content/groups/public/com/sleepycat/je/7.0.6/je-7.0.6.jar
Required by: project : > org.jpos:jpos:2.1.1
However if I don't add it i get this:
Could not resolve all dependencies for configuration ':dockerJava'.
Could not find com.aries:docker-java-shaded:3.1.0-rc-3. Searched in the following locations:
https://nexus.company.com/content/groups/public/com/aries/docker-java-shaded/3.1.0-rc-3/docker-java-shaded-3.1.0-rc-3.pom
https://nexus.company.com/content/groups/public/com/aries/docker-java-shaded/3.1.0-rc-3/docker-java-shaded-3.1.0-rc-3-cglib.jar
Required by: project :
Should I perhaps build Java shaded and include in our local Maven repo?
Here is the script:
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url = 'https://nexus.company.com/content/repositories/snapshots/'
credentials {
username 'na'
password 'na'
}
}
}
dependencies {
classpath group: 'com.company.gradle', name: 'cpmgradle', version: '0.1-SNAPSHOT'
classpath 'com.bmuschko:gradle-docker-plugin:3.4.4'
}
}
// ADDING THIS BREAKS MY BUILD BUT IS NECESSARY FOR DOCKER PLUGIN TO WORK
repositories {
jcenter()
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.company.gradle.java'
apply plugin: 'com.bmuschko.docker-remote-api'
projectinfo {
group = 'com.company.mesb'
artifact = 'MESB'
version = '1.29.DEV-SNAPSHOT'
description = 'MESB'
packaging = 'jar'
}
dependencies {
compile 'org.jpos:jpos:2.1.1'
compile 'org.jdom:jdom2:2.0.6'
compile 'org.json:json:20140107'
compile 'com.company.javasdk:JavaSDK:1.1.JDOM2-SNAPSHOT'
compile 'com.company.javasdk:Base64:1.0'
compile 'org.apache.wss4j:wss4j-ws-security-dom:2.0.3'
compile 'org.apache.santuario:xmlsec:2.0.3'
compile 'org.slf4j:slf4j-log4j12:1.7.10'
compile 'com.google.code.gson:gson:2.3.1'
compile 'org.bouncycastle:bcprov-jdk15on:1.54'
compile 'org.bouncycastle:bcpkix-jdk15on:1.54'
compile 'junit:junit:4.12'
compile 'org.jsoup:jsoup:1.9.2'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.ibm:mq:5.3.07'
compile 'com.ibm:mq.pcf:5.3.07'
compile 'com.ibm:mq.jmqi:5.3.07'
compile 'com.ibm:mq.headers:5.3.07'
compile 'com.ibm:mq.commonservices:5.3.07'
compile 'com.ibm:connector:1.0.0'
runtime 'jaxen:jaxen:1.1.6'
runtime 'xalan:xalan:2.7.2'
runtime 'org.postgresql:postgresql:8.0-311.jdbc3'
runtime 'commons-logging:commons-logging:1.2'
}
compileJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
options.fork = true
options.compilerArgs << '-XDignore.symbol.file'
options.forkOptions.executable = 'javac'
}
task libs(type: Copy) {
description = "Copies dependencies to the 'lib' directory of the deployment."
def libsDir = new File("$buildDir", 'libs')
libsDir.mkdirs()
def dockerDir = new File("$buildDir", 'docker')
dockerDir.mkdirs()
from project.configurations.runtime
into libsDir
}
task bundleZip(type: Zip) {
from projectDir
include 'xsl/**'
include 'conf/**'
include 'js/**'
include 'test/**'
include 'mesb.sh'
from(tasks.libs.outputs) {
include 'MESB*'
}
into project.projectinfo.version
}
tasks.bundleZip.dependsOn jar
tasks.bundleZip.dependsOn libs
def dockerUsername = project.properties['dockerUsername'] ?: ""
def dockerPassword = project.properties['dockerPassword'] ?: ""
docker {
registryCredentials {
username = dockerUsername
password = dockerPassword
}
}
task buildImage(type: com.bmuschko.gradle.docker.tasks.image.DockerBuildImage) {
doFirst {
copy {
from "${buildDir}/libs/MESB-${projectinfo.version}.jar"
into "${buildDir}/docker"
rename { String fileName ->
fileName.replace("-${projectinfo.version}", "")
}
}
copy {
from "docker/jdk/Dockerfile"
into "${buildDir}/docker"
}
copy {
from "xsl"
into "${buildDir}/docker/xsl"
}
copy {
from "conf"
into "${buildDir}/docker/conf"
}
copy {
from "test"
into "${buildDir}/docker/test"
}
copy {
from "${buildDir}/libs"
into "${buildDir}/docker/libs"
}
}
inputDir = project.file("${buildDir}/docker")
tag = "company/mesb:${projectinfo.version}"
}
tasks.buildImage.dependsOn build
task pushImage(type: com.bmuschko.gradle.docker.tasks.image.DockerPushImage) {
imageName = "company/mesb"
tag = "${projectinfo.version}"
}
tasks.pushImage.dependsOn buildImage
artifacts {
archives bundleZip
}
/* Remove the default JAR file from the uploaded artifacts */
configurations.archives.artifacts.with { archives ->
def jarArtifact
archives.each {
if (it.file =~ 'jar') {
jarArtifact = it
}
}
remove(jarArtifact)
}
jar {
dependsOn configurations.runtime
manifest {
attributes 'Main-Class': 'main.MESB'
}
}
tasks.build.dependsOn libs
sourceSets {
main {
java {
srcDir 'src'
}
}
}
Apparently moving root repository definitions benieth the apply plugins section solved this.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.company.gradle.java'
apply plugin: 'com.bmuschko.docker-remote-api'
repositories {
jcenter()
mavenCentral()
}
Don't know whether you have solved your issue but either way...
I encountered a similar issue regarding:
Could not resolve all dependencies for configuration ':dockerJava'.
Could not find com.aries:docker-java-shaded:3.1.0-rc-3.
We solved it by adding the following
repositories {
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}

Gradle Jacoco and JUnit5

We just ported our unit tests to JUnit5. Realizing that this is still rather early adoption with little hints on google.
The most challenging was to get jacoco code coverage for the Junit5 tests which we use on jenkins. Since this took me almost a day to figure out, I thought I share. Nevertheless, if you know of a better solution I would be interested to know!
buildscript {
dependencies {
// dependency needed to run junit 5 tests
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M2'
}
}
// include the jacoco plugin
plugins {
id 'jacoco'
}
dependencies {
testCompile "org.junit.jupiter:junit-jupiter-api:5.0.0-M2"
runtime "org.junit.jupiter:junit-jupiter-engine:5.0.0-M2"
runtime "org.junit.vintage:junit-vintage-engine:4.12.0-M2"
}
apply plugin: 'org.junit.platform.gradle.plugin'
Then the problem seems to be that junitPlatformTest as defined in the org.junit.platform.gradle.plugin is defined too
late in the gradle lifecycle phase and hence is unknown when the script is parsed.
The following hack is needed in order to still be able to define a jacoco task which observes the junitPlatformTest task.
tasks.whenTaskAdded { task ->
if (task.name.equals('junitPlatformTest')) {
System.out.println("ADDING TASK " + task.getName() + " to the project!")
// configure jacoco to analyze the junitPlatformTest task
jacoco {
// this tool version is compatible with
toolVersion = "0.7.6.201602180812"
applyTo task
}
// create junit platform jacoco task
project.task(type: JacocoReport, "junitPlatformJacocoReport",
{
sourceDirectories = files("./src/main")
classDirectories = files("$buildDir/classes/main")
executionData task
})
}
}
Finally it is necessary to configure the junitPlatform plugin. The following code allows command line configuration of which junit 5 tags shall be run:
You can run all tests with 'unit' tag by running:
gradle clean junitPlatformTest -PincludeTags=unit
You can run all tests which are missing both unit and integ tag using
gradle clean junitPlatformTest -PexcludeTags=unit,integ
If no tags are provided all tests will be run (default).
junitPlatform {
engines {
include 'junit-jupiter'
include 'junit-vintage'
}
reportsDir = file("$buildDir/test-results")
tags {
if (project.hasProperty('includeTags')) {
for (String t : includeTags.split(',')) {
include t
}
}
if (project.hasProperty('excludeTags')) {
for (String t : excludeTags.split(',')) {
exclude t
}
}
}
enableStandardTestTask false
}
Thank you, so the hack now looks like this:
project.afterEvaluate {
def junitPlatformTestTask = project.tasks.getByName('junitPlatformTest')
// configure jacoco to analyze the junitPlatformTest task
jacoco {
// this tool version is compatible with
toolVersion = "0.7.6.201602180812"
applyTo junitPlatformTestTask
}
// create junit platform jacoco task
project.task(type: JacocoReport, "junitPlatformJacocoReport",
{
sourceDirectories = files("./src/main")
classDirectories = files("$buildDir/classes/main")
executionData junitPlatformTestTask
})
}
Can be also resolved with direct agent injection:
subprojects {
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.9"
}
configurations {
testAgent {
transitive = false
}
}
dependencies {
testAgent("org.jacoco:org.jacoco.agent:0.7.9:runtime")
}
tasks.withType(JavaExec) {
if (it.name == 'junitPlatformTest') {
doFirst {
jvmArgs "-javaagent:${configurations.testAgent.singleFile}=destfile=${project.buildDir.name}/jacoco/test.exec"
}
}
}
}
then report will be available with jacocoTestReport task
To get a reference to the junitPlatformTest task, another option is to implement an afterEvaluate block in the project like this:
afterEvaluate {
def junitPlatformTestTask = tasks.getByName('junitPlatformTest')
// do something with the junitPlatformTestTask
}
See my comments on GitHub for JUnit 5 for further examples.
You just need to add #RunWith(JUnitPlatform.class) to your package
#RunWith(JUnitPlatform.class)
public class ClassTest {
}

Spring Data Neo4j how to aggregate

Im trying to do what I think should be a very basic task but I'm getting steam rolled. My code is as follows:
#Query("match (x:Package) where x.houseAirwayBill = {self}.houseAirwayBill return count(x)")
#JsonIgnore
Long pieces
#JsonProperty("total_pieces")
Long getPieces(){
return pieces
}
However, it just throws a stack strace saying that it gets a '1' when it wants to get a map... I've been looking at other ways to do this, but I can't get the repository to autowire in the Domain object either... I'm at a loss. Did no one forecee that you'd want to do an aggregate in a domain object?
My build.gradle
buildscript {
repositories {
maven { url "https://repo.spring.io/libs-release" }
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.10.RELEASE")
}
}
apply plugin: "groovy"
apply plugin: 'spring-boot'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = "1.4.38"
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url "http://m2.neo4j.org/content/repositories/releases/"}
maven { url "https://repo.spring.io/libs-release" }
maven { url "https://repo.spring.io/libs-milestone" }
maven { url 'http://repo.spring.io/snapshot' }
}
defaultTasks "clean", "processResources", "build"
dependencies {
//groovy
compile 'org.codehaus.groovy:groovy-all:2.4.0-rc-2'
//spring
compile("org.springframework.boot:spring-boot-starter-web"){
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
compile("org.springframework.boot:spring-boot-starter-jetty")
compile 'org.eclipse.jetty:jetty-servlet:9.3.0.M1'
compile 'org.springframework.boot:spring-boot-actuator:1.2.3.RELEASE'
//compile 'org.springframework.data:spring-data-rest-webmvc:2.3.0.RELEASE'
//compile 'org.springframework.hateoas:spring-hateoas:0.17.0.RELEASE'
compile('org.springframework.boot:spring-boot-starter-data-rest:1.2.3.RELEASE')
//compile 'org.springframework.data:spring-data-neo4j:3.3.0.RELEASE'
compile 'org.springframework.data:spring-data-neo4j-aspects:3.3.0.RELEASE'
//compile "org.neo4j:neo4j-rest-graphdb:2.0.1"
compile("org.hibernate:hibernate-validator")
compile 'javax.persistence:persistence-api:1.0.2'
compile 'org.springframework.data:spring-data-neo4j-rest:3.4.0.BUILD-SNAPSHOT'
compile 'org.springframework.data:spring-data-jpa:1.8.0.RELEASE'
//Jersey
compile 'org.glassfish.jersey.core:jersey-client:2.17'
//JsonSchema stuff
// Required if generating equals, hashCode, or toString methods
compile 'commons-lang:commons-lang:2.6'
// Required if generating JSR-303 annotations
compile 'javax.validation:validation-api:1.1.0.CR2'
// Required if generating Jackson 2 annotations
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.0'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.0'
// Required if generating JodaTime data types
compile 'joda-time:joda-time:2.2'
//Retrofit
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.retrofit:converter-jackson:1.2.2'
//logging
compile 'ch.qos.logback:logback-classic:1.1.2'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
processResources {
expand(project.properties)
}
So, after sleeping over the problem and looking over the documentation, I did this:
#Query("start item=node({self}) match (x:Package) where x.houseAirwayBill= item.houseAirwayBill return count(x)")
#JsonIgnore
def pieces
#JsonProperty("total_pieces")
#Transactional
Long getPieces(){
return pieces.get("count(x)") as Long
}
the start item=node({self}) is really important as it binds the self reference to a parameter which I called Item in this case. The getter NEEDS to be in a transaction as well. I hope this helps because I could not find an specific example on how to do this anywhere.
Code is in groovy btw.

Gradle Geb saucelabs plugin

I'm following the example from http://www.gebish.org/manual/0.9.2/sauce-labs.html#gradle_geb_saucelabs_plugin but am unable to get it working. My build.gradle script is as follows:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.0.0"
classpath 'org.gebish:geb-gradle:0.9.2'
}
}
version "0.1"
group "example"
apply plugin: "grails"
apply plugin: "geb-saucelabs"
repositories {
grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
maven { url "http://repository-saucelabs.forge.cloudbees.com/release" }
}
grails {
grailsVersion = '2.3.5'
groovyVersion = '2.1.9'
springLoadedVersion '1.1.3'
}
dependencies {
bootstrap "org.grails.plugins:tomcat:7.0.50" // No container is deployed by default, so add this
compile 'org.grails.plugins:resources:1.2' // Just an example of adding a Grails plugin
sauceConnect "com.saucelabs:sauce-connect:3.0.28"
}
sauceLabs {
browsers { //5
firefox_linux_19 //Could not find property 'reporting' on root project 'gradleGrailsError'.
chrome_mac
internetExplorer_vista_9
}
task { //6
testClassesDir = test.testClassesDir
testSrcDirs = test.testSrcDirs
classpath = test.classpath
}
account { //7
username = System.getenv("SAUCE_ONDEMAND_USERNAME")
accessKey = System.getenv("SAUCE_ONDEMAND_ACCESS_KEY")
}
}
When I run $gradle test, I get the following error: Could not find property 'reporting' on root project... This error occurs on the line which specifies firefox_linux_19 as the browser. Can someone please advise how I can get the geb-saucelabs plugin working correctly? Thanks.
After a lot of trial and error, I got the following to work:
sauceLabs {
tasks.withType(Test) {
reports.junitXml.destination = reporting.file("test-results/$name")
reports.html.destination = reporting.file("test-reports/$name")
}
browsers { //5
firefox_linux_19
chrome_mac
internetExplorer_vista_9
}
account { //7
username = System.getenv("SAUCE_ONDEMAND_USERNAME")
accessKey = System.getenv("SAUCE_ONDEMAND_ACCESS_KEY")
}
}
The addition of the tasks.withType(Test) was the key, and I also removed the task closure which was listed in the sample code.

Resources