Coder Social home page Coder Social logo

Comments (6)

saladinkzn avatar saladinkzn commented on July 23, 2024

Hello,

I'm afraid there's no way to do it right now as project.sourceSets.main.output is always added in front of classpath.

The only way I can see to achieve this is to put instrumented classes in sourceSets.main.output (build/main/classes) folder overriding default classes.

from gretty.

saladinkzn avatar saladinkzn commented on July 23, 2024

Furthermore I've added support for beforeClassPath in gretty-1.2.6-SNAPSHOT:

gretty {
    beforeClassPath "${buildDir}/instrumentedClasses"
}

from gretty.

x12a1f avatar x12a1f commented on July 23, 2024

Thanks. I tried it but it does not seem to be working. When using beforeClassPath it still uses the normal, uninstrumented, code.

Currently I have it working using the following work around:

cobertura {
    // cobertura in the servlet containter started by gretty looks for the datafile in this
    // location. TODO: pass the location of this file to the servlet using system properties
    coverageOutputDatafile = file("$projectDir/cobertura.ser")
    coverageReportDatafile = file("$projectDir/cobertura.ser")
}

afterEvaluate {
    tasks.appBeforeIntegrationTest {
        gretty {
            servletContainer = 'jetty9'

            // add the instrumented classes to the class path
            classPath "${project.buildDir}/instrumented_classes"

            // add the libraries needed by cobertura to the class path
            configurations.cobertura.each {
                classPath it
            }

        }
    }
    .doFirst {
        // move the classes out of the way so gretty can only see the instrumented_classes
        file("${project.buildDir}/classes/main.nope").deleteDir()
        file("${project.buildDir}/classes/main").renameTo("${project.buildDir}/classes/main.nope")
    }
}

afterEvaluate {
    tasks.appAfterIntegrationTest.finalizedBy 'generateCoberturaReport'

    // move the classes back
    tasks.generateCoberturaReport.doFirst {
        file("${project.buildDir}/classes/main.nope").renameTo("${project.buildDir}/classes/main")
    }
}

from gretty.

saladinkzn avatar saladinkzn commented on July 23, 2024

Nice to hear you found a workaround. I'll take a look again today.

from gretty.

saladinkzn avatar saladinkzn commented on July 23, 2024

Well, using following configuration I was able to achive success with gretty-1.2.6-SNAPSHOT

buildscript {
  repositories {
    mavenLocal()
    jcenter()
    mavenCentral()
  }
  dependencies {
    classpath "ru.shadam.gretty:gretty:$gretty_version"
    classpath "net.saliman:gradle-cobertura-plugin:2.3.1"
  }
}

repositories {
  mavenLocal()
  jcenter()
  maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
}

apply plugin: 'groovy'
apply plugin: 'org.akhikhl.gretty'
apply plugin: 'net.saliman.cobertura'

dependencies {
  compile 'org.webjars:bootstrap:3.2.0'
  compile 'org.webjars:jquery:2.1.1'
  // We use Velocity for example of template processing within the webapp.
  compile 'org.apache.velocity:velocity:1.7'
}

cobertura {
  coverageOutputDatafile = file("$projectDir/cobertura.ser")
  coverageReportDatafile = file("$projectDir/cobertura.ser")
}

afterEvaluate {
  tasks.appBeforeIntegrationTest {
    gretty {
      servletContainer = 'jetty9'

      jvmArgs = ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005']

      beforeClassPath "${project.buildDir}/instrumented_classes/"


      // add the libraries needed by cobertura to the class path
      configurations.cobertura.each {
        classPath it
      }
    }
  }

  tasks.appAfterIntegrationTest.finalizedBy 'coberturaReport'
}

dependencies {
  testCompile "org.codehaus.groovy:groovy-all:$groovy_version"
  testCompile "org.spockframework:spock-core:$spock_version"
  testCompile "org.gebish:geb-spock:$gebVersion"
  testCompile "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
  testCompile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
}

test {
  include '**/Test*.*'
  include '**/*Test.*'
  exclude '**/*IT.*'
}

task integrationTest(type: Test, dependsOn: 'test') {
  outputs.upToDateWhen { false }
  include '**/*IT.*'
  doFirst {
    systemProperty 'geb.build.reportsDir', reporting.file('geb')
  }
}

You should use

maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }

instead of mavenLocal() to reproduce my build.

from gretty.

x12a1f avatar x12a1f commented on July 23, 2024

Yes, I'm not sure what I did wrong earlier but it works. Many thanks!

from gretty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.