Cov txheej txheem:

Dependency nyob rau hauv gradle yog dab tsi?
Dependency nyob rau hauv gradle yog dab tsi?

Video: Dependency nyob rau hauv gradle yog dab tsi?

Video: Dependency nyob rau hauv gradle yog dab tsi?
Video: Peb Los Ua Neej Nyob Rau Ntiajteb (Nkauj Ntseeg Vajtswv) 2024, Kaum ib hlis
Anonim

Gradle tsim tsab ntawv txhais cov txheej txheem los tsim cov haujlwm; txhua qhov project muaj qee qhov kev vam khom thiab qee qhov kev tshaj tawm. Kev vam meej txhais tau tias cov khoom uas txhawb nqa los tsim koj qhov project xws li xav tau JAR cov ntaub ntawv los ntawm lwm cov haujlwm thiab JARs sab nraud xws li JDBC JAR lossis Eh-cache JAR hauv chav kawm.

Kuj paub, qhov kev vam khom nyob rau hauv gradle nyob qhov twg?

Cov kev vam khom tuaj yeem nyob ntawm koj lub tshuab lossis hauv chaw cia khoom, thiab txhua qhov kev hloov pauv kev vam khom lawv tshaj tawm tau cia li suav nrog thiab. Kev vam meej feem ntau yog tswj ntawm Module-theem sab hauv kev vam khom thaiv hauv kev tsim. qib ntaub ntawv.

Ib sab saum toj no, testCompile hauv gradle yog dab tsi? Hauv Gradle dependencies yog pab pawg nyob rau hauv lub npe hu ua pawg dependencies. Cov testCompile configuration muaj cov dependencies uas yuav tsum tau sau cov kev xeem ntawm peb tes num. Qhov kev teeb tsa no muaj cov chav sib sau ua ke ntawm peb qhov project thiab cov kev vam khom ntxiv rau kev teeb tsa ua ke.

Tsis tas li ntawd, kuv yuav tswj hwm qhov kev vam meej li cas?

Cov kauj ruam los ntawm kauj ruam los tswj kev vam meej

  1. Tsim ib txoj haujlwm tshiab hauv Studio nrog Kotlin DSL ua cov ntawv tsim.
  2. Tsim ib lub nplaub tshev tshiab hu ua buildSrc nyob rau hauv lub ntsiab nplaub tshev ntawm qhov project.
  3. Hauv buildSrc ntxiv ob peb folders thiab cov ntaub ntawv, yog li cov qauv yog raws li nram no:
  4. Ntxiv Kotlin DSL plugin hauv cov ntaub ntawv build.gradle.kts:

Dab tsi yog classpath hauv build gradle?

Cov classpath configuration feem ntau pom nyob rau hauv buildSrc {} thaiv qhov twg ib tug yuav tsum tau tshaj tawm dependencies rau lub tsim . qib , nws tus kheej (rau plugins, kab tias). Yog tias buildscript nws tus kheej xav tau ib yam dab tsi los khiav, siv classpath . Yog koj qhov project xav tau ib yam dab tsi los khiav, siv compile.

Pom zoo: