// ĠCopyright Ġ 2 0 0 0 - 2 0 2 0 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġorg . jetbrains . plugins . gradle . import ing Ċ Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . jetbrains . plugins . gradle . tool ing . annotation . Target Versions Ċ import Ġorg . junit . Test Ċ Ċ class ĠGradle Build Src Import ing Test Ġ: ĠGradle Import ing TestCase () Ġ{ ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġbuild Src Ġproject Ġis Ġimported Ġas Ġmodules `() Ġ{ ĊĠĠĠ Ġcreate Project Sub File (" build Src / src / main / java / my / pack / Test Plugin . java ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ""" ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpackage Ġmy . pack ; ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġimport Ġorg . gradle . api . Project ; ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġimport Ġorg . gradle . api . Plugin ; ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpublic Ġclass ĠTest Plugin Ġimplements ĠPlugin < Project > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpublic Ġvoid Ġapply ( Project Ġproject ){ }; ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ""" . trim Indent ()) ĊĠĠĠ Ġimport Project (" apply Ġplugin : Ġ' java '\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" apply Ġplugin : Ġmy . pack . Test Plugin ") ĊĠĠĠ Ġassert Modules (" project ", Ġ" project . main ", Ġ" project . test ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" project . build Src ", Ġ" project . build Src . main ", Ġ" project . build Src . test ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġbuild Src Ġproject Ġlevel Ġdependencies Ġare Ġimported `() Ġ{ ĊĠĠĠ Ġcreate Project Sub File (" build Src / build . gradle ", ĠGradle Build Script Builder Ex (). with JUnit (" 4 . 1 2 "). generate ()) ĊĠĠĠ Ġimport Project ("") ĊĠĠĠ Ġassert Modules (" project ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" project . build Src ", Ġ" project . build Src . main ", Ġ" project . build Src . test ") ĊĠĠĠ Ġval Ġmodule Lib Deps Ġ= Ġget Module Lib Deps (" project . build Src . test ", Ġ" Gradle : Ġjunit : junit : 4 . 1 2 ") ĊĠĠĠ ĠassertThat ( module Lib Deps ). has Size ( 1 ). all Satisf y Ġ{ ĊĠĠĠĠĠ ĠassertThat ( it . library Level ). isEqualTo (" project ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Target Versions ("< 6 . 0 ") Ġ// Ġsince Ġ 6 . 0 Ġ' build Src ' Ġis Ġa Ġreserved Ġproject Ġname , Ġhttps :// docs . gradle . org / current / user guide / up grading _ version _ 5 . html # build src _ is _ now _ reserved _ as _ a _ project _ and _ sub project _ build _ name ĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġbuild Src Ġproject Ġis Ġincluded Ġinto Ġthe Ġmain Ġbuild `() Ġ{ ĊĠĠĠ Ġcreate Project Sub File (" build Src / src / main / java / my / pack / Util . java ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" package Ġmy . pack ;\ n public Ġclass ĠUtil Ġ{} ") ĊĊĠĠĠ Ġimport Project (" apply Ġplugin : Ġ' java '") ĊĠĠĠ Ġassert Modules (" project ", Ġ" project . main ", Ġ" project . test ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" project . build Src ", Ġ" project . build Src . main ", Ġ" project . build Src . test ") ĊĊĠĠĠ Ġcreate Settings File (" include Ġ' build Src '") ĊĠĠĠ Ġimport Project (" apply Ġplugin : Ġ' java '") ĊĠĠĠ Ġassert Modules (" project ", Ġ" project . main ", Ġ" project . test ", Ġ" project . build Src ") ĊĊĠ Ġ} ĊĊĠ Ġ@ Target Versions (" 6 . 7 +") Ġ// Ġsince Ġ 6 . 7 Ġincluded Ġbuilds Ġbecome Ġ" visible " Ġfor Ġ` build Src ` Ġproject Ġhttps :// docs . gradle . org / 6 . 7 - rc - 1 / release - notes . html # build - src ĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġbuild Src Ġwith Ġapplied Ġplugins Ġprovided Ġby Ġincluded Ġbuild Ġof Ġthe Ġroot Ġproject `() Ġ{ ĊĠĠĠ Ġcreate Project Sub File (" build Src / build . gradle ", Ġ" plugins Ġ{ Ġid Ġ' my project . my - test - plugin ' Ġ}\ n ") ĊĠĠĠ Ġcreate Project Sub File (" build Src / settings . gradle ", Ġ"") ĊĠĠĠ Ġval Ġdep Jar Ġ= Ġcreate Project Jar Sub File (" build Src / libs / my Lib . jar ") ĊĠĠĠ Ġcreate Project Sub File (" build - plugins / settings . gradle ", Ġ"") ĊĠĠĠ Ġcreate Project Sub File (" build - plugins / build . gradle ", Ġ" plugins Ġ{ Ġid Ġ' groovy - gradle - plugin ' Ġ}\ n ") ĊĠĠĠ Ġcreate Project Sub File (" build - plugins / src / main / groovy / my project . my - test - plugin . gradle ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" plugins Ġ{ Ġid Ġ' java ' Ġ}\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" dependencies Ġ{ Ġimplementation Ġfiles (' libs / my Lib . jar ') Ġ}\ n ") ĊĊĠĠĠ Ġcreate Settings File (" include Build Ġ' build - plugins '") ĊĠĠĠ Ġimport Project ("") ĊĠĠĠ Ġassert Modules (" project ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" project . build Src ", Ġ" project . build Src . main ", Ġ" project . build Src . test ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" build - plugins ", Ġ" build - plugins . main ", Ġ" build - plugins . test ") ĊĊĠĠĠ Ġassert Module Lib Dep (" project . build Src . main ", Ġdep Jar . present able Url , Ġdep Jar . url ) ĊĠ Ġ} ĊĊĠ Ġ/** ĊĠĠ Ġ* Ġsince Ġ 6 . 7 Ġincluded Ġbuilds Ġbecome Ġ" visible " Ġfor Ġ` build Src ` Ġproject Ġhttps :// docs . gradle . org / 6 . 7 - rc - 1 / release - notes . html # build - src ĊĠĠ Ġ* Ġ!!! ĠNote , Ġthis Ġis Ġtrue Ġonly Ġfor Ġbuilds Ġincluded Ġfrom Ġthe Ġ" root " Ġbuild Ġand Ġit Ġbecomes Ġvisible Ġalso Ġfor Ġ" nested " Ġ` build Src ` Ġprojects Ġ!!! ĊĠĠ Ġ* ĠTrans itive Ġincluded Ġbuilds Ġare Ġnot Ġvisible Ġeven Ġfor Ġrelated Ġ" trans itive " Ġ` build Src ` Ġprojects ĊĠĠ Ġ* Ġdue Ġto Ġlimitation Ġcaused Ġby Ġspecific Ġordering Ġrequirement : Ġ Ġ" include Ġorder Ġis Ġimportant Ġif Ġan Ġincluded Ġbuild Ġprovides Ġa Ġplugin Ġwhich Ġshould Ġbe Ġdiscovered Ġvery Ġvery Ġearly ". ĊĠĠ Ġ* ĠIt Ġcan Ġbe Ġimproved Ġin Ġthe Ġfuture ĠGradle Ġreleases . ĊĠĠ Ġ*/ ĊĠ Ġ@ Target Versions (" 6 . 7 +") ĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġnested Ġbuild Src Ġwith Ġapplied Ġplugins Ġprovided Ġby Ġincluded Ġbuild Ġof Ġthe Ġroot Ġproject `() Ġ{ ĊĠĠĠ Ġcreate Project Sub File (" build - plugins / settings . gradle ", Ġ"") ĊĠĠĠ Ġcreate Project Sub File (" build - plugins / build . gradle ", Ġ" plugins Ġ{ Ġid Ġ' groovy - gradle - plugin ' Ġ}\ n ") ĊĠĠĠ Ġcreate Project Sub File (" build - plugins / src / main / groovy / my project . my - test - plugin . gradle ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" plugins Ġ{ Ġid Ġ' java ' Ġ}\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" dependencies Ġ{ Ġimplementation Ġfiles (' libs / my Lib . jar ') Ġ}\ n ") ĊĊĠĠĠ Ġcreate Project Sub File (" another - build / settings . gradle ", Ġ"") ĊĠĠĠ Ġcreate Project Sub File (" another - build / build Src / build . gradle ", Ġ" plugins Ġ{ Ġid Ġ' my project . my - test - plugin ' Ġ}\ n ") ĊĠĠĠ Ġcreate Project Sub File (" another - build / build Src / settings . gradle ", Ġ"") ĊĠĠĠ Ġval Ġdep Jar Ġ= Ġcreate Project Jar Sub File (" another - build / build Src / libs / my Lib . jar ") ĊĊĠĠĠ Ġcreate Settings File (" include Build Ġ' build - plugins '\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" include Build Ġ' another - build '") ĊĊĠĠĠ Ġimport Project ("") ĊĠĠĠ Ġassert Modules (" project ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" build - plugins ", Ġ" build - plugins . main ", Ġ" build - plugins . test ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" another - build ", Ġ" another - build . build Src ", Ġ" another - build . build Src . main ", Ġ" another - build . build Src . test ") ĊĊĠĠĠ Ġassert Module Lib Dep (" another - build . build Src . main ", Ġdep Jar . present able Url , Ġdep Jar . url ) ĊĠ Ġ} Ċ }