Gradle Error: No method add() found for arguments - gradle

So I'm adding a custom plugin to Gradle, specifically jmeter. https://github.com/kulya/jmeter-gradle-plugin
I thought everything worked, but now this error is occuring:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\rstraubel\Documents\DataCentral\build.gradle' line: 21
* What went wrong:
A problem occurred evaluating root project 'DataCentral'.
> Could not find method add() for arguments [jmeterEditor, class com.github.kulya.gradle.plugins.jmeter.JmeterRunGuiTask] on task set.
Line 21 is just where I call plugin: 'jmeter'
Everything else specified in the github has been done. Any ideas? Thanks
Edit: Full Build.gradle
buildscript {
ext {
springBootVersion = '1.0.2.RELEASE'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-milestone"}
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("com.github.kulya:jmeter-gradle-plugin:1.3.1-2.6")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'idea'
apply plugin: 'sonar-runner'
apply plugin: 'jmeter'
jar {
baseName = 'datacentral'
version = '0.0.1-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-milestone" }
maven { url "http://m2.neo4j.org" }
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
compile "org.springframework.boot:spring-boot-starter-data- mongodb:${springBootVersion}"
compile "com.fasterxml.jackson.core:jackson-databind"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.data:spring-data-mongodb"
compile "org.mongodb:mongo-java-driver:2.12.0-rc0"
compile "org.springframework.data:spring-data-rest-webmvc"
testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"
}
jmeterRun.configure {
jmeterTestFiles = [file("src/test/jmeter/TestCases.jmx")]
}
sonarRunner {
sonarProperties {
property "sonar.host.url", "http://hawkeye.control-tec.com:9000"
property "sonar.jdbc.url", "jdbc:mysql://bluestreak.qualifier.control-tec.com:3306/sonar?useUnicode=true&characterEncoding=utf8"
property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
property "sonar.jdbc.username", "sonar"
property "sonar.jdbc.password", "sonar-pass"
property "sonar.projectKey", "com.controltec.incontrol.qualifier:Data-Central"
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.0'
}

Most likely, the jmeter plugin hasn't been updated to support Gradle 2.0. You can verify by trying with 1.12.

Related

How do I resolve the "Cannot assign 'String' to 'Publication'" Gradle errors in IntelliJ?

I'm using Gradle 6.7 for a project and I'm using IntelliJ. When writing Gradle files or when running inspections, I keep getting this error.
"Cannot assign 'String' to 'Publication'".
Based on the Gradle docs and all the examples, it seems as though my configuration is correct but I'm unable to resolve these warnings.
import org.gradle.api.tasks.testing.logging.TestLogEvent
buildscript {
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
jcenter()
}
dependencies {
classpath "org.github.ngbinh.scalastyle:gradle-scalastyle-plugin_2.11:1.0.1"
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.8"
classpath "net.ltgt.gradle:gradle-nullaway-plugin:0.2"
classpath "gradle.plugin.com.dorongold.plugins:task-tree:1.5"
}
}
}
apply plugin: 'java'
apply plugin: 'scalaStyle'
apply plugin: 'scala'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'net.ltgt.nullaway'
apply plugin: "com.dorongold.task-tree"
apply plugin: "jacoco"
group 'com.mridang'
version '0.0.2'
...
...
publishing {
repositories {
maven {
name = "github"
url = uri("https://maven.pkg.github.com/mridang/myrepo")
credentials(PasswordCredentials)
}
}
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact scaladocJar
pom {
name = 'myproject'
description = 'Foo'
url = 'https://github.com/mridang/myrepo'
issueManagement {
system = "Github"
url = "https://github.com/mridang/myrepo/issues"
}
}
}
}
}
Here's a screenshot that better illustrates the issue:
It is false positive inspection warning. You can vote for this issue in tracker: IDEA-162281.

Gradle: create .jar from .class files and include it in EAR_dir/lib when EAR is built

You'd think this'd be easy enough. Gradle/Maven were designed specifically to get rid of build nightmares. And yet... I have scoured the web, including SO. I would prefer to be using Maven but alas this is not in my control.
My master build.gradle file looks like this:
buildscript {
repositories {
maven { url "https://aaa.com/xxxx/aaa-mvn" }
}
dependencies {
{redacted}
classpath "com.aaa.plugin.gradle:module-plugin:1.+"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.4"
}
}
apply plugin: 'maven-publish'
apply plugin: {redacted}
apply plugin: {redacted}
apply plugin: 'build-defaults'
apply plugin: 'module-plugin'
apply plugin: 'war'
description = 'xxxxxx'
defaultTasks 'build','install'
dependencies {
jbossModule(group: 'com.aaa.bbbb', name: 'inf-jdbc', version: '3.0.2')
}
artifactory {
publish {
repoKey=version.endsWith("SNAPSHOT") ? 'aaa-mvn-dist-snapshots' : 'aaa-mvn-dist'
defaults {
publications('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact project(':xxxEAR').ear
}
}
}
repositories {
maven { url "https://xxxx.aaa.com/artifactory/aaa-mvn" }
}
This is gradle.build for my .war. I have a .war inside an .ear.
description = 'Pricing'
buildscript {
repositories {
maven { url "https://xxx.aaa.com/artifactory/aaa-mvn" }
}
dependencies {
classpath "com.aaa.plugin.gradle:ucd-publish-plugin:1.+"
classpath "com.aaa.plugin.gradle:build-defaults-plugin:1.+"
classpath {redacted}
classpath {redacted}
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'jacoco'
apply plugin: {redacted}
apply plugin: 'ucd-publish'
apply plugin: 'build-defaults'
apply plugin: {redacted}
apply plugin: 'maven'
apply plugin: 'maven-publish'
repositories {
maven { url "https://xxxx.aaa.com/artifactory/aaa-mvn" }
}
war {
archiveName 'xxxx.war'
}
dependencies {
compile {redacted}
compileOnly group: 'javax', name: 'javaee-api', version:'7.0'
testCompile "junit:junit:4.12"
compile 'io.swagger:swagger-annotations:1.5.10'
compile(group: 'com.aaa.inf', name: 'inf-jdbc', version: '3.0.2', classifier: 'sources')
compile(group: 'com.aaa.inf', name: 'inf-throttle', version: '3.0.1')
compile(group: 'com.ibm.db2', name: 'db2jcc', version: '3.64.133')
compile {redacted}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.0
}
}
}
}
The build.gradle file for my .ear is:
description = 'xxxxx'
buildscript {
repositories {
maven { url "https://xxxx.aaa.com/artifactory/aaa-mvn" }
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.5"
classpath "com.aaa.plugin.gradle:build-defaults-plugin:1.+"
classpath "com.aaa.plugin.gradle:ucd-publish-plugin:1.+"
classpath "com.aaa.plugin.gradle:openapi-generator-gradle-plugin:1.+"
}
}
apply plugin: 'ear'
apply plugin: 'maven'
apply from: 'build.local-jboss.gradle'
apply plugin: 'maven-publish'
apply plugin: {redacted}
apply plugin: 'ucd-publish'
apply plugin: 'build-defaults'
apply plugin: {redacted}
configurations{
gen
}
dependencies {
deploy project (path: ":pricingWAR", configuration: 'archives')
earlib 'com.aaa.inf:inf-api-auth:1.4.+'
earlib {redacted}
earlib group: 'javax.security.enterprise', name: 'javax.security.enterprise-api', version: '1.0'
earlib (group: {redacted}) {
exclude group: 'javax.security.dddddd'
}
gen "io.swagger:swagger-codegen:2.2.2"
}
artifacts{
archives ear
}
repositories {
maven {
url "https://xxxx.aaa.com/artifactory/aaa-mvn"
}
}
task cleanVolumes(type: Delete) {
delete fileTree(dir: "./volumes/deployments/")
}
task copyEar(type: Copy) {
tasks.cleanVolumes.execute()
from "build/libs"
into "${project.projectDir}/volumes/deployments"
fileMode = 0644
}
build.finalizedBy(generateSwagger)
swaggerConfig {
archive = ear.archivePath
outputFormat = "JSON"
outputPath = project.buildDir.toString() + "/swagger"
}
Just looking to do this: .jar up the .class files compiled in my business classes and add them to EAR_file\lib.
I've gone so far as to try to use Gradle's native Groovy nature to write code that builds the .jar and moves it into EAR_file\lib. This of course is ridiculous. And worse still, it does not quite work. Paired with auto-deploy there are timing issues.
Some of you no doubt are wincing.
To save me from such insanity, please let me know what you know about this. I have of course tried various permutations of:
apply plugin: 'java'
...
jar {
...
}
to no avail.
Thank you in advance.
Finally have it working after helpful input from coworkers. For others' benefit here is the whole thing it ended up as:
In build.gradle in the EAR project level:
// My project is named: xxx-svc and the .war subproject is named pricing-theAPI
dependencies {
deploy project (path: ":xxx-theAPI", configuration: 'archives') // This was here already
earlib project(path: ":xxx-theAPI", configuration: 'customJar') // This is new
}
In build.gradle in the WAR project level:
configurations {
customJar
}
task doJar(dependsOn:classes, type: Jar){
from sourceSets.main.output
include 'com/xyz/xxxxx/yyyyyy/zzzz/**' // See Note 1
}
artifacts {
customJar doJar
}
Note 1: I added this modifier b/c in my case I needed only the .class files at the given location in the .jar and in fact had to exclude all others. Note the Gradle docs have the modifier "include" misidentified. They call it "includes" but in fact it is "include".

Could not find method cargo() for arguments

I am trying to deploy war to tomcat with gradle cargo,i am getting error could not found method cargo()
C:\Users\naresh.vatsal\workspace_spring_jan14\SpringMvcUsingGradle>gradle build
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\naresh.vatsal\workspace_spring_jan14\SpringMvcUsingGradle\build.gradle' line: 45
What went wrong:
A problem occurred evaluating root project 'SpringMvcUsingGradle'.
Could not find method cargo() for arguments [build_3gitu3al50b7kv8zi1ebj3qsr$runclosure3#302aa00f] on root project 'SpringMvcUsingGradle'.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat-base'
apply plugin: 'com.bmuschko.cargo-base'
ext.tomcatVersion = '7.0.67'
sourceCompatibility = 1.7
buildscript {
repositories {
maven {
url "https://plugins.grdev.net/m2/"
}
}
dependencies {
classpath "com.bmuschko:gradle-tomcat-plugin:2.2.4"
classpath 'com.bmuschko:gradle-cargo-plugin:2.2'
}
}
repositories {
mavenCentral()
}
dependencies {
def cargoVersion = '1.4.5'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
"org.codehaus.cargo:cargo-ant:$cargoVersion"
compile 'org.springframework:spring-context:4.0.0.RELEASE'
compile 'org.springframework:spring-webmvc:4.0.0.RELEASE'
compile 'org.aspectj:aspectjrt:1.7.4'
compile 'javax.inject:javax.inject:1'
compile 'javax.servlet:jstl:1.2'
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'org.slf4j:jcl-over-slf4j:1.7.5'
compile 'org.slf4j:slf4j-log4j12:1.7.5'
compile 'log4j:log4j:1.2.15'
testCompile 'junit:junit:4.7'
}
cargo {
containerId = 'tomcat7x'
port = 8080
local {
homeDir = file('C:/mdi/soft/apache-tomcat-7.0.67')
output = file('C:/mdi/soft/apache-tomcat-7.0.67/output.log')
}
}
war {
version = ''
}
It seems, that you've applied the wrong plugin at the moment. Just change:
apply plugin: 'com.bmuschko.cargo-base'
to
apply plugin: 'com.bmuschko.cargo'
Because, when you apply the com.bmuschko.cargo-base plugin, you have to configure each task individually, according to the plugin description.
And one more, there is no property output, which could be defined within the local closure, but there is an outputFile property, so, your local closure should look like:
local {
homeDir = file('C:/mdi/soft/apache-tomcat-7.0.67')
outputFile = file('C:/mdi/soft/apache-tomcat-7.0.67/output.log')
}

Gradle 2.8 cargo war deployment compile method not found

le 'C:\Users\naresh.vatsal\workspace_spring_jan14\SpringMvcUsingGradle\build.gradle' line: 28
ent wrong:
m occurred evaluating root project 'SpringMvcUsingGradle'.
not find method compile() for arguments [org.springframework:spring-context:4.0.0.RELEASE] on org.gradle.api.internal.artifacts.dsl.dependencies.Default
cyHandler_Decorated#434c4af3.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat-base'
apply plugin: 'com.bmuschko.cargo'
ext.tomcatVersion = '7.0.67'
ext.cargoVersion = '1.1.3'
sourceCompatibility = 1.7
buildscript
{
repositories {
maven {
url "https://plugins.grdev.net/m2/"
mavenCentral()
}
}
dependencies {
classpath "com.bmuschko:gradle-tomcat-plugin:2.2.4"
classpath 'com.bmuschko:gradle-cargo-plugin:2.2'
}
dependencies {
compile 'org.springframework:spring-context:4.0.0.RELEASE'
compile 'org.springframework:spring-webmvc:4.0.0.RELEASE'
compile 'org.aspectj:aspectjrt:1.7.4'
compile 'javax.inject:javax.inject:1'
compile 'javax.servlet:jstl:1.2'
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'org.slf4j:jcl-over-slf4j:1.7.5'
compile 'org.slf4j:slf4j-log4j12:1.7.5'
compile 'log4j:log4j:1.2.15'
testCompile 'junit:junit:4.7'
}
}
cargo {
containerId = 'tomcat7x'
port = 8080
local {
homeDir = file('C:/mdi/soft/apache-tomcat-7.0.67')
output = file('C:/mdi/soft/apache-tomcat-7.0.67/output.log')
}
}
war {
version = '' `enter code here`
}

running gradle jettyRun error

I am trying to run my spring Boot Application using gradle jettyRun but when gradle is compilingJava these errors appear:
alberto#alberto-desktop:~/Credito/PalmasServer$ gradle jettyRun
:compileJava
FAILURE: Build failed with an exception.
What went wrong:
Could not resolve all dependencies for configuration ':compile'.
Could not find org.springframework.data:spring-data-rest-webmvc:.
Required by:
:PalmasServer:unspecified
Could not find org.hsqldb:hsqldb:.
Required by:
:PalmasServer:unspecified
Could not find com.h2database:h2:.
Required by:
:PalmasServer:unspecified
Could not find nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:.
Required by:
:PalmasServer:unspecified
Could not find org.thymeleaf.extras:thymeleaf-extras-springsecurity3:.
Required by:
:PalmasServer:unspecified
Could not find org.thymeleaf:thymeleaf-spring4:.
Required by:
:PalmasServer:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 35.664 secs
And this is my build.gradle File:
buildscript {
ext {
springBootVersion = '1.1.9.RELEASE'
}
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.9.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'application'
sourceCompatibility = 1.7
targetCompatibility = 1.7
war {
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "http://maven.springframework.org/milestone" }
flatDir {
dirs 'lib'
}
}
dependencies {
compile "xerces:xercesImpl:2.9.0"
compile "net.sourceforge.nekohtml:nekohtml:1.9.12"
compile "nekohtml:nekodtd:0.1.11"
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-tomcat:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-aop:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
compile("org.springframework.data:spring-data-rest-webmvc")
compile("org.springframework.boot:spring-boot-starter-security:1.0.2.RELEASE")
compile("org.springframework.security.oauth:spring-security-oauth2:2.0.0.RC2")
compile("org.springframework.security.oauth:spring-security-oauth2-javaconfig:1.0.0.M1")
compile("org.hsqldb:hsqldb")
compile("com.h2database:h2")
compile("com.google.guava:guava:17.0")
compile("org.apache.commons:commons-lang3:3.3.2")
compile("org.apache.httpcomponents:httpclient:4.3.4")
compile("com.squareup.retrofit:retrofit:1.6.0")
compile("commons-io:commons-io:2.4")
compile("com.github.davidmarquis:fluent-interface-proxy:1.3.0")
compile ("org.springframework.boot:spring-boot-starter-security:1.0.2.RELEASE")
compile ("javax.servlet:jstl:1.2")
compile ("commons-fileupload:commons-fileupload:1.3.1")
testCompile("junit:junit")
compile("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect")
compile("org.thymeleaf.extras:thymeleaf-extras-springsecurity3")
compile("org.thymeleaf:thymeleaf-spring4")
def poiVersion = "3.10.1"
compile "org.apache.poi:poi:${poiVersion}"
compile "org.apache.poi:poi-ooxml:${poiVersion}"
compile "org.apache.poi:ooxml-schemas:1.1"
}
jar {
baseName = 'gs-uploading-files'
version = '0.1.0'
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
Why when i am running in Eclipse all is OK????
Any other idea?
Try adding the following piece of code:
compile fileTree(dir: 'lib', include: ['*.jar'])
to dependencies block.

Resources