2013-06-11 5 views
1

첫 번째로, 불쌍한 나의 영어에 대한 미안하지만, 나는 프랑스 다.Grails & gradle : plugin management

저는 gradles로 grails 프로젝트를 만들고 나머지 플러그인을 사용하고 싶습니다. 여기

import org.grails.gradle.plugin.GrailsTask 
version = '1.0' 
grailsVersion = '2.2.1' 
apply plugin: 'java' 
apply plugin: 'maven' 
apply plugin: 'grails' 



buildscript { 
     repositories { 
      mavenCentral() 
      mavenRepo name: "grails", url: 'http://repo.grails.org/grails/repo' 
     } 
     dependencies { 
      classpath "org.grails:grails-gradle-plugin:1.1.1-SNAPSHOT" 
     } 
} 

repositories { 
    mavenCentral() 
    mavenRepo name: 'grails', url: 'http://repo.grails.org/grails/repo' 
    mavenRepo name: 'nexus', url: 'http://nexusurl.fr' 
    mavenRepo url: 'http://repo.grails.org/grails/plugins' 

} 

uploadArchives { 
    repositories { 
     mavenDeployer { 
      repository(url: 'http://url') { 
      authentication(userName: 'log', password: 'pass') 
} 
      pom.version = '0.0.0' 
      pom.artifactId = 'yo' 
      pom.groupId = 'com.something' 
      pom.packaging = 'war' 
     } 
    } 
} 



dependencies { 
    ['dependencies', 'resources', 'core', 'plugin-domain-class', 'plugin-tomcat', 'plugin-services'].each { plugin -> 
     compile "org.grails:grails-$plugin:2.2.1" 
    } 
    compile 'repo.grails.org:grails-plugins-rest:0.7' 
    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.9' 
    compile 'org.codehaus.jackson:jackson-core-asl:1.9.9' 
    compile 'com.googlecode.json-simple:json-simple:1.1' 
    bootstrap 'org.codehaus.groovy:groovy-all:1.8.6' 
} 

GRAILS_TASK_PREFIX = 'grails-' 
if (name.startsWith(GRAILS_TASK_PREFIX)) { 
    project.task(name, type: GrailsTask) { 
     command "${name - GRAILS_TASK_PREFIX}" 
    } 
} 

나머지 플러그인 : 여기

내 build.gradle의 conf 파일입니다 이전 http://grails.org/plugin/rest

,이 플러그인은 아주 간단했다 얻을 :

grails install-plugin rest 

느릅 나무가 추가 application.properties 파일에 다음 줄을 입력하십시오.

plugins.rest=0.7 

이 플러그인을 내 buildFile에 추가하는 방법을 모르겠다.

내 Grails 애플리케이션을 실행하지만 런타임에 오류가 발생 될 수있다 :

compile 'repo.grails.org:grails-plugins-rest:0.7' 
:

Error | 
2013-06-11 14:20:41,916 [http-bio-8080-exec-8] ERROR errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [POST] /dwgui/signIn/login - parameters: 
username: demo-user 
password: *** 
No signature of method: com.ftprod.dwgui.security.AuthenticationService.withHttp() is applicable for argument types: (java.util.LinkedHashMap, com.ftprod.dwgui.security.AuthenticationService$_testSign 
In_closure1) values: [[uri:http://data.iraiser.eu], com.f[email protected]2786aa0f]. Stacktrace follows: 
Message: No signature of method: com.ftprod.dwgui.security.AuthenticationService.withHttp() is applicable for argument types: (java.util.LinkedHashMap, com.ftprod.dwgui.security.AuthenticationService$ 
_testSignIn_closure1) values: [[uri:http://data.iraiser.eu], com.f[email protected]2786aa0f] 
    Line | Method 
->> 28 | testSignIn in com.ftprod.dwgui.security.AuthenticationService 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|  14 | login  in com.ftprod.dwgui.security.SignInController 
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 615 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 722 | run . . . in java.lang.Thread 

내 build.gradle의 종속 범위에이 라인을 추가하는 것은 나에게 Gradle을 빌드하는 동안 오류를 줄

오류 :

* What went wrong: 
Execution failed for task ':grails-run-app'. 
> Could not find repo.grails.org:grails-plugins-rest:0.7. 
    Required by: 
     :dwgui:1.0 

나는 명확하게 마지막 오류를 이해합니다.

그래서 여기 내 질문이 있습니다 : 어떻게 grails usle grale 빌드를 위해 나머지 플러그인을 추가합니까?

답변

2

최신 Grails는 종속성 BuildConfig.groovy하지 application.properties 사용합니다. build.gradle은 Gradle 전용이며, Grails 의존성에 도움이 될 것 같지 않습니다.

그래서, 당신은 plugins 섹션에 넣어 당신의 conf/BuildConfig.groovy, 편집 할 수 있습니다 http://grails.org/doc/latest/guide/conf.html#pluginDependencies

+0

이것은 내 BuildConfig.groovy 파일에 적용되었지만이 파일을 신경 쓰지 않는 gradle을 사용하고 있습니다 – Snite

+0

gradle을 실행하면 어떻게됩니까? 'grails run-app' 만? –

+0

"compile"을 사용하고 있는지 확인하십시오 : rest : 0.7 "', not compile 'repo.grails.org : grails-plugins-rest : 0.7'' –

2

대부분의 grails 플러그인과 마찬가지로 대부분 구형 플러그인이며 구형이며 죽었습니다. 플러그인에서 무엇이 필요합니까? 해당 플러그인은 6 년 후에 업데이트되지 않았습니다.

등이. 직렬화, URL 라우팅에 내장되어 있습니다 REST에 대해 수행 할 필요가 거의 모든 것, 바로 아래

http://grails.org/doc/latest/guide/webServices.html#REST

웹 서비스 섹션이, 즉 당신이 어떻게 수행하는 방법을 보여줍니다 HTTP 요청하고 JSON 응답을 얻을 :

import groovyx.net.http.* 
import static groovyx.net.http.ContentType.JSON 
def http = new HTTPBuilder("http://localhost:8080/amazon") 

http.request(Method.GET, JSON) { 
    url.path = '/book/list' 
    response.success = { resp, json -> 
     for (book in json.books) { 
     println book.title 
     } 
    } 
} 
+0

나는이 플러그인을 사용하여 코드를 작성했습니다. 기본 grails 빌드를 찾을 수 있으면 graddle을 사용해야합니다. 내 코드를 다시 쓸 수 있습니다 – Snite

0

영어 실력은 당신이 생각했던대로 전혀 나쁘지 않다 :

plugins { 
    ...  
    compile ":rest:0.7" 
} 

참조를 플러그인 종속성에 대한 문서 . :)

나는 플러그인의 유용성에 @Nix와 동의한다. 대신 꽤 자세한 내용 인 rest-client-builder 플러그인을 사용할 수 있습니다.

다시 @Igor Artamonov가 설치에 대한 답변에서 언급 한 방식을 따라야합니다.

메르 ..

+0

제가 말했듯이, 제 앱 부스를 실행하는데 문제가 없습니다. 'grails run- app 'cmd. 내가 'grale-grails-run-app'cmd를 사용하여 런타임 오류가 발생했습니다. 플러그인의 유용성에 동의합니다. 코드를 다시 작성 하겠지만 향후 플러그인 구성에서이 문제를 해결할 수 있습니다. – Snite

0

좋아, (하지만 난 다른를 얻을) 내 문제를 해결 이고르 : 여기

내 build.gradle입니다 :

여기
... 
repositories { 
    mavenCentral() 
    mavenRepo name: 'grails', url: 'http://repo.grails.org/grails/repo' 
    mavenRepo name: 'nexus', url: 'http://integration.ftprod.fr/nexus/content/groups/public/' 
    mavenRepo url: 'http://repo.grails.org/grails/plugins' 
    mavenRepo url: 'http://repo.grails.org/grails/plugins-releases' 

} 
... 
dependencies { 
    ['dependencies', 'resources', 'core', 'plugin-domain-class', 'plugin-tomcat', 'plugin-services'].each { plugin -> 
     compile "org.grails:grails-$plugin:2.2.1" 
    } 
    compile 'org.grails.plugins:rest:0.7' 
    compile 'com.ftprod.dw:dw-client-api:0.0.28' 
    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.9' 
    compile 'org.codehaus.jackson:jackson-core-asl:1.9.9' 
    compile 'com.googlecode.json-simple:json-simple:1.1' 
    bootstrap 'org.codehaus.groovy:groovy-all:1.8.6' 
} 
... 

가 내 build.config :

... 
    plugins { 
     ... 
    compile ":rest:0.7" 
    } 
... 

이 줄의 새로운 오류 (소스 다운로드 후) :

compile 'org.grails.plugins:rest:0.7' 

* What went wrong: 
Execution failed for task ':grails-refresh-dependencies'. 
> loader constraint violation: when resolving overridden method "org.apache.tools.ant.helper.ProjectHelper2$RootHandler.setDocumentLocator(Lorg/xml/sax/Locator;)V" the class loader (instance of org/gr 
ails/launcher/RootLoader) of the current class, org/apache/tools/ant/helper/ProjectHelper2$RootHandler, and its superclass loader (instance of <bootloader>), have different Class objects for the type 
andler.setDocumentLocator(Lorg/xml/sax/Locator;)V used in the signature 
+0

build.gradle에서'rest' 항목을 한 번 제거해야합니다. 당신은'BuildConfig.groovy'에 엔트리를 가지고 있습니다. – dmahapatro