Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

could not find method compile() for arguments

Tags:

gradle

I'm trying to execute some .sql scripts and then deploy web app using gradle tomcat plugin.

But when I make any attempt to run gradle I've got an error

enter image description here

My buildscript looks like this

buildscript {
//repository location
repositories {
    mavenCentral()
    jcenter()
}
//dependencies
//did not divide them into runtime&compile
dependencies {
    //aspectJ dependencies
    compile 'org.aspectj:aspectjlib:1.6.2'
    compile 'org.aspectj:aspectjrt:1.7.4'
    compile 'org.aspectj:aspectjweaver:1.7.4'
    //servlet
    compile 'javax.servlet:javax.servlet-api:3.0.1'
    //jdbc postresql
    compile 'org.postgresql:postgresql:9.2-1004-jdbc4'
    //commons dbcp
    compile 'commons-dbcp:commons-dbcp:1.2.2' 
    //spring & spring MVC dependencies
    compile 'org.springframework:spring-core:' + spring_version
    compile 'org.springframework:spring-web:' + spring_version
    compile 'org.springframework:spring-webmvc:' + spring_version
    compile 'org.springframework:spring-jdbc:' + spring_version
    compile 'org.springframework:spring-aspects:' + spring_version
    //spring security
    compile 'org.springframework.security:spring-security-core:' + spring_security_version
    compile 'org.springframework.security:spring-security-web:' + spring_security_version
    compile 'org.springframework.security:spring-security-config:' + spring_security_version
    //JSTL
    compile 'jstl:jstl:1.2'
    //slf4j-log4j
    compile 'org.slf4j:slf4j-api:1.7.0'
    compile 'org.slf4j:slf4j-log4j12:1.7.0'
    compile 'log4j:log4j:1.2.17'
    //mybatis
    compile 'org.mybatis:mybatis:3.2.4'
    compile 'org.mybatis:mybatis-spring:1.2.2'
    //gson
    compile 'com.google.code.gson:gson:2.2.4'
    //validation jsr303
    compile 'javax.validation:validation-api:1.0.0.GA'
    //junit4(test?)
    compile 'junit:junit:4.11'
    //spring test(test?)
    compile 'org.springframework:spring-test:' + spring_version
    //java mail
    compile 'javax.mail:mail:1.4'

    //tomcat plugin
    def tomcatVersion = '7.0.53'
    tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
        "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
    tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
        exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
    }

    //additional classpath
    classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3'
    classpath 'org.postgresql:postgresql:9.2-1004-jdbc4'
}
}

In build.gradle there are also several tasks and several apply plugin.

What's the problem? Full stack trace

enter image description here

My build.gradle is in a project folder.

like image 594
lapots Avatar asked May 13 '14 09:05

lapots


People also ask

Could not find method compile () for arguments react native?

You can fix this issue by replacing compile with implementation in node_modules/react-native-geocoder/android/build. gradle.

How do I know which version of Gradle is installed?

Verify Gradle Installation. Now open the command prompt. In the command prompt, enter Gradle -version. It will display the current version of Gradle just installed on the screen.

What is compileOnly in gradle?

compileOnly. Gradle adds the dependency to the compile classpath only (that is, it is not added to the build output). This is useful when you're creating an Android module and you need the dependency during compilation, but it's optional to have it present at runtime.


2 Answers

The build script is mixing up buildscript dependencies (i.e.

  1. dependencies of the build itself; typically this means Gradle plugins
  2. with regular dependencies (i.e. dependencies of the code to be compiled/run).

2 needs to go into dependencies { ... }, not into buildscript { dependencies { ... } }.

Everything but the classpath dependencies are regular dependencies.

like image 140
Peter Niederwieser Avatar answered Sep 17 '22 15:09

Peter Niederwieser


I get this error sometimes after Android Studio does some operation that tries to automatically add things to my build.gradle file, and then it messes up lines of code in the dependencies block that end with quotes or double-quotes. So I end up with a line like this:

def gpsVersion = '9.4.0'
compile "com.google.android.gms:play-services-wearable:${gpsVersion}" compile "com.google.android.gms:play-services-places:${gpsVersion}"

And as you can see it looks like the method compile has many arguments now. Fix the line spacing and resync to fix it.

like image 27
elliptic1 Avatar answered Sep 17 '22 15:09

elliptic1