GoogleCloudPlatform / gradle-appengine-plugin

Gradle plugin that provides tasks for uploading, running and managing Google App Engine projects
Apache License 2.0
236 stars 60 forks source link

Stackdriver debugger: no source-context.json? #243

Open renaudcerrato opened 8 years ago

renaudcerrato commented 8 years ago

I'm unable to use stackdriver debugger because it seems there's no source-context.json uploaded during appengineUpdate:

image

renaud@null:~/Workspace/project$ ./gradlew appengineUpdate && find . -name "source-context.json"
renaud@null:~/Workspace/project$

I'm using 1.9.34 - Any clue?

loosebazooka commented 8 years ago

I think source context is exclusively for git managed projects. What way are you trying to use it? I believe it tries to detect the current git commit in your project. I think the workflow expects you to commit before you deploy. some docs here

I believe it's not create during a "build-step" as much as it is during a "deploy-step" so you wont really see it. What you need to do is inspect the intermediate deploy directory.

You can preserve the intermediate staging directory in appcfg by adding an option in your build file

appengine {
  appcfg {
    extraOptions = ["--retain_upload_dir"]
  }
}

you should see output like

:appengineUpdate
Beginning interaction for module tomato...
0% Created staging directory at: '/tmp/appcfg7883550217978681461.tmp'
..
..
..
Temporary staging for module tomato directory left in /tmp/appcfg7883550217978681461.tmp

If you go and inspect that directory (specifically in WEB-INF/classes, you should be able to see whether source-context.json was created or not.

(on linux) running ls in that directory shows the com (the first part of my java packages) and a source-context.json

test@test-machine: /tmp/appcfg7883550217978681461.tmp/WEB-INF/classes$ ls
com  source-context.json
renaudcerrato commented 8 years ago

Thanks! Sure, I'm using git, and changes are commited to google's repo - but there's no source-context.json produced :-/

renaud@null:~/Workspace/project$ git remote -v
dev     https://source.developers.google.com/p/***-dev (fetch)
dev     https://source.developers.google.com/p/***-dev (push)
origin  https://github.com/renaudcerrato/***.git (fetch)
origin  https://github.com/renaudcerrato/***.git (push)
renaud@null:~/Workspace/project$ ls /tmp/appcfg2297010422602013785.tmp/WEB-INF/classes/
jersey-multipart-config.properties  META-INF  com
loosebazooka commented 8 years ago

Is your appengine sdk is at 1.9.34 as well?

renaudcerrato commented 8 years ago

Yep, tried with 1.9.36 as well.

loosebazooka commented 8 years ago

Any chance you can include your build.gradle file (or some redacted version of it)?

renaudcerrato commented 8 years ago

Sure:

root's build.gradle:

allprojects {
    repositories {
        jcenter()
    }
}

ext.gae = [
        version: "1.9.34",
        plugin: "1.9.34",
]

project's build.gradle:

buildscript {
    repositories {
        jcenter()
        maven {url "https://plugins.gradle.org/m2/"}
    }
    dependencies {
        classpath "com.google.appengine:gradle-appengine-plugin:$gae.plugin"
    }
}

plugins {
    id "net.ltgt.apt" version "0.6"
}

repositories {
    jcenter()
    mavenCentral()
    maven { url "http://repo.maven.apache.org/maven2" }
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
apply plugin: 'idea'

dependencies {
    compile project(":backend")
    // App Engine
    appengineSdk "com.google.appengine:appengine-java-sdk:$gae.version"
    compile "com.google.appengine:appengine-api-1.0-sdk:$gae.version"
    testCompile "com.google.appengine:appengine-testing:$gae.version"
    testCompile "com.google.appengine:appengine-api-stubs:$gae.version"
    testCompile "com.google.appengine:appengine-tools-sdk:$gae.version"
    // HK2 metadata generator
    apt 'org.glassfish.hk2:hk2-metadata-generator:2.4.0'
    // Google Cloud Storage
    compile 'com.google.appengine.tools:appengine-gcs-client:0.5'
    // Objectify
    compile 'com.googlecode.objectify:objectify:5.1.10'
    // Servlet
    compile 'javax.servlet:servlet-api:2.5'
    // Slf4j for Jul
    compile 'org.slf4j:slf4j-jdk14:1.7.18'
    // Junit
    testCompile 'junit:junit:4.12'
    // Mockito
    testCompile 'org.mockito:mockito-core:1.+'
    // OkHttp
    testCompile 'com.squareup.okhttp:okhttp:2.7.4'
    testCompile 'com.squareup.okhttp:logging-interceptor:2.7.4'
}

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
        noCookies = true
        extraOptions = ["--oauth2_refresh_token=" + oauthToken(), "--auto_update_dispatch"/*, "--retain_upload_dir"*/]
    }
}
loosebazooka commented 8 years ago

@patflynn do you know who might be able to help here?

lesv commented 8 years ago

Take a look at the instructions at: https://github.com/GoogleCloudPlatform/cloud-debugger-gce-java-sample

That file is generated by: gcloud preview app gen-repo-info-file -\-output-file=target/project-1.0-SNAPSHOT/WEB-INF/classes/source-context.json and should be created just before you mvn package, but after you mvn clean.

lesv commented 8 years ago

In an ideal world @patflynn all of the plugins would do this step automatically for you.

lesv commented 8 years ago

Sorry, should have been gradle references, not mvn. You still need to exec to gcloud at some point in the process.

erezhaba commented 8 years ago

Please note that the absence of the source context file should not block you from using the cloud debugger. It would function just fine without it, just mind to use the correct version of the source. You can use local source with the cloud debugger UI.

At this point the source context file should be interesting for you only if you are using Google Cloud Repository (soon we're adding support for other repositories)

AFAIK there was a bug in 'gcloud preview apps deploy' with uploading the source context file, this should be fixed now. Please try with an update version of gcloud. (the file is also generated by this command)

patflynn commented 8 years ago

yup. Agreed.

On Wed, Apr 27, 2016 at 6:09 PM, Les Vogel notifications@github.com wrote:

In an ideal world @patflynn https://github.com/patflynn all of the plugins would do this step automatically for you.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/GoogleCloudPlatform/gradle-appengine-plugin/issues/243#issuecomment-215246660