ãã®èšäºã§ã¯ãGradleã®äŸåé¢ä¿ç®¡çã®åºæ¬ã«ã€ããŠèª¬æãã詳现ãªå®çšäŸãå°ããªã©ã€ãããã¯ãããã³ããã¥ã¡ã³ãå ã®é©åãªå Žæãžã®ãªã³ã¯ãæäŸããŸãã
ãªããžããª
ãåãã®ããã«ãGradleã«ã¯ç¬èªã®ãªããžããªããªããMavenããã³IvyãªããžããªãäŸåé¢ä¿ã®ãœãŒã¹ãšããŠäœ¿çšããŸãã åæã«ããªããžããªãæäœããããã®ã€ã³ã¿ãŒãã§ãŒã¹ã¯åºæ¬çãªã¬ãã«ã§éãã¯ãããŸããããã©ã¡ãŒã¿ãŒã®éãã«ã€ããŠã¯ã IvyArtifactRepositoryãªã³ã¯ãšMavenArtifactRepositoryãªã³ã¯ããããã«åŠã¶ããšãã§ããŸã ã ãhttpãããhttpsãããŸãã¯ãfileããããã³ã«ãURLãšããŠäœ¿çšã§ããããšã«æ³šæããŠãã ããã ãªããžããªãèšé²ãããé åºã¯ããªããžããªã§äŸåé¢ä¿ãæ€çŽ¢ãããé åºã«åœ±é¿ããŸãã
// build.gradle repositories { maven { url "http://example.com" } ivy { url "http://example.com" } }
äŸåé¢ä¿ã®å®£èš
// build.gradle apply plugin: 'java' repositories { mavenCentral() } dependencies { compile group: 'com.googlecode.jsontoken', name: 'jsontoken', version: '1.1' testCompile group: 'junit', name: 'junit', version: '4.+' }
äžèšã®äŸã§ã¯ããããžã§ã¯ããã³ã³ãã€ã«ããããã®ç°ãªãæ§æïŒcompileãštestCompileïŒã®2ã€ã®äŸåé¢ä¿ãæ¥ç¶ãããŠãããã«ãã¹ã¯ãªããã衚瀺ãããŸãã JsonTokenã¯ãããžã§ã¯ãã®ã³ã³ãã€ã«ãšãããžã§ã¯ããã¹ãã®ã³ã³ãã€ã«äžã«æ¥ç¶ãããjUnitã¯ãããžã§ã¯ããã¹ãã®ã³ã³ãã€ã«äžã®ã¿æ¥ç¶ãããŸãã ã³ã³ãã€ã«æ§æã®è©³çŽ°ã«ã€ããŠã¯ã ãã¡ããã芧ãã ãã ã
ãŸããjUnitäŸåé¢ä¿ãåçïŒ+ïŒãšããŠæ¥ç¶ããŠããããšãããããŸãã ææ°ã®ããŒãžã§ã³4. +ã䜿çšãããŸãããã€ããŒã¢ããããŒãã远跡ããå¿ èŠã¯ãããŸããïŒã¢ããªã±ãŒã·ã§ã³ã®ã³ã³ãã€ã«ã®ã³ã³ãã€ã«ã¿ã€ãã§ã¯ããã®æ©èœã䜿çšããªãããšããå§ãããŸããäºæããªããããŒã«ã©ã€ãºãé£ããåé¡ãçºçããå¯èœæ§ãããããã§ãïŒã
jUnitäŸåé¢ä¿ã®äŸã«ã€ããŠã¯ãå¿ èŠãªäŸåé¢ä¿ãèŠã€ããããã®æšæºçãªGradleã¡ã«ããºã ãæ€èšããŠãã ããã
1. compile ("org.junit:junit:4.+") 2. group: "org.junit" name: "junit" version: "4.+" 3. [junit:4.1] ⊠[junit:4.12] 4. [junit:4.12] 5. [junit:4.12] dependencies { ⊠} artifacts { ⊠} 6. junit-4.12.jar junit-4.12-source.jar junit-4.12-javadoc.zip
ãã£ãã·ã¥
Gradleã«ã¯ãããã©ã«ãã§äŸåé¢ä¿ã24æéä¿åãããã£ãã·ã¥ã·ã¹ãã ããããŸããããã®åäœã¯ãªãŒããŒã©ã€ãã§ããŸãã
// build.gradle configurations.all { resolutionStrategy.cacheChangingModulesFor 4, 'hours' resolutionStrategy.cacheDynamicVersionsFor 10, 'minutes' }
ãã£ãã·ã¥ã«ããŒã¿ãä¿åããããã«èšå®ãããæéãçµéãããšãã·ã¹ãã ã¯ã¿ã¹ã¯ãéå§ãããšãã«ãåçäŸåé¢ä¿ãšå€æŽäŸåé¢ä¿ãæŽæ°ããå¯èœæ§ãæåã«ãã§ãã¯ããå¿ èŠã«å¿ããŠæŽæ°ããŸãã
Gradleã¯ã以åã«ããŠã³ããŒãããããã¡ã€ã«ãã¢ããããŒãããªãããã«ããURL /ãã¡ã€ã«ãœãŒã¹ãç°ãªã£ãŠããŠããããã«æ€èšŒã·ã¹ãã ã䜿çšããŸãã Gradleã¯ããã£ãã·ã¥ïŒURLãããŒãžã§ã³ãšã¢ãžã¥ãŒã«åãGradleã®ä»ã®ããŒãžã§ã³ã®ãã£ãã·ã¥ãMavenãã£ãã·ã¥ïŒãHTTPãªã¯ãšã¹ãããããŒïŒæ¥ä»ãã³ã³ãã³ãé·ãETagïŒãSHA1ããã·ã¥ïŒå©çšå¯èœãªå ŽåïŒãåžžã«ãã§ãã¯ããŸãã äžèŽãããã®ãèŠã€ãããªãå Žåãã·ã¹ãã ã¯ãã¡ã€ã«ãããŠã³ããŒãããŸãã
ãŸãããã«ãã·ã¹ãã ã«ã¯2ã€ã®ãã©ã¡ãŒã¿ããããèµ·åæã«ç¹å®ã®ã¿ã¹ã¯ã®ãã£ãã·ã¥ããªã·ãŒãå€æŽã§ããŸãã
--offline-Gradleã¯ãäŸåé¢ä¿ã®æŽæ°ã確èªããããã«ãããã¯ãŒã¯ã«æ¥ç¶ããããšããŸããã
--refresh-dependencies-Gradleã¯ãã¹ãŠã®äŸåé¢ä¿ãæŽæ°ããããšããŸãã ãã£ãã·ã¥å ã®ããŒã¿ãç Žæããå Žåã«äœ¿çšãããšäŸ¿å©ã§ãã ãã£ãã·ã¥ãããããŒã¿ãæ€èšŒããç°ãªãå Žåã¯æŽæ°ããŸãã
Gradle User Guideã§äŸåé¢ä¿ã®ãã£ãã·ã¥ã®è©³çŽ°ãèªãããšãã§ããŸãã
äŸåé¢ä¿ã®çš®é¡
Gradleã«ã¯ããã€ãã®çš®é¡ã®äŸåé¢ä¿ããããŸãã æãäžè¬çã«äœ¿çšãããã®ã¯æ¬¡ã®ãšããã§ãã
-å€éšãããžã§ã¯ãã®äŸåé¢ä¿-å€éšãªããžããªããããŠã³ããŒããããäŸåé¢ä¿ã
// build.gradle dependencies { compile "com.android.support:appcompat-v7:23.1.1" }
-ãããžã§ã¯ãã®äŸåé¢ä¿-1ã€ã®ãããžã§ã¯ãã®ãã¬ãŒã ã¯ãŒã¯å ã®ã¢ãžã¥ãŒã«ïŒãµããããžã§ã¯ãïŒãžã®äŸåã
// build.gradle dependencies { compile project(':subproject') }
-ãã¡ã€ã«ã®äŸåé¢ä¿-ãã¡ã€ã«ãšããŠæ¥ç¶ãããäŸåé¢ä¿ïŒjar / aarã¢ãŒã«ã€ãïŒã
build.gradle repositories { flatDir { dirs 'aarlibs' // , aar- } } dependencies { compile(name:'android_library', ext:'aar') // aar- compile files('libs/a.jar', 'libs/b.jar') compile fileTree(dir: 'libs', include: '*.jar') }
ã¯ã©ã€ã¢ã³ãã¢ãžã¥ãŒã«ã®äŸåé¢ä¿ãGradle APIã®äŸåé¢ä¿ãããã³ããŒã«ã«Groovyã®äŸåé¢ä¿ããããŸãã ãããã¯ãã£ãã«äœ¿çšãããªãããããã®èšäºã®ãã¬ãŒã ã¯ãŒã¯ã§ã¯ããããå解ããŸãããããããã«é¢ããããã¥ã¡ã³ãã¯ãã¡ãã§èªãããšãã§ããŸã ã
äŸåããªãŒ
åå€éšãŸãã¯èšèšã®äŸåé¢ä¿ã«ã¯ãç¬èªã®äŸåé¢ä¿ãå«ãŸããŠããå Žåããããããããèæ ®ããŠããŠã³ããŒãããå¿ èŠããããŸãã ãããã£ãŠãã³ã³ãã€ã«äžã«ãéžæããæ§æã®äŸåé¢ä¿ãèªã¿èŸŒãŸããäŸåé¢ä¿ããªãŒãæ§ç¯ãããŸãããã®äººéè¡šçŸã¯ãAndroid Studioã®Gradleã¿ã¹ã¯ãdependenciesããŸãã¯ãããžã§ã¯ãã«ãŒããã©ã«ããŒã«ããã³ã³ãœãŒã«ã®gradleïŒ module_nameïŒ ïŒäŸåé¢ä¿ã³ãã³ããå®è¡ããããšã§ç¢ºèªã§ããŸãã å¿çãšããŠã䜿çšå¯èœãªåæ§æã®äŸåé¢ä¿ããªãŒã®ãªã¹ããååŸããŸãã
æ§æãã©ã¡ãŒã¿ãŒã䜿çšããŠãæ§æåãæå®ããŠãæå®ãããæ§æã®ã¿ã®äŸåé¢ä¿ããªãŒã衚瀺ããŸãã
githubã«ãããªããžããªã®ç¹å¥ã«æºåããããœãŒã¹ãååŸããŠãç¹å®ã®æ§æã®äŸåé¢ä¿ããªãŒãååŸããŠã¿ãŸãããïŒãããžã§ã¯ããç¶æ 0ã«ãªã£ãç¬éãã€ãŸãbuild.gradle.0ãbuild.gradleãšããŠäœ¿çšãããŸãïŒã
äŸåé¢ä¿ããªãŒãåæããåŸãã¢ããªã¢ãžã¥ãŒã«ã¯2ã€ã®å€éšäŸåé¢ä¿ïŒappcompatãšguavaïŒãäŸåé¢ä¿ãšããŠäœ¿çšãã2ã€ã®èšèšäŸåé¢ä¿ïŒ1çªç®ãš2çªç®ïŒã䜿çšããŠããããšãããããŸãã ãããžã§ã¯ããã¯ã©ã¹ãã¹ã«åãã©ã€ãã©ãªã®2ã€ã®ããŒãžã§ã³ãå«ãããšã¯ã§ããªãããšã¯æããã§ãããããã¯å¿ èŠãããŸããã ãã®æç¹ã§ãGradleã«ã¯ç«¶å解決ã¢ãžã¥ãŒã«ãå«ãŸããŠããŸãã
çŽäºè§£æ±º
Gradle DSLã«ã¯ãäŸåé¢ä¿ã®ç«¶åã解決ããããã«äœ¿çšãããã³ã³ããŒãã³ããå«ãŸããŠããŸãã äžèšã®äŸåé¢ä¿ããªãŒã§jsontokenã©ã€ãã©ãªã®äŸåé¢ä¿ãèŠããšããããã¯äžåºŠãã衚瀺ãããŸããã 2çªç®ã®ã¢ãžã¥ãŒã«ã§ã¯ãjsontokenã©ã€ãã©ãªã®äŸåé¢ä¿ã¯æå®ãããŠããããäŸåé¢ä¿èªäœã®åºåã«ã¯ '-> 1.1'ãè¿œå ãããŠããŸããã€ãŸããã©ã€ãã©ãªããŒãžã§ã³1.0ã¯äœ¿çšãããŸããããGradle競å解決ã¢ãžã¥ãŒã«ã䜿çšããŠããŒãžã§ã³1.1ã«èªåçã«çœ®ãæããããŸãã
競åãã©ã®ããã«è§£æ±ºããããã説æããããã«ãGradleã¿ã¹ã¯ã®dependencyInsightã䜿çšããããšãã§ããŸãã次ã«äŸã瀺ããŸãã
競å解決ã®çµæãšããŠããŒãžã§ã³1.1ãéžæãããããšã«æ³šæããŠãã ãããä»ã®ã«ãŒã«ã®çµæãšããŠéžæããããšãã§ããŸãïŒããšãã°ã匷å¶éžæãŸãã¯ã«ãŒã«éžæïŒã ãã®èšäºã§ã¯ãäŸåé¢ä¿ã解決ããããã®æŠç¥ã«åœ±é¿ããã«ãŒã«ã®äœ¿çšäŸã瀺ããŸããdependencyInsightã¿ã¹ã¯ãå®äºããåŸã以äžã®åã¹ãããã§ã©ã€ãã©ãªã®ç¹å®ã®ããŒãžã§ã³ãéžæããçç±ã確èªã§ããŸãã ãããè¡ãã«ã¯ãåã¹ããŒãžã«ç§»åãããšãã«ãdependencyInsightã¿ã¹ã¯ãåå¥ã«å®è¡ã§ããŸãã
å¿ èŠã«å¿ããŠãããšãã°ããããžã§ã¯ãã®æ§æäžã«ç«¶åãæ€åºããããšãã«ãã©ãŒã«ãããããã«æ瀺ããããšã§ãGradle競å解決ã¢ãžã¥ãŒã«ã®ããžãã¯ãåå®çŸ©ã§ããŸãã ïŒç¶æ 1ïŒ
// build.gradle // ⊠configurations.compile.resolutionStrategy { failOnVersionConflict() }
ãã®åŸãGradleäŸåé¢ä¿ããªãŒãæ§ç¯ããããšããŠããã¢ããªã±ãŒã·ã§ã³ã®äŸåé¢ä¿ã®ç«¶åã«ããã¿ã¹ã¯ãäžæãããŸãã
ãã®åé¡ã«ã¯4ã€ã®è§£æ±ºçããããŸãã
æåã®ãªãã·ã§ã³ã¯ã競å解決æŠç¥ãç¡å¹ã«ããè¡ãåé€ããããšã§ãã
2çªç®ã®ãªãã·ã§ã³ã¯ãç¹å®ã®ããŒãžã§ã³ïŒç¶æ 2ïŒã瀺ããjsonTokenã©ã€ãã©ãªãŒã®å¿ é 䜿çšèŠåã競å解決æŠç¥ã«è¿œå ããããšã§ãã
// build.gradle // ⊠configurations.compile.resolutionStrategy { force 'com.googlecode.jsontoken:jsontoken:1.1' failOnVersionConflict() }
ãã®ãœãªã¥ãŒã·ã§ã³ãé©çšãããšãäŸåé¢ä¿ããªãŒã¯æ¬¡ã®ããã«ãªããŸãã
3çªç®ã®ãªãã·ã§ã³ã¯ãjsonTokenã©ã€ãã©ãªãã¢ããªãããžã§ã¯ãã®äŸåé¢ä¿ãšããŠæ瀺çã«è¿œå ãããã®äŸåé¢ä¿ã«forceãã©ã¡ãŒã¿ãŒãå²ãåœãŠãããšã§ããããã«ããã䜿çšããã©ã€ãã©ãªã®ããŒãžã§ã³ãæ瀺çã«ç€ºãããŸãã ïŒç¶æ 3ïŒ
// build.gradle // ⊠dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.google.guava:guava:+' compile project(":first") compile project(":second") compile ('com.googlecode.jsontoken:jsontoken:1.1') { force = true } }
ãããŠãäŸåé¢ä¿ããªãŒã¯æ¬¡ã®ããã«ãªããŸãã
4çªç®ã®ãªãã·ã§ã³ã¯ãexcludeãã©ã¡ãŒã¿ãŒã䜿çšããŠããããžã§ã¯ãã®äŸåé¢ä¿ã®1ã€ããç¬èªã®äŸåé¢ä¿ã®1ã€ããjsontokenãé€å€ããããšã§ãã ïŒç¶æ 4ïŒ
// build.gradle dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.google.guava:guava:+' compile project(":first") compile(project(":second")) { exclude group: "com.googlecode.jsontoken", module: 'jsontoken' } }
ãããŠãäŸåé¢ä¿ããªãŒã¯æ¬¡ã®ããã«ãªããŸãã
excludeã¯äž¡æ¹ã®ãã©ã¡ãŒã¿ãŒãåæã«æž¡ãå¿ èŠã¯ãªãã1ã€ãã䜿çšã§ããªãããšã«æ³šæããŠãã ããã
ããããäŸåé¢ä¿ããªãŒã®æ£ããåºåã«ãããããããã¢ããªã±ãŒã·ã§ã³ããã«ãããããšãããšãGradleã¯ãšã©ãŒãè¿ããŸãã
ãšã©ãŒã®åå ã¯ããã«ãã¿ã¹ã¯å®è¡ã¡ãã»ãŒãžã®åºåããç解ã§ããŸããåãããã±ãŒãžåã®GwtCompatibleã¯ã©ã¹ã¯ãããã€ãã®äŸåé¢ä¿ã«å«ãŸããŠããŸãã ããã¯äºå®ã§ããäºå®ãã¢ããªãããžã§ã¯ãã¯äŸåé¢ä¿ãšããŠguavaã©ã€ãã©ãªã䜿çšããjsontokenã©ã€ãã©ãªã¯äŸåé¢ä¿ã§å€ãGoogleã³ã¬ã¯ã·ã§ã³ã䜿çšããŠããŸãã Googleã³ã¬ã¯ã·ã§ã³ã¯ã°ã¢ãã®äžéšã§ãããåããããžã§ã¯ãã§å ±æããããšã¯ã§ããŸããã
ãããžã§ã¯ãã®ãã«ããæåãããã«ã¯ã次ã®3ã€ã®ãªãã·ã§ã³ããããŸãã
1ã€ç®ã¯ãã¢ããªã¢ãžã¥ãŒã«ã®äŸåé¢ä¿ããguavaãåé€ããããšã§ãã Googleã³ã¬ã¯ã·ã§ã³ã«å«ãŸããã°ã¢ãã®äžéšã®ã¿ã䜿çšããå Žåãææ¡ããããœãªã¥ãŒã·ã§ã³ã¯é©åã§ãã
2çªç®ã¯ãæåã®ã¢ãžã¥ãŒã«ããGoogleã³ã¬ã¯ã·ã§ã³ãé€å€ããããšã§ãã äžèšã®äŸå€ãŸãã¯æ§æã«ãŒã«ã䜿çšããŠãããå®çŸã§ããŸãã æåã«äŸå€ã䜿çšããŠãäž¡æ¹ã®ãªãã·ã§ã³ãæ€èšããŠãã ããïŒç¶æ 5ïŒ
// build.gradle dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.google.guava:guava:+' compile(project(":first")) { exclude module: 'google-collections' } compile(project(":second")) { exclude group: "com.googlecode.jsontoken", module: 'jsontoken' } }
æ§æã«ãŒã«ã®äœ¿çšäŸïŒç¶æ 6ïŒïŒ
//build.gradle configurations.all { exclude group: 'com.google.collections', module: 'google-collections' } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.google.guava:guava:+' compile project(":first") compile(project(":second")) { exclude group: "com.googlecode.jsontoken", module: 'jsontoken' } }
Googleã³ã¬ã¯ã·ã§ã³ã®äŸå€ã®äž¡æ¹ã®å®è£ ã®äŸåé¢ä¿ããªãŒã¯åãã§ãã
3çªç®ã®ãªãã·ã§ã³ã¯ãã¢ãžã¥ãŒã«çœ®ææ©èœã䜿çšããããšã§ãïŒç¶æ 7ïŒïŒ
// build.gradle dependencies { modules { module('com.google.collections:google-collections') { replacedBy('com.google.guava:guava') } } compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.google.guava:guava:+' compile project(":first") compile(project(":second")) { exclude group: "com.googlecode.jsontoken", module: 'jsontoken' } }
äŸåé¢ä¿ããªãŒã¯æ¬¡ã®ããã«ãªããŸãã
競åãçºçããå Žåã«ã¢ã»ã³ããªãäžæããããšã瀺ãå®çŸ©æžã¿ã®ç«¶å解決ããžãã¯ãçµäºãããšãæ§æ段éã§ã¿ã¹ã¯ã®å®è¡ãäžæãããããšã«æ³šæããŠãã ããã ã€ãŸããã¢ãžã¥ãŒã«çœ®æã«ãŒã«ã®äœ¿çšã¯ãäŸåé¢ä¿éã®ç«¶å解決æŠç¥ã®ã«ãŒã«ã®1ã€ã§ãã
ãŸããGradleäŸåé¢ä¿ã®ãªã¹ãããguavaãåé€ãããšãGoogleã³ã¬ã¯ã·ã§ã³ããããžã§ã¯ãã«ä¿åãããããã«äŸåããæ©èœãå®è¡ãç¶ç¶ã§ãããããåè¿°ã®ãªãã·ã§ã³ã®æåŸãæãæè»æ§ãé«ãããšã«æ³šæããããšãéèŠã§ãã ãããŠãäŸåé¢ä¿ããªãŒã¯æ¬¡ã®ããã«ãªããŸãã
åãªãã·ã§ã³ã®åŸãã³ã³ãã€ã«ããã³èµ·åãããã¢ããªã±ãŒã·ã§ã³ã®åœ¢ã§æåãåããŸãã
ããããå¥ã®ç¶æ³ïŒç¶æ 8ïŒãèŠãŠã¿ãŸããããã¯ã€ã€ãŒã¢ãã¯ã®åçãªäŸåæ§ãå€§å¹ ã«åæžãããŠããŸãïŒã¹ã¯ãªãŒã³ã·ã§ããã®ãµã€ãºãå°ããããããïŒã ãã¬ãŒãã³ã°ç®çã§ã®ã¿äœ¿çšããŸãã代ããã«ãååãæäŸããã©ã€ãã©ãªãæ³åããŠãã ããã圌ã¯ãã€ã§ãæ°ããããŒãžã§ã³ããªãªãŒã¹ã§ããŸããææ°ããŒãžã§ã³ã䜿çšããå¿ èŠããããŸãã
// build.gradle configurations.all { exclude group: 'org.apache.httpcomponents', module: 'httpclient' exclude group: 'org.json', module: 'json' exclude group: 'org.eclipse.jetty' exclude group: 'com.fasterxml.jackson.core' exclude group: 'com.jayway.jsonpath' } dependencies { compile 'com.github.tomakehurst:wiremock:+' }
äŸåé¢ä¿ããªãŒã¯æ¬¡ã®ãšããã§ãã
ã芧ã®ãšãããGradleã¯ããŒã¿çã§ããwiremockã®ææ°ããŒãžã§ã³ãããŠã³ããŒãããŸãã ãããã°ã¢ã»ã³ããªã®ç¶æ³ã¯æ£åžžã§ãããã¢ã»ã³ããªããŠãŒã¶ãŒã«æäŸããå Žåã¯ããªãªãŒã¹ããŒãžã§ã³ã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ã®å質ã確èªããå¿ èŠããããŸãã ããããåæã«ãåžžã«ææ°ããŒãžã§ã³ãšé »ç¹ãªãªãªãŒã¹ã䜿çšããå¿ èŠããããããwiremockããŒãžã§ã³ãåçã«æå®ããããšãæåŠããæ¹æ³ã¯ãããŸããã ãã®åé¡ã®è§£æ±ºçã¯ãäŸåé¢ä¿ã®ããŒãžã§ã³ãéžæããæŠç¥ã«ã€ããŠç¬èªã®ã«ãŒã«ãäœæããããšã§ãã
// build.gradle //⊠configurations.all { //⊠resolutionStrategy { componentSelection { all { selection -> if (selection.candidate.version.contains('alpha') || selection.candidate.version.contains('beta')) { selection.reject("rejecting non-final") } } } } }
ãã®ã«ãŒã«ã¯ãwiremockã ãã§ãªãããã¹ãŠã®äŸåé¢ä¿ã«é©çšãããããšã«æ³šæããŠãã ããã
ãã®åŸãæ å ±ã¢ãŒãã§äŸåé¢ä¿ããªãŒã衚瀺ããã¿ã¹ã¯ãéå§ããã©ã€ãã©ãªã®ããŒã¿çãã©ã®ããã«ç Žæ£ãããããããã³ããããç Žæ£ãããçç±ã確èªããŸãã æçµçã«ãå®å®ããŒãžã§ã³1.58ãéžæãããŸãã
ãããããã¹ãäžã«ãããŒãžã§ã³1.58ã«é倧ãªãã°ããããã¢ã»ã³ããªããã®ç¶æ ã§ãªãªãŒã¹ã§ããªãããšãããããŸããã ãã®åé¡ã解決ããã«ã¯ãäŸåé¢ä¿ã®ããŒãžã§ã³ãéžæããããã®å¥ã®ã«ãŒã«ãèšè¿°ããŸãã
// build.gradle //⊠configurations.all { //⊠resolutionStrategy { componentSelection { // ⊠withModule('com.github.tomakehurst:wiremock') { selection -> if (selection.candidate.version == "1.58") { selection.reject("known bad version") } } } } }
ãã®åŸãwiremock 1.58ãç Žæ£ãããããŒãžã§ã³1.57ã®äœ¿çšãéå§ãããäŸåé¢ä¿ããªãŒã¯æ¬¡ã®ããã«ãªããŸãã
ãããã«
èšäºãéåžžã«èšå€§ã§ããããšãå€æãããšããäºå®ã«ãããããããGradleã®äŸåé¢ä¿ç®¡çã®ãããã¯ã«ã¯ããã®èšäºã®ãã¬ãŒã ã¯ãŒã¯å ã§çºè¡šãããŠããªãå€ãã®æ å ±ãå«ãŸããŠããŸãã å ¬åŒã®ãŠãŒã¶ãŒã¬ã€ããšGradle DSLã®ããã¥ã¡ã³ãã®å©ããåããŠããã®äžçãæ·±ãæãäžããããšããå§ãããŸããGradleDSLã®ããã¥ã¡ã³ãã¯å匷ã«æéãããããŸãã
ãããããã®çµæãèªååã®ãããã§ããŸãããŸããŸãªãã°ã衚瀺ããããšãã«äœãããå¿ èŠãããããç解ãããããã§ãæ°åæéãç¯çŽããæ©äŒãåŸãããŸãã ããšãã°ãæè¿65Kã¡ãœãããšMultidexã®ãã°ã¯éåžžã«æŽ»çºã§ããããäŸåé¢ä¿ã®é©åãªè¡šç€ºãšexcludeã®äœ¿çšã®ãããã§ãåé¡ã¯éåžžã«è¿ éã«è§£æ±ºãããŸãã
ãŸãèªãïŒ GradleïŒ5ã€ã®éçºè ã®å©ç¹