2

I need to upload file with HTTP post in gradle build. I found HTTPPlugin which could make the deal. I made a simple build but it gives me error:

Caused by: groovy.lang.MissingPropertyException: Could not get unknown 
property 'HttpTask' for root project 'sample-app' of type 
org.gradle.api.Project.

build.gradle

plugins {
    id "io.github.http-builder-ng.http-plugin" version "0.1.1"
}

task notify(type:HttpTask){
    config {
        request.uri = 'http://something.com'
    }
    post {
        request.uri.path = '/notify'
        request.body = [event: 'activated']
        response.success {
            println 'The event notification was successful'
        }
    }
}

It seems gradle cannot find HTTPTask. Any idea what I'm missing?

Jarno Lahtinen
  • 1,713
  • 17
  • 30
  • 2
    Hi. I had similar issue, and found it's an open issue in the Github project for this plugin, which is not resolved yet : https://github.com/http-builder-ng/gradle-http-plugin/issues/6 – M.Ricciuti Aug 23 '18 at 07:55

2 Answers2

2

The error "Could not get unknown property 'HttpTask' for root project" can be fixed by specifying the full qualified name of HttpTask type when declaring your task:

task notify(type: io.github.httpbuilderng.http.HttpTask){
    config {
        request.uri = 'http://something.com'
    }
    post {
        request.uri.path = '/notify'
        request.body = [event: 'activated']
        response.success {
            println 'The event notification was successful'
        }
    }        
}

Best would be that this plugin declares an extension name "HttpTask" of type HttpTask.class so that we can directly use "HttpTask" without fully qualified name and without having to import this type in our script. This is how other plugins work (nebula ospakage plugin for example, with task "Rpm").

Documentation of this plugin project should also be updated to provide a working example ( https://github.com/http-builder-ng/gradle-http-plugin )

M.Ricciuti
  • 11,070
  • 2
  • 34
  • 54
  • Any idea how to ignore javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException exeption on task? – Jarno Lahtinen Aug 24 '18 at 05:25
  • Hi. I did not try HTTPS feature myself, but this plugin is based on HTTP-Builder-NG client library which supports SSL: there is some documentation how to configure SSLContext and and to ignore SSL exceptions here: https://http-builder-ng.github.io/http-builder-ng/asciidoc/html5/#_execution .Hope this will help. – M.Ricciuti Aug 24 '18 at 07:01
2

Try with the fully qualified name of the task :

plugins {
    id "io.github.http-builder-ng.http-plugin" version "0.1.1"
}

task notify(type: io.github.httpbuilderng.http.HttpTask){
    config {
        request.uri = 'http://something.com'
    }
    post {
        request.uri.path = '/notify'
        request.body = [event: 'activated']
        response.success {
            println 'The event notification was successful'
        }
    }
}

Or import HttpTask in your script :

import io.github.httpbuilderng.http.HttpTask

plugins {
    id "io.github.http-builder-ng.http-plugin" version "0.1.1"
}

task notify(type:HttpTask){
// ...
ToYonos
  • 16,469
  • 2
  • 54
  • 70