TouK / excel-export

excel-export grails plugin
58 stars 32 forks source link

Compile problems with grails-2.3.2 #11

Closed ankurcha closed 10 years ago

ankurcha commented 10 years ago
[14:01:41][Step 3/6] Starting: ./grailsw test-app
[14:01:41][Step 3/6] in directory: /home/buildacct/work/d5510eb4b3ba04b3/api
[14:01:42][Step 3/6] | Loading Grails 2.3.2
[14:01:44][Step 3/6] | Configuring classpath
[14:01:50][Step 3/6] | Configuring classpath.
[14:01:50][Step 3/6] | Environment set to test
[14:01:50][Step 3/6] | Environment set to test.
[14:01:50][Step 3/6] | Environment set to test..
[14:01:50][Step 3/6] | Environment set to test...
[14:01:50][Step 3/6] | Environment set to test....
[14:01:52][Step 3/6] | Environment set to test.....
[14:01:53][Step 3/6] | Compiling 82 source files
[14:01:58][Step 3/6] Note: /home/buildacct/work/d5510eb4b3ba04b3/api/src/java/analytics/api/DocumentMergerHelper.java uses unchecked or unsafe operations.
[14:01:58][Step 3/6] Note: Recompile with -Xlint:unchecked for details.
[14:01:59][Step 3/6] | Compiling 82 source files.
[14:01:59][Step 3/6] | Error Compilation error: startup failed:
[14:01:59][Step 3/6] /home/buildacct/work/d5510eb4b3ba04b3/api/grails-app/controllers/analytics/api/ApiController.groovy: 11: unable to resolve class pl.touk.excel.export.WebXlsxExporter
[14:01:59][Step 3/6]  @ line 11, column 1.
[14:01:59][Step 3/6]    import pl.touk.excel.export.WebXlsxExporter
[14:01:59][Step 3/6]    ^
[14:01:59][Step 3/6] 
[14:01:59][Step 3/6] 1 error
[14:01:59][Step 3/6] Process exited with code 1
[14:01:59][Step 3/6] Step test (Command Line) failed
jakubnabrdalik commented 10 years ago

You wrote about grails-2.3.1 but your logs show 2.3.2 Anyways, you don't have a problem with compiling excel-export plugin. The problem you have is because you app doesn't see classes from the plugin. Without your config I cannot help you. Make sure you follow https://github.com/TouK/excel-export#how-to-get-it-installed and if you still have problems, take a look at https://github.com/TouK/excel-export-samples

ankurcha commented 10 years ago

Sorry my bad, it is grails-2.3.2. The plugin does work in 2.3.1. I followed the sample to setup my BuildConfig.groovy file

grails.server.port.http = 8080
grails.servlet.version = "3.0"

grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.war.file = "target/${appName}.war"
grails.project.source.level = 1.7
grails.project.target.level = 1.7
grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // uncomment to disable ehcache
        excludes 'grails-plugin-databinding', 'xercesImpl', 'xml-apis'
    }

    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve

    repositories {
        inherits false // Whether to inherit repository definitions from plugins
        grailsPlugins()
        grailsHome()
        grailsCentral()
        mavenLocal()
        mavenCentral()
    }

    dependencies {
        def versions = [
            awsJavaSdk: "1.5.8",
            gmongo: "1.2",
            gpars: "1.1.0",
            httpBuilder: "0.6",
            log4jExtras: "1.1",
            metrics: "2.2.0",
            mongoDriver: "2.11.3",
            openCsv: "2.3"
        ]
        compile("org.mongodb:mongo-java-driver:${versions.mongoDriver}")
        compile("com.gmongo:gmongo:${versions.gmongo}")
        compile("org.codehaus.groovy.modules.http-builder:http-builder:${versions.httpBuilder}") {
            excludes 'xml-apis', 'groovy'
        }
        compile("com.yammer.metrics:metrics-graphite:${versions.metrics}") {
            excludes 'slf4j-api'
        }
        compile("com.yammer.metrics:metrics-servlet:${versions.metrics}")
        compile("com.yammer.metrics:metrics-web:${versions.metrics}")
        compile("log4j:apache-log4j-extras:${versions.log4jExtras}")
        compile("com.amazonaws:aws-java-sdk:${versions.awsJavaSdk}")
        compile("net.sf.opencsv:opencsv:${versions.openCsv}")
        compile("org.codehaus.gpars:gpars:${versions.gpars}")
        compile 'com.brightcove.metrics:metrics-graphite-pickle:1.2.0'
        compile('org.objenesis:objenesis:1.3')
    }

    plugins {
        // plugins for the build system only
        build(':jetty:2.0.3')

        // plugins needed at runtime but not for compilation

        // compile time plugins
        runtime ":excel-export:0.1.8"
        runtime ":cors:1.1.1"
    }
}

I don't think i am doing anything special as far as the usage is concerned either

xlsx {
                def items = output.remove('items')
                def exporter = new WebXlsxExporter()
                response.setHeader("Content-Type", "application/vnd.ms-excel")
                response.setHeader("Content-disposition", "attachment; filename=\"${filename}.xlsx\"")
                if(items) {
                    def headers = (output.keySet() + items[0].keySet()) as List
                    exporter.fillHeader(headers)
                    items.eachWithIndex { item, i ->
                        def row = headers.collect { item.containsKey(it) ? item[it] : output[it] }
                        exporter.fillRow(row, i + 1) // fillRow(list) always adds to the 1st

                    }
                }
                exporter.save(response.outputStream)
            }
jakubnabrdalik commented 10 years ago

Ok, I was able to replicate this problem in sample app, with Grails 2.3.2. It works with Grails 2.3.1, and with in-place plugins in Grails 2.3.2. No idea why, so far.

jakubnabrdalik commented 10 years ago

Ok, it seems I've solved the problem in my test-app. Does look like some mess in grails dependency resolver.

Upgrade your excel-export depencency to '0.1.9' Try running: grails refresh-dependencies

and if it doesn't work, do:

rm -rf ~/.grails/2.3.2/projects/excel-export rm -rf ~/.grails/ivy-cache/org.grails.plugins/excel-export rm -rf ~/.m2/repository/org/grails/plugins/excel-export grails clean grails refresh-dependencies

Let me know if it works for you.

jakubnabrdalik commented 10 years ago

Assuming my solution works for you, after 2 months of lack of feedback, I'm closing this issue.