Khoulaiz / gradle-jetty-eclipse-plugin

Gradle Jetty Plugin for Eclipse Jetty
Apache License 2.0
38 stars 10 forks source link

Unable to set jettyEclipseRun parameters #9

Open Jerbell opened 10 years ago

Jerbell commented 10 years ago

This seems to be in version 1.9.2.

The task snippet: doFirst { jettyEclipseRun.httpPort = 8080 jettyEclipseRun.daemon = true jettyEclipseRun.execute() }

Will say:

No such property: httpPort for class: com.sahlbach.gradle.plugins.jettyEclipse.JettyEclipseRun Possible solutions: httpPort, stopPort

Khoulaiz commented 10 years ago

Please show me the complete build or at least the complete task definition.

raymondmaxwellsmith commented 10 years ago

I seem to be seeing a similar issue with 1.9.2 (problem does not occur for 1.9.1). The error I get is:

No signature of method: static com.sahlbach.gradle.plugins.jettyEclipse.JettyEclipseRun.doFirst() is applicable for argument types: (build_470jr1vj74331s7ggkv5d65ijs$_run_closure5) values: [build_470jr1vj74331s7ggkv5d65ijs$_run_closure5@421def93] Possible solutions: doFirst(groovy.lang.Closure), doFirst(org.gradle.api.Action), doLast(groovy.lang.Closure), doLast(org.gradle.api.Action)

My complete build file is:

allprojects {
    apply plugin: 'java'
    apply plugin: 'jettyEclipse' 
    group   = 'com.hypermancer'
    version = '0.0.2'
}

// if we need sub-projects then we will need to move these settings into a subprojects clause
buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath (group: 'com.sahlbach.gradle', name: 'gradle-jetty-eclipse-plugin', version: '1.9+')
        classpath (group: 'org.eclipse.jetty', name:'jetty-jsp', version:'9.2.1.v20140609')
        classpath (group: 'org.eclipse.jetty', name:'jetty-webapp', version:'9.2.1.v20140609')
        classpath (group: 'org.eclipse.jetty', name:'jetty-plus', version:'9.2.1.v20140609')
        classpath (group: 'org.eclipse.jetty', name:'jetty-annotations', version:'9.2.1.v20140609')
    }
}

repositories {
    mavenCentral()
}

dependencies {
    // Netflix Componentry
    compile 'org.apache.httpcomponents:httpclient:4.1.2'
    compile 'asm:asm-all:3.2'
    compile 'commons-configuration:commons-configuration:1.9'
    compile 'com.sun.jersey:jersey-core:1.17.1'
    compile 'com.sun.jersey:jersey-server:1.17.1'
    compile 'com.sun.jersey.contribs:jersey-guice:1.17.1'
    compile 'com.netflix.karyon:karyon-extensions:1.0.22'
    compile 'com.netflix.karyon:karyon-admin-web:1.0.22'

    // Utility Libraries
    compile 'com.fasterxml.jackson.core:jackson-core:2.3.1'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.3.1'
    compile 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.3.1'
    compile 'joda-time:joda-time:2.3'
    compile 'commons-io:commons-io:2.4'
    compile 'ch.qos.logback:logback-classic:1.1.1'

    // Couchbase
    compile 'com.couchbase.client:couchbase-client:1.4.3'

    // Testing
    testCompile 'junit:junit:4.11'
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.12'
}

jettyEclipseRun.doFirst( {
    System.setProperty("archaius.deployment.environment","dev")
})
Khoulaiz commented 10 years ago

Very strange, I need some time to figure that out. I don't think it's a source code bug. Either my build environment is different now or gradle or groovy changed something. I'll check that.

Jerbell commented 10 years ago

Here's a copy of my script. Changing the Gradle version seems to have the same behaviour. The task that's failing is integrationTest.

buildscript {
    repositories {
        jcenter()
        maven { url 'http://buildrepo.nowtv.bskyb.com/plugins-release' }
    }

    dependencies {
        classpath 'com.sahlbach.gradle:gradle-jetty-eclipse-plugin:1.9.2',
                  'org.ow2.asm:asm:5.0.3',
                  'org.ow2.asm:asm-commons:5.0.3'
    }
}

apply plugin: 'groovy'
apply plugin: 'jettyEclipse'

sourceCompatibility = 1.7

configurations {
    compile.exclude module: 'commons-logging' // use jcl-over-slf4j
}

repositories {
    mavenCentral()
    jcenter()
}

sourceSets {
    integration {
        resources.srcDirs 'src/integration/features'
    }
}

ext.versions = [
    aspectj: '1.8.1',
    jackson: '2.4.1',
    scala: '2.10',
    spring: '4.0.6.RELEASE',
    springsecurity: '3.2.4.RELEASE'
]

dependencies {
    // server
    providedCompile 'javax.servlet:servlet-api:2.5'

    // app
    compile 'cglib:cglib:3.1',
            'org.objenesis:objenesis:2.1',
            'ch.qos.logback:logback-classic:1.1.2',
            'com.carrotsearch:hppc:0.6.0',
            "com.fasterxml.jackson.core:jackson-databind:$versions.jackson",
            "com.fasterxml.jackson.core:jackson-annotations:$versions.jackson",
            'com.google.guava:guava:17.0',
            'joda-time:joda-time:2.3',
            'org.apache.tomcat:tomcat-jdbc:7.0.54',
            'org.hibernate:hibernate-entitymanager:4.3.5.Final',
            'org.slf4j:slf4j-api:1.7.7',
            'mysql:mysql-connector-java:5.1.31',
            'javax.validation:validation-api:1.1.0.Final',
            'org.hibernate:hibernate-validator:5.1.1.Final',
            "org.aspectj:aspectjtools:$versions.aspectj",
            "org.aspectj:aspectjrt:$versions.aspectj",
            "org.aspectj:aspectjweaver:$versions.aspectj",
            'org.slf4j:jcl-over-slf4j:1.7.7',
            "org.springframework:spring-orm:$versions.spring",
            "org.springframework:spring-webmvc:$versions.spring",
            "org.springframework.security:spring-security-config:$versions.springsecurity",
            "org.springframework.security:spring-security-ldap:$versions.springsecurity",
            'com.googlecode.flyway:flyway-core:2.3.1' // version 3 won't work with MySql 5.0
    compile ("org.springframework.security:spring-security-web:$versions.springsecurity") {
        exclude module: 'spring-jdbc'
        exclude module: 'spring-tx'
    }

    compile 'com.mangofactory:swagger-springmvc:0.8.5',
            "org.scala-lang:scala-library:$versions.scala.+"

    compile "org.springframework:spring-aspects:${versions.spring}"

    testCompile 'junit:junit:4.11',
                'org.mockito:mockito-core:1.9.5',
                'org.hamcrest:hamcrest-core:1.3'

    testCompile 'org.codehaus.groovy:groovy-all:2.3.+',
                'org.codehaus.groovy:groovy-json:2.3.+',
                'info.cukes:cucumber-groovy:1.1.8',
                'org.jdbi:jdbi:2.55',
                'org.apache.httpcomponents:httpclient:4.3.4'
    testCompile ('com.jayway.restassured:json-path:2.3.2') {
        exclude module: 'groovy'
    }

    integrationCompile sourceSets.main.output,
                       sourceSets.test.output,
                       configurations.testCompile
    integrationRuntime sourceSets.main.output,
                       sourceSets.test.output,
                       configurations.testRuntime

}

task integrationTest(type: Test) {
    dependsOn assemble, compileIntegrationGroovy, processIntegrationResources

    doFirst {
        jettyEclipseRun.httpPort = 8080
        jettyEclipseRun.daemon = true
        jettyEclipseRun.execute()
    }

    testClassesDir = sourceSets.integration.output.classesDir
    classpath = sourceSets.integration.runtimeClasspath

    doLast {
        javaexec {
            main = 'cucumber.api.cli.Main'
            classpath = configurations.integrationRuntime + sourceSets.integration.output
            args = [
                '--format', 'pretty',
                '--strict',
                '--glue', 'classpath:steps',
                'src/integration/features'
            ]
            if (System.getProperty('tags') != null && !System.getProperty('tags').isEmpty()) {
                args = ['--tags', System.getProperty('tags')] + args
            }
            systemProperties System.getProperties()
        }

        jettyEclipseStop.stopPort = 9451
        jettyEclipseStop.stopKey = 'secret'
        jettyEclipseStop.execute()
    }
}

jettyEclipse.httpPort = 8080
jettyEclipse.stopPort = 9451
jettyEclipse.stopKey = 'secret'
dai0304 commented 10 years ago

I encountered same problem. When "jettyEclipseRun.doFirst" is executed, the jettyEclipseRun seems to be an instance of not org.gradle.api.Task but java.lang.Class and is class com.sahlbach.gradle.plugins.jettyEclipse.JettyEclipseRun. So, our script attempt to invoke static method doFirst of JettyEclipseRun.