java.conf 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187
  1. macro _INPUT_WITH_FLAG(Flag, IN[]) {
  2. .CMD=$_INPUT_WITH_FLAG_IMPL(${pre=$Flag :IN} IN $IN)
  3. }
  4. macro _INPUT_WITH_FLAG_IMPL(IN{input}[], Args...) {
  5. .CMD=$Args ${hide;input:IN}
  6. }
  7. macro ACCELEO(XSD{input}[], MTL{input}[], MTL_ROOT="${MODDIR}", LANG{input}[], OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], DEBUG?"stdout2stderr":"stderr2stdout") {
  8. .PEERDIR=build/platform/java/jdk $JDK_RESOURCE_PEERDIR
  9. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input;pre=build/scripts/:DEBUG.py} $JDK_RESOURCE/bin/java -Dfile.encoding=utf8 -classpath ${RUN_JAR_PROG_CP_PRE}${tool:"tools/acceleo"}${RUN_JAR_PROG_CP_SUF} ru.yandex.se.logsng.tool.Cli $_INPUT_WITH_FLAG(--xsd IN $XSD) $_INPUT_WITH_FLAG(--mtl IN $MTL) $_INPUT_WITH_FLAG(--lang IN $LANG) --output-dir $BINDIR --build-root ${ARCADIA_BUILD_ROOT} --source-root ${ARCADIA_ROOT} --mtl-root $MTL_ROOT ${hide;output_include:OUTPUT_INCLUDES} ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${hide;kv:"p JV"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}
  10. }
  11. ### @usage: JAVA_LIBRARY()
  12. ###
  13. ### The module describing java library build.
  14. ###
  15. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  16. module JAVA_LIBRARY: JAR_LIBRARY {
  17. .SEM=BUILD_JAR_SEM
  18. }
  19. PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM=IGNORED
  20. module _JAR_PROGRAM_COMPILATION: JAR_LIBRARY {
  21. .IGNORED=JAVA_RUNTIME_PEERDIR JAVA_RUNTIME_EXCLUDE
  22. .ALIASES=JAVA_RUNTIME_PEERDIR=_NOOP_MACRO JAVA_RUNTIME_EXCLUDE=_NOOP_MACRO
  23. .FINAL_TARGET=no
  24. when ($OPENSOURCE == "yes" && $AUTOCHECK == "yes") {
  25. # FIXME: Replace AUTOCHECK == yes with _not a host platform_ check after YMAKE-218
  26. MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
  27. MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION REQUIRE_MODIFICATIONS_DISCLOSURE
  28. when ($MAKE_UBERJAR_VALUE == "yes") {
  29. # At the time LICENCE_RESTRICTION does not properly distinct static / dynamic linkage in UBERJAR() modules.
  30. # Hence we forbid using UBERJAR() in OPENSOURCE()
  31. #
  32. # Should be fixed in YMAKE-1043
  33. _OK = no
  34. }
  35. }
  36. when ($OS_IOS == "yes" || $OS_ANDROID == "yes" || $MAPSMOBI_BUILD_TARGET == "yes") {
  37. MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
  38. MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION
  39. }
  40. ASSERT(_OK "UBERJAR() macro can not be used in this configuration, see YMAKE-1043")
  41. }
  42. ### @usage: JAVA_PROGRAM()
  43. ###
  44. ### The module describing java programs build.
  45. ### Output artifacts: .jar and directory with all the jar to the classpath of the formation.
  46. ###
  47. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  48. multimodule JAVA_PROGRAM {
  49. module JAR_RUNNABLE: _JAR_RUNNABLE {
  50. .ALLOWED=JAVA_RUNTIME_PEERDIR JAVA_RUNTIME_EXCLUDE
  51. .SEM=PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM
  52. # TODO(svidyuk) JAVA_DEPENDENCIES_CONFIGURATION must not be ignored here but there are diagnostics issues in case of ECLUDE in the middle:
  53. # * A -> B -> C -> lib-v1.4
  54. # | |-> DM(lib-v1.1)
  55. # | |-> EXCLUDE(lib-v1.4)
  56. # | |-> FORBID_CONFLICT_DM_RECENT = OK
  57. # |-> DM(lib-v1.1)
  58. # |-> FORBID_CONFLICT_DM_RECENT = FAIL (because downgrade from v1.4 to v1.1 is detected before understanding that v1.4 was excuded on the examined path)
  59. .IGNORED=RUN_JAVA_PROGRAM JAVA_DEPENDENCIES_CONFIGURATION PROVIDES FEATURE_VERSION
  60. .ALIASES=JAVA_RUNTIME_PEERDIR=PEERDIR JAVA_RUNTIME_EXCLUDE=EXCLUDE
  61. .PEERDIRSELF=JAR_COMPILATION
  62. SET(MODULE_TYPE JAVA_PROGRAM)
  63. }
  64. module JAR_COMPILATION: _JAR_PROGRAM_COMPILATION {
  65. .SEM=BUILD_JAR_SEM
  66. SET(MODULE_TYPE JAVA_PROGRAM)
  67. }
  68. }
  69. _PROCESSOR_CLASSES_VALUE=
  70. _PROCESSOR_CLASSES_SEM=
  71. macro PROCESSOR_CLASSES(Classes...) {
  72. SET_APPEND(_PROCESSOR_CLASSES_VALUE $Classes)
  73. SET_APPEND(_PROCESSOR_CLASSES_SEM && java-apclasses $Classes)
  74. }
  75. _AUTO_SERVICE_SEM=
  76. macro AUTO_SERVICE(Ver) {
  77. USE_ANNOTATION_PROCESSOR(contrib/java/com/google/auto/service/auto-service/${Ver})
  78. PEERDIR(contrib/java/com/google/auto/service/auto-service-annotations/${Ver})
  79. SET(_AUTO_SERVICE_SEM && java-apautoservice $Ver)
  80. }
  81. _BUILD_JAVA_ANNOTATION_PROCESSOR_SEM=$BUILD_JAR_SEM $_PROCESSOR_CLASSES_SEM $_AUTO_SERVICE_SEM
  82. ### @usage: JAVA_ANNOTATION_PROCESSOR()
  83. ###
  84. ### The module describing java annotation processor build.
  85. ### Output artifacts: .jar and directory with all the jar to the classpath of the formation.
  86. ###
  87. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  88. multimodule JAVA_ANNOTATION_PROCESSOR {
  89. module JAR_RUNNABLE: _JAR_RUNNABLE {
  90. .ALLOWED=JAVA_RUNTIME_PEERDIR JAVA_RUNTIME_EXCLUDE
  91. .SEM=PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM
  92. .IGNORED=RUN_JAVA_PROGRAM PROVIDES FEATURE_VERSION
  93. .ALIASES=JAVA_RUNTIME_PEERDIR=PEERDIR JAVA_RUNTIME_EXCLUDE=EXCLUDE
  94. .PEERDIRSELF=JAR_COMPILATION
  95. SET(MODULE_TYPE JAVA_ANNOTATION_PROCESSOR)
  96. }
  97. module JAR_COMPILATION: _JAR_PROGRAM_COMPILATION {
  98. .SEM=_BUILD_JAVA_ANNOTATION_PROCESSOR_SEM
  99. }
  100. }
  101. _RUN_JAVA_CONTRIB_ANNOTATION_PROCESSOR_SEM=
  102. multimodule JAVA_CONTRIB_ANNOTATION_PROCESSOR {
  103. module JAR_RUNNABLE: _JAR_RUNNABLE {
  104. .IGNORED=JAVA_SRCS RUN_JAR_PROGRAM RUN_JAVA_PROGRAM JAR_RESOURCE SRC_RESOURCE LOCAL_JAR
  105. .PEERDIRSELF=JAR_COMPILATION
  106. .SEM=_RUN_JAVA_CONTRIB_ANNOTATION_PROCESSOR_SEM
  107. SET(MODULE_TYPE JAVA_ANNOTATION_PROCESSOR)
  108. ENABLE(DISABLE_SCRIPTGEN)
  109. }
  110. module JAR_COMPILATION: JAVA_CONTRIB {
  111. .ALIASES=JAVA_RUNTIME_PEERDIR=_NOOP_MACRO JAVA_RUNTIME_EXCLUDE=_NOOP_MACRO
  112. .FINAL_TARGET=no
  113. .SEM=_BUILD_JAVA_ANNOTATION_PROCESSOR_SEM
  114. }
  115. }
  116. ### Usage JUNIT_TESTS_JAR(path/to/some/peer realname.jar)
  117. ###
  118. ### Specifies jar to search test suites and test cases. By default tests are
  119. ### searched in the jar compild by JTEST or JUNIT5 module sources. This macro
  120. ### allows to specify diferent jar to search tests.
  121. ###
  122. ### Only one jar file is used to search tests. If this macro invoked multiple
  123. ### times (which is not reccomended practice) only the last invocation will
  124. ### have effect.
  125. ###
  126. ### If this macro is used no test from the module build by current ya.make
  127. ### will be searched and executed.
  128. macro JUNIT_TESTS_JAR(Dir, Jar) {
  129. SET(UNITTEST_DIR $Dir)
  130. PEERDIR($Dir)
  131. SET(UNITTEST_MOD $Dir/$Jar)
  132. }
  133. BUILD_JUNIT5_JAR_SEM=$BUILD_JAR_SEM && junit5_test
  134. multimodule JUNIT5 {
  135. # ATTENTION ya ide idea relies on this submodule name to find scope of `ya make` build before project generation
  136. module JAR_TESTABLE: _JAR_TEST {
  137. .ALLOWED=YT_SPEC
  138. # TODO(svidyuk) JAVA_DEPENDENCIES_CONFIGURATION must not be ignored here but there are diagnostics issues in case of ECLUDE in the middle:
  139. # * A -> B -> C -> lib-v1.4
  140. # | |-> DM(lib-v1.1)
  141. # | |-> EXCLUDE(lib-v1.4)
  142. # | |-> FORBID_CONFLICT_DM_RECENT = OK
  143. # |-> DM(lib-v1.1)
  144. # |-> FORBID_CONFLICT_DM_RECENT = FAIL (because downgrade from v1.4 to v1.1 is detected before understanding that v1.4 was excuded on the examined path)
  145. .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM JAVA_DEPENDENCIES_CONFIGURATION PROVIDES FEATURE_VERSION
  146. .ALIASES=JAVA_TEST_PEERDIR=PEERDIR JAVA_TEST_EXCLUDE=EXCLUDE
  147. .PEERDIRSELF=JAR_COMPILATION
  148. .SEM=PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM
  149. PEERDIR(devtools/jtest-annotations/junit5)
  150. SET(MODULE_TYPE JUNIT5)
  151. }
  152. module JAR_COMPILATION: JAR_LIBRARY {
  153. .ALLOWED=YT_SPEC
  154. .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO JAVA_TEST_EXCLUDE=_NOOP_MACRO
  155. .FINAL_TARGET=no
  156. .DEFAULT_NAME_GENERATOR=FullPath
  157. .SEM=BUILD_JUNIT5_JAR_SEM
  158. .IGNORED=JUNIT_TESTS_JAR
  159. PEERDIR+=devtools/junit5-runner
  160. PEERDIR+=build/platform/java/jacoco-agent
  161. when ($OPENSOURCE != "yes") {
  162. PEERDIR+=devtools/jtest-annotations/junit5
  163. }
  164. SET(MODULE_TYPE JUNIT5)
  165. when ($OPENSOURCE == "yes" && $AUTOCHECK == "yes") {
  166. # FIXME: Replace AUTOCHECK == yes with _not a host platform_ check after YMAKE-218
  167. MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
  168. MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION REQUIRE_MODIFICATIONS_DISCLOSURE
  169. when ($MAKE_UBERJAR_VALUE == "yes") {
  170. # At the time LICENCE_RESTRICTION does not properly distinct static / dynamic linkage in UBERJAR() modules.
  171. # Hence we forbid using UBERJAR() in OPENSOURCE()
  172. #
  173. # Should be fixed in YMAKE-1043
  174. _OK = no
  175. }
  176. }
  177. ASSERT(_OK "UBERJAR() macro can not be used in this condfiguration, see YMAKE-1043")
  178. }
  179. }
  180. BUILD_JUNIT4_JAR_SEM=$BUILD_JAR_SEM && junit4_test
  181. multimodule JTEST {
  182. # ATTENTION ya ide idea relies on this submodule name to find scope of `ya make` build before project generation
  183. module JAR_TESTABLE: _JAR_TEST {
  184. .ALLOWED=YT_SPEC
  185. # TODO(svidyuk) JAVA_DEPENDENCIES_CONFIGURATION must not be ignored here but there are diagnostics issues in case of ECLUDE in the middle:
  186. # * A -> B -> C -> lib-v1.4
  187. # | |-> DM(lib-v1.1)
  188. # | |-> EXCLUDE(lib-v1.4)
  189. # | |-> FORBID_CONFLICT_DM_RECENT = OK
  190. # |-> DM(lib-v1.1)
  191. # |-> FORBID_CONFLICT_DM_RECENT = FAIL (because downgrade from v1.4 to v1.1 is detected before understanding that v1.4 was excuded on the examined path)
  192. .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM JAVA_DEPENDENCIES_CONFIGURATION PROVIDES FEATURE_VERSION
  193. .ALIASES=JAVA_TEST_PEERDIR=PEERDIR JAVA_TEST_EXCLUDE=EXCLUDE
  194. .PEERDIRSELF=JAR_COMPILATION
  195. .SEM=PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM
  196. SET(MODULE_TYPE JTEST)
  197. PEERDIR(devtools/junit-runner devtools/jtest-annotations/junit4)
  198. DEPENDENCY_MANAGEMENT(contrib/java/com/google/code/gson/gson/2.10.1 contrib/java/com/beust/jcommander/1.72 contrib/java/junit/junit/4.12)
  199. }
  200. module JAR_COMPILATION: JAR_LIBRARY {
  201. .ALLOWED=YT_SPEC
  202. .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO JAVA_TEST_EXCLUDE=_NOOP_MACRO
  203. .FINAL_TARGET=no
  204. .DEFAULT_NAME_GENERATOR=FullPath
  205. .SEM=BUILD_JUNIT4_JAR_SEM
  206. .IGNORED=JUNIT_TESTS_JAR
  207. SET(MODULE_TYPE JTEST)
  208. DEPENDS(contrib/java/org/sonarsource/scanner/cli/sonar-scanner-cli/2.8)
  209. PEERDIR+=build/platform/java/jacoco-agent
  210. when ($OPENSOURCE != "yes") {
  211. PEERDIR+=devtools/jtest-annotations/junit4
  212. }
  213. when ($OPENSOURCE == "yes" && $AUTOCHECK == "yes") {
  214. # FIXME: Replace AUTOCHECK == yes with _not a host platform_ check after YMAKE-218
  215. MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
  216. MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION REQUIRE_MODIFICATIONS_DISCLOSURE
  217. when ($MAKE_UBERJAR_VALUE == "yes") {
  218. # At the time LICENCE_RESTRICTION does not properly distinct static / dynamic linkage in UBERJAR() modules.
  219. # Hence we forbid using UBERJAR() in OPENSOURCE()
  220. #
  221. # Should be fixed in YMAKE-1043
  222. _OK = no
  223. }
  224. }
  225. ASSERT(_OK "UBERJAR() macro can not be used in this configuration, see YMAKE-1043")
  226. }
  227. }
  228. multimodule JTEST_FOR {
  229. # ATTENTION ya ide idea relies on this submodule name to find scope of `ya make` build before project generation
  230. module JAR_TESTABLE: _JAR_TEST {
  231. .ALLOWED=YT_SPEC
  232. # TODO(svidyuk) JAVA_DEPENDENCIES_CONFIGURATION must not be ignored here but there are diagnostics issues in case of ECLUDE in the middle:
  233. # * A -> B -> C -> lib-v1.4
  234. # | |-> DM(lib-v1.1)
  235. # | |-> EXCLUDE(lib-v1.4)
  236. # | |-> FORBID_CONFLICT_DM_RECENT = OK
  237. # |-> DM(lib-v1.1)
  238. # |-> FORBID_CONFLICT_DM_RECENT = FAIL (because downgrade from v1.4 to v1.1 is detected before understanding that v1.4 was excuded on the examined path)
  239. .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM JAVA_DEPENDENCIES_CONFIGURATION PROVIDES FEATURE_VERSION
  240. .ALIASES=JAVA_TEST_PEERDIR=PEERDIR JAVA_TEST_EXCLUDE=EXCLUDE
  241. .RESTRICTED=JUNIT_TESTS_JAR
  242. .PEERDIRSELF=JAR_COMPILATION
  243. .SEM=PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM
  244. SET(MODULE_TYPE JTEST_FOR)
  245. PEERDIR(${UNITTEST_DIR} devtools/junit-runner)
  246. DEPENDENCY_MANAGEMENT(contrib/java/com/google/code/gson/gson/2.8.6 contrib/java/com/beust/jcommander/1.72 contrib/java/junit/junit/4.12)
  247. }
  248. module JAR_COMPILATION: JAR_LIBRARY {
  249. .ALLOWED=YT_SPEC
  250. .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO JAVA_TEST_EXCLUDE=_NOOP_MACRO
  251. .FINAL_TARGET=no
  252. .DEFAULT_NAME_GENERATOR=FullPath
  253. .SEM=BUILD_JUNIT4_JAR_SEM
  254. .RESTRICTED=JUNIT_TESTS_JAR
  255. SET(MODULE_TYPE JTEST_FOR)
  256. DEPENDS(contrib/java/org/sonarsource/scanner/cli/sonar-scanner-cli/2.8)
  257. PEERDIR(devtools/junit-runner build/platform/java/jacoco-agent ${UNITTEST_DIR})
  258. }
  259. }
  260. # TODO Something for using tool in RUN_JAVA_PROGRAM
  261. _SEM_JAR_RUNNABLE=
  262. multimodule JAVA_CONTRIB_PROGRAM {
  263. module JAR_RUNNABLE: _JAR_RUNNABLE {
  264. .IGNORED=JAVA_SRCS RUN_JAR_PROGRAM RUN_JAVA_PROGRAM JAR_RESOURCE SRC_RESOURCE LOCAL_JAR
  265. .PEERDIRSELF=JAR_COMPILATION
  266. .SEM=_SEM_JAR_RUNNABLE
  267. SET(MODULE_TYPE JAVA_PROGRAM)
  268. ENABLE(DISABLE_SCRIPTGEN)
  269. }
  270. module JAR_COMPILATION: JAVA_CONTRIB {
  271. .ALIASES=JAVA_RUNTIME_PEERDIR=_NOOP_MACRO JAVA_RUNTIME_EXCLUDE=_NOOP_MACRO
  272. .FINAL_TARGET=no
  273. .SEM=BUILD_JAR_SEM
  274. }
  275. }
  276. # tag:java-specific
  277. JAVA_VCS_MF_ARG=
  278. COMPILE_JAVA_MF=${hide:JAVA_FAKEID} $COMPILE_JAVA $MAVEN_EXPORT_CMD
  279. # tag:java-specific
  280. when ($EXT_JAVA_VCS_INFO == "yes") {
  281. JAVA_VCS_MF_ARG=--vcs-mf $VCS_JAVA
  282. COMPILE_JAVA_MF=${hide:JAVA_FAKEID} $GENERATE_VCS_JAVA_INFO_NODEP && $COMPILE_JAVA $MAVEN_EXPORT_CMD
  283. }
  284. # tag:java-specific
  285. EXT_JAVA_VCS_INFO=no
  286. ### @usage: EMBED_JAVA_VCS_INFO()
  287. ###
  288. ### Embed manifest with vcs info into `EXTERNAL_JAVA_LIBRARY`
  289. ### By default this is disabled.
  290. macro EMBED_JAVA_VCS_INFO() {
  291. .SEM=add_vcs_info_to_mf ${hide;output:"VcsInfoMfDummy.java"}
  292. ENABLE(EXT_JAVA_VCS_INFO)
  293. }
  294. # tag:java-specific tag:internal
  295. ### @usage: EXTERNAL_JAVA_LIBRARY() #internal
  296. ###
  297. ### EXTERNAL_JAVA_LIBRARY() is a module for creating a .jar file using non-Java code (generators etc.)
  298. ### Unlike regular JAVA_LIBRARY this module doesn't produce .pom file, so it cannot be exported to Maven itself.
  299. ### PEERDIR it from JAVA_LIBRARY or JAVA_PROGRAM for export to Maven.
  300. module EXTERNAL_JAVA_LIBRARY: _BASE_UNIT {
  301. .EXTS=.jsrc .java .jar .mf
  302. .NODE_TYPE=Bundle
  303. .CMD=COMPILE_JAVA_MF
  304. # TODO(YMAKE-27) all contribs involved into opensource export must be JAVA_CONTRIB modules
  305. # and this module must not be intended for export. Such hange will break JBUILD and thus is
  306. # blocked on YMAKE-27
  307. .SEM=JAVA_CONTRIB_SEM
  308. .PEERDIR_POLICY=as_build_from
  309. .FINAL_TARGET=no
  310. .ALIASES=SRCS=_SRCS_NO_GLOBAL
  311. .ALLOWED=EMBED_JAVA_VCS_INFO
  312. .RESTRICTED=EXTERNAL_JAR
  313. .GLOBAL=MAVEN_EXPORT_COORDS
  314. SET(MODULE_TAG JAVA)
  315. PEERDIR(build/platform/java/jdk)
  316. PEERDIR+=$JDK_RESOURCE_PEERDIR $EXTERNAL_JAVA_EXTRA_PEERDIR
  317. when ($KOTLIN_PROTO == "yes") {
  318. PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${_KOTLIN_VERSION}
  319. }
  320. when ($MAVEN_EXPORT == "yes") {
  321. when ($MAVEN_DEPLOY == "yes") {
  322. PEERDIR+=build/external_resources/maven
  323. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM && $MAVEN_DEPLOY_CMD
  324. }
  325. otherwise {
  326. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM
  327. }
  328. MAVEN_EXPORT_COORDS_GLOBAL=$MAVEN_EXPORT_GROUP_ID:${MODULE_PREFIX}${REALPRJNAME}:${MAVEN_EXPORT_VERSION}:
  329. }
  330. PEERDIR_TAGS=JAVA JAVA_PROTO JAVA_FBS JAVA_IDL PACKAGE_UNION
  331. HAS_MANAGEABLE_PEERS=yes
  332. DYNAMIC_LINK=yes
  333. _PROTO_CMDLINE=$_JAVA_PROTO_CMDLINE
  334. _EVLOG_CMDLINE=$_JAVA_EVLOG_CMDLINE
  335. _FBS_CMDLINE=$_JAVA_FLATC_CMDLINE
  336. when ($PACKAGE_PREFIX) {
  337. PACKAGE_PREFIX_ARGS=--package-prefix=$PACKAGE_PREFIX
  338. }
  339. DISABLE(NEED_PLATFORM_PEERDIRS)
  340. NO_PLATFORM()
  341. SET(MODULE_SUFFIX .jar)
  342. SET(MODULE_LANG JAVA)
  343. _WHEN_EXPORT_GRADLE()
  344. }
  345. # tag:java-specific
  346. ALL_JAR_SOURCES=
  347. LINT_JAVA_SOURCES=
  348. ALL_SRCDIRS=
  349. LINK_JAR_RESOURCES=
  350. LINK_JAR_JSOURCES=
  351. JAR_GEN_SRCS=
  352. JAR_GEN_JSRCS=
  353. macro _JAVA_SRCS(RESOURCES?"yes":"no", SRCDIR=".", PACKAGE_PREFIX="", EXCLUDE[], FILES[], SKIP_CHECK_SRCDIR?"SKIP_CHECK_SRCDIR":"", Globs...) {
  354. _CHECK_JAVA_SRCDIR($SKIP_CHECK_SRCDIR $SRCDIR)
  355. SET_APPEND(ALL_SRCDIRS $SRCDIR)
  356. SET(VAR_SALT $SRCDIR $Globs $EXCLUDE $PACKAGE_PREFIX $RESOURCES $FILES)
  357. SET(JAR_SRCS_GLOB uniq_${hash:VAR_SALT})
  358. _LATE_GLOB(${JAR_SRCS_GLOB} ${pre=${SRCDIR}/:Globs} EXCLUDE ${EXCLUDE})
  359. SET_APPEND(LINT_JAVA_SOURCES \${input;rootrel;ext=.java:${JAR_SRCS_GLOB}})
  360. SET_APPEND(ALL_JAR_SOURCES --jsources ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt --resources ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt --srcdir ${quo:SRCDIR} \${input:${JAR_SRCS_GLOB}} ${pre=\$\{input\:\";suf=\"\}:FILES})
  361. _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_RESOURCES ${quo:SRCDIR} ${BINDIR}/cls ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt)
  362. _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_JSOURCES ${quo:SRCDIR} ${BINDIR}/src ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt)
  363. _FILL_JAR_GEN_SRCS(JAR_GEN_SRCS JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst $KT_SRCLIST ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt $Globs EXCLUDE $EXCLUDE)
  364. _FILL_JAR_GEN_SRCS(JAR_GEN_JSRCS SRC_JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst $KT_SRCLIST ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt $Globs EXCLUDE $EXCLUDE)
  365. }
  366. # tag:java-specific
  367. # Fill semantic jar_source_set by JAVA_SRCS() Args
  368. SEM_JAR_SOURCE_SET=
  369. macro _SEM_JAR_SOURCE_SET(SRCDIR=".", PACKAGE_PREFIX="", EXCLUDE[], FILES[], RESOURCES?"RESOURCES":"", SKIP_CHECK_SRCDIR?"SKIP_CHECK_SRCDIR":"", Globs...) {
  370. # Now ignore SKIP_CHECK_SRCDIR, PACKAGE_PREFIX, EXCLUDE, RESOURCES, FILES
  371. SET_APPEND(SEM_JAR_SOURCE_SET && jar_source_set ${pre=${SRCDIR}\::Globs})
  372. }
  373. ### Fill JAVA_SRCS to value for ya ide idea and real apply for late globs
  374. macro FULL_JAVA_SRCS(Args...) {
  375. _IDEA_JAVA_SRCS_VALUE($Args)
  376. _JAVA_SRCS($Args)
  377. }
  378. # tag:java-specific
  379. ### @usage: DEFAULT_JAVA_SRCS_LAYOUT()
  380. ###
  381. ### DEFAULT_JAVA_SRCS_LAYOUT() declare all source files can be find at maven/gradle standard path src/main/java **/*.java
  382. ### and all resources an be find at maven/gradle standard path src/main/resources **/*
  383. macro DEFAULT_JAVA_SRCS_LAYOUT() {
  384. # Maven default source paths, supported by gradle too
  385. # JAVA_SRCS may be alias of FULL_JAVA_SRCS
  386. FULL_JAVA_SRCS(SRCDIR src/main/java **/*.java SKIP_CHECK_SRCDIR)
  387. FULL_JAVA_SRCS(RESOURCES SRCDIR src/main/resources **/* SKIP_CHECK_SRCDIR)
  388. }
  389. # tag:java-specific
  390. ### @usage: DEFAULT_JUNIT_JAVA_SRCS_LAYOUT()
  391. ###
  392. ### DEFAULT_JUNIT_JAVA_SRCS_LAYOUT() declare all test source files can be find at maven/gradle standard path src/test/java **/*.java
  393. ### and all resources can be find at maven/gradle standard path src/test/resources **/*
  394. macro DEFAULT_JUNIT_JAVA_SRCS_LAYOUT() {
  395. # Maven default test source paths, supported by gradle too
  396. # JAVA_SRCS may be alias of FULL_JAVA_SRCS
  397. FULL_JAVA_SRCS(SRCDIR java **/*.java SKIP_CHECK_SRCDIR)
  398. FULL_JAVA_SRCS(RESOURCES SRCDIR resources **/* SKIP_CHECK_SRCDIR)
  399. }
  400. macro _HASH_HELPER(Args...) {
  401. .CMD=${hash:Args}
  402. .SEM=${hash:Args}
  403. }
  404. macro _GENTAR_HELPER(OUT_DIR[], Args...) {
  405. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --pack ${OUT_DIR} --outs ${output;tared;suf=.$_HASH_HELPER($Args).gentar:OUT_DIR} ${hide;kv:"tared_kind nodir"}
  406. }
  407. # tag:java-specific
  408. RUN_JAR_PROG_CP_PRE=@
  409. RUN_JAR_PROG_CP_SUF=.cplst
  410. when($JDK_VERSION == "8") {
  411. RUN_JAR_PROG_CP_PRE=
  412. RUN_JAR_PROG_CP_SUF=
  413. }
  414. # tag:java-specific
  415. JDK_LATEST_VERSION=23
  416. JDK_LATEST_PEERDIR=build/platform/java/jdk/jdk${JDK_LATEST_VERSION}
  417. # tag:java-specific
  418. # Fill semantic by RUN_JAVA_PROGRAM()
  419. _SEM_RUN_JAVA_PROGRAM=runs-ITEM \
  420. && runs-args ${Args} \
  421. && runs-classpath ${RUN_JAR_PROG_CP_PRE}${tool:CLASSPATH}${RUN_JAR_PROG_CP_SUF} \
  422. && runs-cwd ${CWD} ${hide;cwd:CWD} \
  423. && runs-in ${IN} ${hide;input:IN} \
  424. && runs-in_dir ${IN_DIR} \
  425. && runs-in_dirs_inputs ${IN_DIRS_INPUTS} \
  426. && runs-in_noparse ${IN_NOPARSE} ${hide;context=TEXT;input:IN_NOPARSE} \
  427. && runs-out ${OUT} ${hide;output:OUT} ${OUT_NOAUTO} ${hide;noauto;output:OUT_NOAUTO} ${hide;output;suf=.$_HASH_HELPER($CLASSPATH $IN_DIR $IN $IN_NOPARSE $TOOL $Args).gentar:OUT_DIR} \
  428. && runs-out_dir ${OUT_DIR} \
  429. && runs-tool ${TOOL} ${hide;tool:TOOL}
  430. macro _DO_2_RUN_JAR_PROGRAM(IN_DIRS_VAR="uniq_", IN_DIRS_INPUTS[], IN{input}[], IN_NOPARSE{input}[], IN_DIR[], OUT_NOAUTO{output}[], OUT{output}[], TOOL{tool}[], OUT_DIR[], CLASSPATH[], ADD_SRCS_TO_CLASSPATH?"yes":"no", CWD="${ARCADIA_BUILD_ROOT}", STDOUT="", STDOUT_NOAUTO="", Args...) {
  431. _LATE_GLOB(${IN_DIRS_VAR} ${suf=/**/*:IN_DIR})
  432. _CHECK_RUN_JAVA_PROG_CLASSPATH($CLASSPATH)
  433. .PEERDIR=build/platform/java/jdk $JDK_RESOURCE_PEERDIR
  434. .CMD=${hide;kv:"p RJ"} ${hide;kv:"pc blue"} ${hide:JAVA_FAKEID} ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} ${OUT_DIR} && ${cwd:CWD} $YMAKE_PYTHON ${input:"build/scripts/setup_java_tmpdir.py"} $YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} ${pre=--file=:STDOUT} ${hide;output:STDOUT} ${pre=--file=:STDOUT_NOAUTO} ${hide;noauto;output:STDOUT_NOAUTO} $YMAKE_PYTHON ${input:"build/scripts/fix_java_command_file_cp.py"} --build-root ${ARCADIA_BUILD_ROOT} $JDK_RESOURCE/bin/java -Dfile.encoding=utf8 -classpath ${RUN_JAR_PROG_CP_PRE}${tool:CLASSPATH}${RUN_JAR_PROG_CP_SUF} ${Args} && $_GENTAR_HELPER($CLASSPATH $IN_DIR $IN $IN_NOPARSE $TOOL $Args OUT_DIR $OUT_DIR) ${hide;input:IN} ${hide;context=TEXT;input:IN_NOPARSE} ${hide;noauto;output:OUT_NOAUTO} ${hide;output:OUT} ${hide;tool:TOOL} ${IN_DIRS_INPUTS}
  435. .SEM=$_SEM_RUN_JAVA_PROGRAM
  436. }
  437. # tag:java-specific
  438. macro _DO_1_RUN_JAR_PROGRAM(IN_DIRS_VAR="uniq", Args...) {
  439. _DO_2_RUN_JAR_PROGRAM($Args IN_DIRS_VAR $IN_DIRS_VAR IN_DIRS_INPUTS ${"$"}{hide;input:$IN_DIRS_VAR})
  440. }
  441. # tag:java-specific
  442. macro RUN_JAVA_PROGRAM(Args...) {
  443. _DO_1_RUN_JAR_PROGRAM($Args IN_DIRS_VAR uniq_${hash:Args})
  444. }
  445. # tag:java-specific
  446. _JAR_ANN_PROCESSORS=
  447. _JAR_ANN_PROC_OPT_PREFIX=
  448. _ANN_PROCESSORS_SEM=
  449. macro JAR_ANNOTATION_PROCESSOR(Classes...) {
  450. SET_APPEND(_JAR_ANN_PROCESSORS $Classes)
  451. SET(_JAR_ANN_PROC_OPT_PREFIX -processor)
  452. SET_APPEND(_ANN_PROCESSORS_SEM && annotation_processors $Classes)
  453. # for ya ide idea only
  454. SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Classes)
  455. }
  456. # tag:java-specific
  457. macro _JAR_ANN_PROC_OPTS(Classes...) {
  458. .CMD=$_JAR_ANN_PROC_OPT_PREFIX ${join=,:Classes} $_USE_ANNOTATION_PROCESSOR_OPT
  459. }
  460. # tag:java-specific
  461. _USE_ANNOTATION_PROCESSOR_TOOL=
  462. _USE_ANNOTATION_PROCESSOR_SEM=
  463. ### @usage: USE_ANNOTATION_PROCESSOR(Path)
  464. ###
  465. ### Used to specify annotation processor for building JAVA_PROGRAM() and JAVA_LIBRARY().
  466. macro USE_ANNOTATION_PROCESSOR(Path) {
  467. SET(_USE_ANNOTATION_PROCESSOR_TOOL $Path)
  468. SET(_USE_ANNOTATION_PROCESSOR_SEM && use_annotation_processor $Path)
  469. }
  470. when ($_USE_ANNOTATION_PROCESSOR_TOOL != "") {
  471. _USE_ANNOTATION_PROCESSOR_CMD=${tool:_USE_ANNOTATION_PROCESSOR_TOOL}
  472. _USE_ANNOTATION_PROCESSOR_OPT=${pre=-processorpath "@";suf=.cplst:_USE_ANNOTATION_PROCESSOR_CMD}
  473. }
  474. otherwise {
  475. _USE_ANNOTATION_PROCESSOR_CMD=
  476. _USE_ANNOTATION_PROCESSOR_OPT=
  477. }
  478. # tag:java-specific
  479. macro _NOOP_MACRO(Args...) {
  480. ENABLE(UNUSED_MACRO)
  481. }
  482. # tag:java-specific
  483. module _JAR_BASE: _BARE_UNIT {
  484. .NODE_TYPE=Bundle
  485. .CMD=TOUCH_UNIT
  486. .PEERDIR_POLICY=as_build_from
  487. .FINAL_TARGET=no
  488. .ALIASES=SRCS=_SRCS_NO_GLOBAL
  489. .ALLOWED=EMBED_JAVA_VCS_INFO DEPENDENCY_MANAGEMENT EXCLUDE
  490. .DEFAULT_NAME_GENERATOR=TwoDirNames
  491. .RESTRICTED=WITH_JDK RESOURCE RESOURCE_FILES
  492. SET(MODULE_TAG JAVA)
  493. PEERDIR_TAGS=JAVA JAVA_PROTO JAVA_FBS JAVA_IDL DLL JAR_COMPILATION __EMPTY__ RESOURCE_LIB
  494. HAS_MANAGEABLE_PEERS=yes
  495. DYNAMIC_LINK=yes
  496. _PROTO_CMDLINE=$_JAVA_PROTO_CMDLINE
  497. _EVLOG_CMDLINE=$_JAVA_EVLOG_CMDLINE
  498. _FBS_CMDLINE=$_JAVA_FLATC_CMDLINE
  499. DISABLE(NEED_PLATFORM_PEERDIRS)
  500. NO_PLATFORM()
  501. VCS_JAVA=${suf=.__vcs_version__.mf:TARGET}
  502. SET(MODULE_LANG JAVA)
  503. _WHEN_EXPORT_GRADLE()
  504. }
  505. JAVA_CONTRIB_PROXY_SEM=IGNORED
  506. # tag:java-specific
  507. module JAVA_CONTRIB_PROXY: _JAR_BASE {
  508. .SEM=JAVA_CONTRIB_PROXY_SEM
  509. _DONT_REQUIRE_LICENSE()
  510. WITHOUT_VERSION()
  511. }
  512. # tag:java-specific
  513. macro _FETCH_CONTRIB(Id, Out, SBR="sbr:") {
  514. .CMD=${hide:SANDBOX_FAKEID} ${cwd:BINDIR} ${resource;pre=$SBR:Id} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_sandbox.py"} --resource-file $(RESOURCE_ROOT)/sbr/$Id/resource --resource-id $Id --copy-to ${output:Out} ${hide;input:"build/scripts/fetch_from.py"} ${requirements;hide:"network:full"} ${hide;kv:"p SB"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
  515. ADD_CHECK(check.resource $Id)
  516. }
  517. # tag:java-specific
  518. LOCAL_JAR_PATH=
  519. LOCAL_SOURCES_JAR_PATH=
  520. JAR_RESOURCE_ID=
  521. SRC_RESOURCE_ID=
  522. FETCH_SRCS_JAR=
  523. FETCH_TARGET_JAR=
  524. FETCH_CONTRIB_JAR=${hide:JAVA_FAKEID} $FETCH_TARGET_JAR $FETCH_SRCS_JAR
  525. # tag:java-specific
  526. macro JAR_RESOURCE(Id) {
  527. SET(JAR_RESOURCE_ID $Id)
  528. }
  529. # tag:java-specific
  530. macro SRC_RESOURCE(Id) {
  531. SET(SRC_RESOURCE_ID $Id)
  532. }
  533. # tag:java-specific
  534. macro LOCAL_JAR(File) {
  535. SET(LOCAL_JAR_PATH $File)
  536. }
  537. # tag:java-specific
  538. macro LOCAL_SOURCES_JAR(File) {
  539. SET(LOCAL_SOURCES_JAR_PATH $File)
  540. }
  541. JAVA_CONTRIB_SEM= \
  542. ${hide:TARGET} ${hide:AUTO_INPUT} \
  543. consumer-classpath $EXPORT_GRADLE_CLASSPATH \
  544. && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
  545. && consumer-type contrib \
  546. $_JAVAC_SEM \
  547. && IGNORED
  548. # tag:java-specific
  549. module JAVA_CONTRIB: _JAR_BASE {
  550. .CMD=FETCH_CONTRIB_JAR
  551. .PEERDIR_POLICY=as_include
  552. .SEM=JAVA_CONTRIB_SEM
  553. .FINAL_TARGET=yes
  554. .GLOBAL=MAVEN_EXPORT_COORDS
  555. when ($JAR_RESOURCE_ID) {
  556. FETCH_TARGET_JAR= && $_FETCH_CONTRIB($JAR_RESOURCE_ID ${BINDIR}/${MODULE_PREFIX}${REALPRJNAME}${MODULE_SUFFIX})
  557. }
  558. otherwise {
  559. when ($LOCAL_JAR_PATH) {
  560. FETCH_TARGET_JAR= && $FS_TOOLS copy ${input:LOCAL_JAR_PATH} $TARGET
  561. }
  562. otherwise {
  563. FETCH_TARGET_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && ${cwd:BINDIR} $JDK_RESOURCE/bin/jar cfvm $TARGET $VCS_JAVA .
  564. PEERDIR+=build/platform/java/jdk
  565. PEERDIR+=$JDK_RESOURCE_PEERDIR
  566. }
  567. }
  568. when ($SRC_RESOURCE_ID) {
  569. FETCH_SRCS_JAR= && $_FETCH_CONTRIB($SRC_RESOURCE_ID ${BINDIR}/${REALPRJNAME}-sources.jar)
  570. }
  571. otherwise {
  572. when ($LOCAL_SOURCES_JAR_PATH) {
  573. FETCH_SRCS_JAR= && $FS_TOOLS copy ${input:LOCAL_SOURCES_JAR_PATH} ${output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME}
  574. }
  575. otherwise {
  576. FETCH_SRCS_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && $FS_TOOLS md ${BINDIR}/fake-src && ${cwd;suf=/fake-src:BINDIR} $JDK_RESOURCE/bin/jar cfvm ${output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME} $VCS_JAVA .
  577. PEERDIR+=build/platform/java/jdk
  578. PEERDIR+=$JDK_RESOURCE_PEERDIR
  579. }
  580. }
  581. when ($MAVEN_EXPORT == "yes") {
  582. _MAKEFILE_INCLUDE_LIKE_DEPS+=pom.xml
  583. FETCH_CONTRIB_JAR+= && $MAVEN_EXPORT_GEN_DEPLST
  584. }
  585. SET(MODULE_SUFFIX .jar)
  586. _SETUP_MAVEN_EXPORT_COORDS_IF_NEED($MODDIR)
  587. }
  588. MAKE_JAVA_CLASSPATH_FILE=$YMAKE_PYTHON ${input:"build/scripts/make_java_classpath_file.py"} ${hide;input:"build/scripts/process_command_files.py"}
  589. # tag:kotlin-specific
  590. KOTLINC_OPTS_VALUE=
  591. # tag:kotlin-specific
  592. KT_SRCLIST=${BINDIR}/misc/all-kt-sources.txt
  593. KT_SRSCLIST_FLAG=--kotlin $KT_SRCLIST
  594. KT_CLASSES_DIR=${BINDIR}/kt_cls
  595. KT_CLASSPATH=${BINDIR}/kt_cp.txt
  596. COLLECT_KT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/kt_bfg.txt -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file
  597. LINK_KT_CLASSPATH=${MAKE_JAVA_CLASSPATH_FILE} ${BINDIR}/kt_bfg.txt $KT_CLASSPATH && $FS_TOOLS md $KT_CLASSES_DIR
  598. COMPILE_KT= \
  599. ${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} \
  600. ${hide;input:"build/scripts/build_java_with_error_prone2.py"} \
  601. ${hide;input:"build/scripts/setup_java_tmpdir.py"} \
  602. --kotlin --sources-list $KT_SRCLIST \
  603. $JDK_RESOURCE/bin/java -jar $KOTLIN_COMPILER_RESOURCE_GLOBAL/kotlin-compiler.jar -no-stdlib -module-name $REALPRJNAME \
  604. -jvm-target ${KOTLIN_JVM_TARGET} @$KT_SRCLIST -classpath @$KT_CLASSPATH $KOTLINC_FLAGS_VALUE -d $KT_CLASSES_DIR $KOTLINC_OPTS_VALUE
  605. ALL_KT_COMMANDS=
  606. KT_CLASSPATH_ITEM=
  607. # tag:kotlin-specific
  608. KT_KAPT_SOURCES_DIR=${BINDIR}/kapt_gen_src
  609. KT_KAPT_STUBS_DIR=${BINDIR}/kapt_gen_stubs
  610. KT_KAPT_AP_CLASSPATH=
  611. KT_KAPT_PLUGIN_OPTS=-P plugin:org.jetbrains.kotlin.kapt3:sources=${KT_KAPT_SOURCES_DIR} -P plugin:org.jetbrains.kotlin.kapt3:classes=${KT_CLASSES_DIR} -P plugin:org.jetbrains.kotlin.kapt3:stubs=${KT_KAPT_STUBS_DIR} -P plugin:org.jetbrains.kotlin.kapt3:aptMode=stubsAndApt
  612. ### @usage: KAPT_OPTS(opts...)
  613. ###
  614. ### Used to specify annotation processor qualified class names.
  615. ### If specified multiple times, only last specification is used.
  616. macro KAPT_OPTS(Args...) {
  617. SET_APPEND(KT_KAPT_PLUGIN_OPTS ${pre=-P :Args})
  618. }
  619. ### @usage: KAPT_ANNOTATION_PROCESSOR(processors...)
  620. ###
  621. ### Used to specify annotation processor qualified class names.
  622. ### If specified multiple times, only last specification is used.
  623. macro KAPT_ANNOTATION_PROCESSOR(Args...) {
  624. KAPT_OPTS(${pre="plugin:org.jetbrains.kotlin.kapt3:processors=":Args})
  625. }
  626. ### @usage: KAPT_ANNOTATION_PROCESSOR_CLASSPATH(jars...)
  627. ###
  628. ### Used to specify classpath for annotation processors.
  629. ### If specified multiple times, all specifications are used.
  630. macro KAPT_ANNOTATION_PROCESSOR_CLASSPATH(Args...) {
  631. PEERDIR($Args)
  632. SET_APPEND(KT_KAPT_AP_CLASSPATH $Args)
  633. }
  634. # tag:java-specific
  635. JAVAC_CMD=$JDK_RESOURCE/bin/javac
  636. RUN_JAVAC_ARGS=
  637. # tag:java-specific tag:codenav
  638. JAVA_YNDEXING=no
  639. # tag:java-specific
  640. when ($USE_SYSTEM_KYTHE) {
  641. KYTHE_RESOURCE=$USE_SYSTEM_KYTHE
  642. }
  643. otherwise {
  644. KYTHE_RESOURCE=$KYTHE_RESOURCE_GLOBAL
  645. }
  646. # tag:java-specific tag:codenav
  647. _JAVA_YNDEXING_CMD=$YMAKE_PYTHON ${input:"build/scripts/build_java_codenav_index.py"} $TARGET $ARCADIA_BUILD_ROOT $ARCADIA_ROOT ${BINDIR}/all-java.srclst $JDK_RESOURCE/bin/java -jar $KYTHE_RESOURCE/kythe/extractors/javac_extractor.jar
  648. _DO_JAVA_YNDEXING=
  649. # tag:java-specific
  650. SOURCES_JAR=no
  651. when ($BUILD_TYPE == "DEBUG" && $NO_DEBUGINFO != "yes") {
  652. SOURCES_JAR=yes
  653. }
  654. _PACK_SRC_JAR_IMPL=&& $FS_TOOLS md ${BINDIR}/src $JAR_GEN_JSRCS $LINK_JAR_JSOURCES && ${cwd;suf=/src:BINDIR} $JDK_RESOURCE/bin/jar cfvm ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} $VCS_JAVA .
  655. _PACK_SRC_JAR=
  656. # tag:java-specific
  657. _PACK_JNI=
  658. _PACK_JNI_CMD= && $FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} --ya-end-command-file ${BINDIR}/cls
  659. # tag:java-specific
  660. _MAKE_JSTYLE_FILE_LIST=
  661. # tag:java-specific
  662. _LINK_UBERJAR=
  663. _UBERJAR_SELF=
  664. _DO_LINK_UBERJAR= && $JDK_RESOURCE/bin/java -cp $UBERJAR_RESOURCE/devtools-java_shader.jar ru.yandex.devtools.emigrante.Main --out-jar $TARGET $_UBERJAR_SELF ${ext=.jar;pre=--jar :MANAGED_PEERS_CLOSURE} ${UBERJAR_PREFIX_FLAG} ${UBERJAR_HIDE_EXCLUDE_FLAGS} ${UBERJAR_HIDE_INCLUDE_FLAGS} $UBERJAR_PATH_EXCLUDES ${UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG} ${UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS} ${UBERJAR_APPENDING_TRANSFORMER_FLAGS} ${UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG} \
  665. && $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} $BINDIR/_empty/META-INF \
  666. && $YMAKE_PYTHON ${input:"build/scripts/touch.py"} $BINDIR/_empty/META-INF/MANIFEST.MF \
  667. && $UPDATE_VCS_JAVA_INFO_NODEP($TARGET) \
  668. && ${cwd;suf=/_empty:BINDIR} ${JDK_RESOURCE}/bin/jar ufv ${TARGET} META-INF/MANIFEST.MF \
  669. && $JDK_RESOURCE/bin/jar ufvm $TARGET $VCS_JAVA
  670. # tag:java-specific
  671. macro _PACK_JAR_HELPER(Out) {
  672. .CMD=${cwd;suf=/cls:BINDIR} ${env:"LC_ALL=en_US.UTF-8"} $JDK_RESOURCE/bin/jar cfvm $Out $VCS_JAVA .
  673. }
  674. # tag:java-specific
  675. macro _JAVAC_RUN_HELPER(JAVAC_CMD_WITH_ARGS...) {
  676. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} ${hide;input:"build/scripts/build_java_with_error_prone2.py"} ${hide;input:"build/scripts/setup_java_tmpdir.py"} --with-setup-java-tmpdir --sources-list ${BINDIR}/all-java.srclst ${RUN_JAVAC_ARGS} ${JAVAC_CMD_WITH_ARGS} @${BINDIR}/all-java.srclst -classpath ${ARCADIA_BUILD_ROOT}/bfg.jar -Xpkginfo:always ${JAVAC_OPTS} $_JAR_ANN_PROC_OPTS($_JAR_ANN_PROCESSORS) -d ${BINDIR}/cls -g -encoding UTF-8
  677. }
  678. # tag:java-specific
  679. ERROR_PRONE_JDK16PLUS_ADD_OPENS=-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
  680. ERROR_PRONE_2_7_1_FORCED_OPTS=-Xep:InlineMeInliner:OFF -Xep:SameNameButDifferent:OFF
  681. # tag:java-specific
  682. macro _ADD_OPTS_IF_NON_EMPTY(Opt, Args...) {
  683. .CMD=${pre=$Opt :Args}
  684. }
  685. macro _ADD_GEN_POM_FROM_COORD_FILES_ARGS(Deps...) {
  686. .CMD=${pre=--deps-coords ;ext=.jar;suf=.mvn_coords:Deps}
  687. }
  688. MAVEN_BIN=$MAVEN_RESOURCE_GLOBAL/bin/mvn
  689. MAVEN_EXPORT_OUT_DIR_FLAG=$_ADD_OPTS_IF_NON_EMPTY(--output-dir ${MAVEN_EXPORT_OUT_DIR})
  690. MAVEN_EXPORT_SOURCE_DIRS=$_ADD_OPTS_IF_NON_EMPTY(--source-dirs ${ALL_SRCDIRS})
  691. MAVEN_EXPORT_DEPS_COORS=$_ADD_GEN_POM_FROM_COORD_FILES_ARGS(${MANAGED_PEERS_CLOSURE})
  692. MAVEN_EXPORT_OUT_DIR=
  693. MAVEN_EXPORT=no
  694. MAVEN_DEPLOY=no
  695. MAVEN_DEPLOY_SOURCES=
  696. MAVEN_EXPORT_VERSION={vcs_revision}
  697. MAVEN_EXPORT_GEN_DEPLST= \
  698. $WRITER_PY \
  699. --file ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mvn_coords:REALPRJNAME} \
  700. --ya-start-command-file -m ${pre=D=:MAVEN_EXPORT_COORDS_GLOBAL} ${pre=E=:EXCLUDED_MAVEN_EXPORT_COORDS_GLOBAL} --ya-end-command-file \
  701. ${hide:APPLIED_EXCLUDES}
  702. MAVEN_EXPORT_GEN_POM=${hide;kv:"mvn_export yes"} \
  703. $YMAKE_PYTHON ${input:"build/scripts/generate_pom.py"} \
  704. --from-coord-files \
  705. --vcs-info $(VCS)/vcs.json \
  706. --target-path $MODDIR \
  707. $MAVEN_EXPORT_SOURCE_DIRS \
  708. $MAVEN_EXPORT_DEPS_COORS \
  709. $MAVEN_EXPORT_OUT_DIR_FLAG \
  710. --target-coords ${suf=.mvn_coords:TARGET} \
  711. --pom-path ${output:"pom.xml"}
  712. MAVEN_DEPLOY_CMD=$YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} $MAVEN_BIN \
  713. deploy:deploy-file -DpomFile=$BINDIR/pom.xml \
  714. -Dfile=$TARGET -DrepositoryId=$MAVEN_REPO_ID -Durl=$MAVEN_REPO_URL -Djava.net.preferIPv4Addresses=false -Djava.net.preferIPv6Addresses=true \
  715. ${MAVEN_DEPLOY_SOURCES} \
  716. $_ADD_OPTS_IF_NON_EMPTY(-gs $MAVEN_EXPORT_SETTINGS) \
  717. $_ADD_OPTS_IF_NON_EMPTY(-s $MAVEN_EXPORT_SETTINGS)
  718. MAVEN_EXPORT_CMD=
  719. # tag:java-specific
  720. JAVA_COVERAGE_SRCLIST_FLAG=--coverage ${output;pre=${MODULE_PREFIX};suf=.cpsf:REALPRJNAME} --source-root ${ARCADIA_ROOT}
  721. JAVA_COVERAGE_SRCLIST=
  722. PREPARE_JAVA_BUILD_DIRS=$FS_TOOLS md ${BINDIR}/cls && $FS_TOOLS md ${BINDIR}/misc
  723. EXTRACT_GENDIRS=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --unpack --ext .gentar ${ext=.gentar:AUTO_INPUT}
  724. COLLECT_JAVA_SRCLIST=${YMAKE_PYTHON} ${input:"build/scripts/make_java_srclists.py"} ${hide;input:"build/scripts/process_command_files.py"} ${hide;input:"build/scripts/java_pack_to_file.py"} --moddir ${CURDIR} --java ${BINDIR}/all-java.srclst ${KT_SRSCLIST} ${JAVA_COVERAGE_SRCLIST} --ya-start-command-file ${ALL_JAR_SOURCES} ${ext=.java:AUTO_INPUT} ${ext=.kt:AUTO_INPUT} --ya-end-command-file
  725. COLLECT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/bfg.txt -m --ya-start-command-file ${rootrel:MANAGED_PEERS_CLOSURE} $KT_CLASSPATH_ITEM --ya-end-command-file
  726. LINK_CLASSPATH=${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/bfg.txt ${ARCADIA_BUILD_ROOT}/bfg.jar
  727. COMPILE_JAVA_SRCLIST=$_JAVAC_RUN_HELPER($JAVAC_CMD)
  728. PACK_JAR=$_PACK_JAR_HELPER($TARGET)
  729. # NOTE: No && before LINK_JAR_RESOURCES, ALL_KT_COMMANDS and JAR_GEN_SRCS needed since those vars either empty or starts with &&
  730. LINK_JAR=${hide:JAVA_FAKEID} ${hide;kv:"p JV"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"} ${requirements;hide:"cpu:2"} \
  731. $PREPARE_JAVA_BUILD_DIRS \
  732. && $EXTRACT_GENDIRS \
  733. && $COLLECT_JAVA_SRCLIST \
  734. $JAR_GEN_SRCS \
  735. $ALL_KT_COMMANDS \
  736. && $COLLECT_CLASSPATH \
  737. && $LINK_CLASSPATH \
  738. && $COMPILE_JAVA_SRCLIST \
  739. $LINK_JAR_RESOURCES \
  740. && ${cwd;suf=/cls:BINDIR} $GENERATE_VCS_JAVA_INFO_NODEP . \
  741. $_PACK_SRC_JAR \
  742. $_PACK_JNI \
  743. && $PACK_JAR \
  744. $_DO_JAVA_YNDEXING \
  745. $_MAKE_JSTYLE_FILE_LIST \
  746. $_LINK_UBERJAR \
  747. $MAVEN_EXPORT_CMD \
  748. $_ADD_HIDDEN_INPUTS($JAVA_EXTERNAL_DEPENDENCIES_VALUE)
  749. # tag:java-specific
  750. _EXT_SRC_JAR=
  751. _EXT_JAR=
  752. _COPY_EXT_SRC_JAR= && $FS_TOOLS md ${BINDIR}/empty && ${cwd;suf=/empty:BINDIR} $JDK_RESOURCE/bin/jar cfvM ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} .
  753. _DO_USE_EXT_JAR=${hide:JAVA_FAKEID} $FS_TOOLS copy ${input:_EXT_JAR} $TARGET $_COPY_EXT_SRC_JAR $MAVEN_EXPORT_CMD
  754. _DO_COPY_EXT_SRC_JAR= && $FS_TOOLS copy $_EXT_SRC_JAR ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME}
  755. macro JAVA_RESOURCE(JAR, SOURCES="") {
  756. SET(_EXT_SRC_JAR $SOURCES)
  757. SET(_EXT_JAR $JAR)
  758. }
  759. # tag:java-specific tag:fbs
  760. JAVA_FLATBUFFERS_VERSION = 24.3.25
  761. _KOTLIN_ALLOWED_VERSIONS = contrib/java/org/jetbrains/kotlin/kotlin-allopen/${_KOTLIN_VERSION} \
  762. contrib/java/org/jetbrains/kotlin/kotlin-allopen-compiler-plugin/${_KOTLIN_VERSION} \
  763. contrib/java/org/jetbrains/kotlin/kotlin-annotation-processing/${_KOTLIN_VERSION} \
  764. contrib/java/org/jetbrains/kotlin/kotlin-compiler/${_KOTLIN_VERSION} \
  765. contrib/java/org/jetbrains/kotlin/kotlin-compiler-embeddable/${_KOTLIN_VERSION} \
  766. contrib/java/org/jetbrains/kotlin/kotlin-daemon-client/${_KOTLIN_VERSION} \
  767. contrib/java/org/jetbrains/kotlin/kotlin-daemon-embeddable/${_KOTLIN_VERSION} \
  768. contrib/java/org/jetbrains/kotlin/kotlin-gradle-plugin-api/${_KOTLIN_VERSION} \
  769. contrib/java/org/jetbrains/kotlin/kotlin-gradle-plugin-model/${_KOTLIN_VERSION} \
  770. contrib/java/org/jetbrains/kotlin/kotlin-lombok-compiler-plugin/${_KOTLIN_VERSION} \
  771. contrib/java/org/jetbrains/kotlin/kotlin-main-kts/${_KOTLIN_VERSION} \
  772. contrib/java/org/jetbrains/kotlin/kotlin-maven-allopen/${_KOTLIN_VERSION} \
  773. contrib/java/org/jetbrains/kotlin/kotlin-maven-lombok/${_KOTLIN_VERSION} \
  774. contrib/java/org/jetbrains/kotlin/kotlin-maven-noarg/${_KOTLIN_VERSION} \
  775. contrib/java/org/jetbrains/kotlin/kotlin-maven-serialization/${_KOTLIN_VERSION} \
  776. contrib/java/org/jetbrains/kotlin/kotlin-noarg-compiler-plugin/${_KOTLIN_VERSION} \
  777. contrib/java/org/jetbrains/kotlin/kotlin-osgi-bundle/${_KOTLIN_VERSION} \
  778. contrib/java/org/jetbrains/kotlin/kotlin-reflect/${_KOTLIN_VERSION} \
  779. contrib/java/org/jetbrains/kotlin/kotlin-scripting-common/${_KOTLIN_VERSION} \
  780. contrib/java/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/${_KOTLIN_VERSION} \
  781. contrib/java/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/${_KOTLIN_VERSION} \
  782. contrib/java/org/jetbrains/kotlin/kotlin-scripting-ide-services/${_KOTLIN_VERSION} \
  783. contrib/java/org/jetbrains/kotlin/kotlin-scripting-jsr223/${_KOTLIN_VERSION} \
  784. contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm/${_KOTLIN_VERSION} \
  785. contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm-host/${_KOTLIN_VERSION} \
  786. contrib/java/org/jetbrains/kotlin/kotlin-script-runtime/${_KOTLIN_VERSION} \
  787. contrib/java/org/jetbrains/kotlin/kotlin-script-util/${_KOTLIN_VERSION} \
  788. contrib/java/org/jetbrains/kotlin/kotlin-serialization-compiler-plugin/${_KOTLIN_VERSION} \
  789. contrib/java/org/jetbrains/kotlin/kotlin-stdlib/${_KOTLIN_VERSION} \
  790. contrib/java/org/jetbrains/kotlin/kotlin-stdlib-common/${_KOTLIN_VERSION} \
  791. contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk7/${_KOTLIN_VERSION} \
  792. contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${_KOTLIN_VERSION} \
  793. contrib/java/org/jetbrains/kotlin/kotlin-stdlib-js/${_KOTLIN_VERSION} \
  794. contrib/java/org/jetbrains/kotlin/kotlin-test/${_KOTLIN_VERSION} \
  795. contrib/java/org/jetbrains/kotlin/kotlin-test-annotations-common/${_KOTLIN_VERSION} \
  796. contrib/java/org/jetbrains/kotlin/kotlin-test-common/${_KOTLIN_VERSION} \
  797. contrib/java/org/jetbrains/kotlin/kotlin-test-js/${_KOTLIN_VERSION} \
  798. contrib/java/org/jetbrains/kotlin/kotlin-test-junit/${_KOTLIN_VERSION} \
  799. contrib/java/org/jetbrains/kotlin/kotlin-test-junit5/${_KOTLIN_VERSION} \
  800. contrib/java/org/jetbrains/kotlin/kotlin-test-testng/${_KOTLIN_VERSION}
  801. # tag:java-specific
  802. module _COMPILABLE_JAR_BASE : _JAR_BASE {
  803. _GHOST_PEERDIR($_FORCED_DEPENDENCY_MANAGEMENT_VALUE)
  804. # flatbuffers-java
  805. DEPENDENCY_MANAGEMENT(contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  806. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/flatbuffers/flatbuffers-java EXCEPT contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  807. # protobuf-java
  808. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  809. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java EXCEPT contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  810. # protobuf-javalite
  811. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  812. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-javalite EXCEPT contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  813. # protobuf-java-util
  814. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION})
  815. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java-util EXCEPT contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION})
  816. # protobuf-kotlin
  817. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION})
  818. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-kotlin EXCEPT contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION})
  819. # kotlin
  820. DEPENDENCY_MANAGEMENT($_KOTLIN_ALLOWED_VERSIONS)
  821. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib/${_KOTLIN_VERSION})
  822. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk7 EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk7/${_KOTLIN_VERSION})
  823. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8 EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${_KOTLIN_VERSION})
  824. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib-js EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib-js/${_KOTLIN_VERSION})
  825. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib-common EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib-common/${_KOTLIN_VERSION})
  826. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-reflect EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-reflect/${_KOTLIN_VERSION})
  827. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-osgi-bundle EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-osgi-bundle/${_KOTLIN_VERSION})
  828. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test/${_KOTLIN_VERSION})
  829. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-junit EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-junit/${_KOTLIN_VERSION})
  830. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-junit5 EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-junit5/${_KOTLIN_VERSION})
  831. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-testng EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-testng/${_KOTLIN_VERSION})
  832. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-js EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-js/${_KOTLIN_VERSION})
  833. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-common EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-common/${_KOTLIN_VERSION})
  834. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-annotations-common EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-annotations-common/${_KOTLIN_VERSION})
  835. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-main-kts EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-main-kts/${_KOTLIN_VERSION})
  836. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-script-runtime EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-script-runtime/${_KOTLIN_VERSION})
  837. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-script-util EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-script-util/${_KOTLIN_VERSION})
  838. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-scripting-common EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-scripting-common/${_KOTLIN_VERSION})
  839. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-scripting-jsr223 EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-scripting-jsr223/${_KOTLIN_VERSION})
  840. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm/${_KOTLIN_VERSION})
  841. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm-host EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm-host/${_KOTLIN_VERSION})
  842. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-scripting-ide-services EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-scripting-ide-services/${_KOTLIN_VERSION})
  843. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-compiler EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-compiler/${_KOTLIN_VERSION})
  844. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-compiler-embeddable EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-compiler-embeddable/${_KOTLIN_VERSION})
  845. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-daemon-client EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-daemon-client/${_KOTLIN_VERSION})
  846. }
  847. _JAR_MAIN_CLASS=
  848. macro JAR_MAIN_CLASS(Class) {
  849. SET(_JAR_MAIN_CLASS ${Class})
  850. }
  851. _JAR_MAIN_SEM=
  852. _ADD_JAR_MAIN_SEM= && app_main_class ${_JAR_MAIN_CLASS}
  853. GRADLE_EXPORT_PUBLISHING=no
  854. _GRADLE_EXPORT_PUBLISHING_SEM=
  855. PUBLISH_MAVEN_VERSION=no
  856. _DO_GRADLE_EXPORT_PUBLISHING_SEM= \
  857. && publish \
  858. && publish_group $MAVEN_EXPORT_GROUP_ID \
  859. && publish_version $PUBLISH_MAVEN_VERSION
  860. BUILD_JAR_SEM= \
  861. ${hide:TARGET} ${hide:AUTO_INPUT} ${hide:APPLIED_EXCLUDES} \
  862. jar $MODDIR $REALPRJNAME \
  863. && consumer-classpath $EXPORT_GRADLE_CLASSPATH \
  864. && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
  865. && consumer-type library \
  866. $_JAVAC_SEM \
  867. $_KOTLIN_SEM \
  868. $_JAR_MAIN_SEM \
  869. $_GRADLE_EXPORT_PUBLISHING_SEM \
  870. $_ANN_PROCESSORS_SEM \
  871. $_USE_ANNOTATION_PROCESSOR_SEM \
  872. $_ENABLE_PREVIEW_SEM \
  873. $SEM_JAR_SOURCE_SET
  874. BUILD_PROTO_JAR_SEM= \
  875. ${hide:target} ${hide:AUTO_INPUT} \
  876. jar_proto $MODDIR $REALPRJNAME \
  877. $_JAVA_PROTO_SEM \
  878. && consumer-classpath $EXPORT_GRADLE_CLASSPATH \
  879. && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
  880. && consumer-type library \
  881. $_JAVAC_SEM \
  882. $_ANN_PROCESSORS_SEM \
  883. $_USE_ANNOTATION_PROCESSOR_SEM \
  884. $_ENABLE_PREVIEW_SEM \
  885. $_KOTLIN_SEM
  886. # tag:java-specific tag:internal
  887. ### @usage: JAR_LIBRARY() #internal
  888. ###
  889. ### Reimplementation of the JAVA_LIBRARY with ymake.core.conf and ymake based dependency management
  890. module JAR_LIBRARY: _COMPILABLE_JAR_BASE {
  891. .EXTS=.jsrc .java .jar .mf .gentar .kt
  892. .CMD=LINK_JAR
  893. .SEM=BUILD_JAR_SEM
  894. .FINAL_TARGET=yes
  895. .ALIASES=JAVA_SRCS=FULL_JAVA_SRCS ANNOTATION_PROCESSOR=JAR_ANNOTATION_PROCESSOR
  896. .RESTRICTED=EXTERNAL_JAR
  897. .GLOBAL=MAVEN_EXPORT_COORDS
  898. MODULE_SUFFIX=.jar
  899. PEERDIR(build/platform/java/jdk)
  900. PEERDIR+=$JDK_RESOURCE_PEERDIR
  901. when ($_EXT_SRC_JAR) {
  902. _COPY_EXT_SRC_JAR=_DO_COPY_EXT_SRC_JAR
  903. }
  904. when ($_EXT_JAR) {
  905. LINK_JAR=$_DO_USE_EXT_JAR
  906. }
  907. when ($OPENSOURCE_EXPORT == "no") {
  908. BUILD_JAR_SEM=IGNORED
  909. }
  910. when ($_JAR_MAIN_CLASS) {
  911. _JAR_MAIN_SEM=$_ADD_JAR_MAIN_SEM
  912. }
  913. when ($GRADLE_EXPORT_PUBLISHING == "yes") {
  914. _GRADLE_EXPORT_PUBLISHING_SEM=$_DO_GRADLE_EXPORT_PUBLISHING_SEM
  915. }
  916. # in the ideal world this statement must be under condition bellow
  917. DEPENDENCY_MANAGEMENT(contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${_KOTLIN_VERSION})
  918. when ($WITH_KOTLIN_VALUE) {
  919. KT_SRSCLIST=$KT_SRSCLIST_FLAG
  920. _MAKE_LINT_KT_FILES_LIST = $YMAKE_PYTHON ${input:"build/scripts/kt_copy.py"} $KT_SRCLIST ${noauto;output:"all-kt-sources.txt"} $(SOURCE_ROOT) $(BUILD_ROOT)
  921. ALL_KT_COMMANDS=&& $COLLECT_KT_CLASSPATH && $LINK_KT_CLASSPATH
  922. when ($WITH_KAPT_VALUE == "yes") {
  923. # For Kapt usage see: https://kotlinlang.org/docs/kapt.html#using-in-cli
  924. # See for kapt.kotlin.generated: https://github.com/JetBrains/kotlin/blob/master/plugins/kapt3/kapt3-cli/testData/integration/kotlinFileGeneration/build.txt
  925. _KAPT_OPTS=-Xplugin=${tool:"contrib/java/org/jetbrains/kotlin/kotlin-annotation-processing/1.9.24"} $KT_KAPT_PLUGIN_OPTS
  926. _RUN_KAPT=${YMAKE_PYTHON} ${input:"build/scripts/with_kapt_args.py"} ${pre=--ap-classpath :KT_KAPT_AP_CLASSPATH} -- $COMPILE_KT $_KAPT_OPTS
  927. _APPEND_KAPT_GENERATED_SRCS=$YMAKE_PYTHON ${input:"build/scripts/resolve_java_srcs.py"} -d $KT_KAPT_SOURCES_DIR --include-patterns '**/*.java' '**/*.kt' --resolve-kotlin --append -s ${BINDIR}/all-java.srclst -k $KT_SRCLIST -r ${BINDIR}/not-used.txt
  928. ALL_KT_COMMANDS+=&& $_RUN_KAPT && $_APPEND_KAPT_GENERATED_SRCS
  929. }
  930. ALL_KT_COMMANDS+=&& $COMPILE_KT && $_MAKE_LINT_KT_FILES_LIST
  931. LINK_JAR_RESOURCES+=&& $FS_TOOLS copy_all_files ${KT_CLASSES_DIR} ${BINDIR}/cls
  932. PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8
  933. when($WITH_KOTLINC_PLUGIN_ALLOPEN) {
  934. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-allopen-plugin.jar
  935. }
  936. when($WITH_KOTLINC_PLUGIN_LOMBOK) {
  937. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-lombok-plugin.jar
  938. }
  939. when($WITH_KOTLINC_PLUGIN_NOARG) {
  940. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-noarg-plugin.jar
  941. }
  942. when($WITH_KOTLINC_PLUGIN_SERIALIZATION) {
  943. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-serialization-plugin.jar
  944. }
  945. when($WITH_KOTLINC_PLUGIN_DETEKT) {
  946. KOTLINC_OPTS_VALUE+=-Xplugin=${tool:"devtools/detekt-compiler-plugin"}
  947. KOTLINC_OPTS_VALUE+=-P plugin:detekt-compiler-plugin:report=xml:${BINDIR}/misc/detekt-report.xml
  948. # If there are no kt sources, the report won't be generated, however the file must be always present.
  949. ALL_KT_COMMANDS+=&& $YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${BINDIR}/misc/detekt-report.xml
  950. ALL_KT_COMMANDS+=&& $FS_TOOLS copy ${BINDIR}/misc/detekt-report.xml ${noauto;output:"detekt-report.xml"}
  951. }
  952. # Must be in sync with KT_CLASSES_DIR!
  953. # There are problems in JDK13 with abs paths in classpath baked into jar file manifest. Using relative path
  954. # here assumes that jar file with classpath for javac located in the $ARCADIA_BUILD_ROOT
  955. KT_CLASSPATH_ITEM=$MODDIR/kt_cls
  956. }
  957. otherwise {
  958. KT_SRSCLIST=
  959. ALL_KT_COMMANDS=
  960. KT_CLASSES=
  961. }
  962. when ($MAVEN_EXPORT == "yes") {
  963. when ($MAVEN_DEPLOY == "yes") {
  964. PEERDIR+=build/external_resources/maven
  965. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM && $MAVEN_DEPLOY_CMD
  966. }
  967. otherwise {
  968. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM
  969. }
  970. MAVEN_EXPORT_COORDS_GLOBAL=$MAVEN_EXPORT_GROUP_ID:${MODULE_PREFIX}${REALPRJNAME}:${MAVEN_EXPORT_VERSION}:
  971. }
  972. when ($SOURCES_JAR == "yes") {
  973. _PACK_SRC_JAR=$_PACK_SRC_JAR_IMPL
  974. MAVEN_DEPLOY_SOURCES=-Dsources=${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME}
  975. }
  976. when ($JAVA_COVERAGE == "yes") {
  977. JAVA_COVERAGE_SRCLIST=$JAVA_COVERAGE_SRCLIST_FLAG
  978. }
  979. when ($MAKE_UBERJAR_VALUE == "yes") {
  980. _LINK_UBERJAR=$_DO_LINK_UBERJAR
  981. PACK_JAR=$_PACK_JAR_HELPER(${BINDIR}/${REALPRJNAME}.lib.jar)
  982. # TODO: This condition is incorrect in case of autoinputs _UBERJAR_SELF should be empty only for
  983. # modules without AUTO_INPUT and without JAVA_SRCS added inputs.
  984. when($ALL_JAR_SOURCES) {
  985. _UBERJAR_SELF=--jar ${BINDIR}/${REALPRJNAME}.lib.jar
  986. }
  987. PEERDIR+=build/platform/java/uberjar
  988. PEERDIR+=$UBERJAR_RESOURCE_PEERDIR
  989. }
  990. when($JAVA_YNDEXING == "yes") {
  991. PEERDIR+=build/platform/java/kythe
  992. _DO_JAVA_YNDEXING=&& $_JAVAC_RUN_HELPER($_JAVA_YNDEXING_CMD) && ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} kindex.tar .kzip ${hide;output;tared:"kindex.tar"}
  993. }
  994. when($ERROR_PRONE_VALUE) {
  995. PEERDIR+=$ERROR_PRONE_PEERDIR
  996. RUN_JAVAC_ARGS=--error-prone $ERROR_PRONE_RESOURCE/error_prone.jar
  997. }
  998. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "17") {
  999. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1000. JAVAC_OPTS+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1001. }
  1002. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "20") {
  1003. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1004. JAVAC_OPTS+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1005. }
  1006. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "21") {
  1007. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1008. JAVAC_OPTS+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1009. }
  1010. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "22") {
  1011. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1012. JAVAC_OPTS+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1013. }
  1014. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "23") {
  1015. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1016. JAVAC_OPTS+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1017. }
  1018. when($ERROR_PRONE_VALUE && $ERROR_PRONE_VERSION == "2.7.1") {
  1019. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_2_7_1_FORCED_OPTS
  1020. JAVAC_OPTS+=$ERROR_PRONE_2_7_1_FORCED_OPTS
  1021. }
  1022. when ($JAVA_ADD_DLLS_VALUE == "yes") {
  1023. CONSUME_NON_MANAGEABLE_PEERS=yes
  1024. _PACK_JNI=$_PACK_JNI_CMD
  1025. }
  1026. when ($LINT_LEVEL_VALUE != "none") {
  1027. _MAKE_JSTYLE_FILE_LIST= && ${WRITER_PY} --file ${noauto;output:"lint-java.srclst"} -m --ya-start-command-file $LINT_JAVA_SOURCES --ya-end-command-file
  1028. }
  1029. SET(MODULE_TYPE JAVA_LIBRARY)
  1030. _ADD_KOTLIN_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/all-kt-sources.txt REQUIREMENTS cpu:2)
  1031. _ADD_JAVA_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/lint-java.srclst::$(SOURCE_ROOT))
  1032. _ADD_DETEKT_REPORT_CHECK($(BUILD_ROOT)/$MODDIR/detekt-report.xml)
  1033. _ADD_CLASSPATH_CLASH_CHECK()
  1034. JAVA_MODULE()
  1035. }
  1036. # tag:java-specific
  1037. _SCRIPTGEN_FLAGS=
  1038. macro _GEN_JAVA_SCRIPT_IMPL(Out, Template, Props...) {
  1039. .CMD=$SCRIPTGEN_RESOURCE_GLOBAL/scriptgen --java $JDK_RESOURCE/bin/java --output ${output:Out} --template ${input:Template} ${_SCRIPTGEN_FLAGS} -D JAR_NAME=${REALPRJNAME}.jar -D CLASSPATH=${nopath;join;ext=.jar;pre="::":MANAGED_PEERS_CLOSURE} -D PROJECT_DIR=${MODDIR} -D JAR_BASENAME=${REALPRJNAME} $Props
  1040. }
  1041. # tag:java-specific
  1042. _GEN_USERSCRIPTS=
  1043. macro _ADD_GEN_JAVA_SCRIPT(Out, Template, Props...) {
  1044. SET_APPEND(_GEN_USERSCRIPTS && \$_GEN_JAVA_SCRIPT_IMPL($Out $Template $Props))
  1045. }
  1046. # tag:java-specific
  1047. _PACK_JDK=
  1048. # tag:java-specific
  1049. DO_GEN_JAVA_RUN_SH=
  1050. _SOURCE_JARS=
  1051. _SOURCE_JARS_CPLIST=
  1052. _GEN_JAVA_RUN_SH_OUTPUT=run.sh
  1053. when ($HOST_OS_WINDOWS == "yes") {
  1054. _GEN_JAVA_RUN_SH_OUTPUT=run.bat
  1055. }
  1056. GEN_JAVA_RUN_SH=$SCRIPTGEN_RESOURCE_GLOBAL/scriptgen --java $JDK_RESOURCE/bin/java --output ${output:_GEN_JAVA_RUN_SH_OUTPUT} -D GENERATE_DEFAULT_RUNNER=yes -D JAR_NAME=${REALPRJNAME}.jar -D CLASSPATH=${nopath;join;pre="::":MANAGED_PEERS_CLOSURE} -D PROJECT_DIR=${REALPRJNAME} -D JAR_BASENAME=${REALPRJNAME}
  1057. GEN_RUN_CP=${WRITER_PY} --file ${BINDIR}/run-bf.txt -Q -m --ya-start-command-file ${nopath;qe;pre=$REALPRJNAME/:MANAGED_PEERS_CLOSURE} --ya-end-command-file && ${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/run-bf.txt ${TARGET}
  1058. COLLECT_JAR_PROGRAM_CP=$FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS} --ya-end-command-file ${BINDIR}/${REALPRJNAME} ${hide;late_out;nopath;ext=.jar;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE}
  1059. MAKE_JAR_PROGRAM_CPLST=${MAKE_JAVA_CLASSPATH_FILE} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} --ya-start-command-file ${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS_CPLIST} --ya-end-command-file
  1060. TAR_CLASSPATH= && $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} ${output;pre=$MODULE_PREFIX;suf=.tar:REALPRJNAME} ${cwd;pre=$BINDIR/:REALPRJNAME}
  1061. DO_TAR_CLASSPATH=
  1062. LINK_JAR_PROGRAM=${hide:JAVA_FAKEID} $FS_TOOLS md ${BINDIR}/${REALPRJNAME} && $COLLECT_JAR_PROGRAM_CP && $DO_GEN_JAVA_RUN_SH && $GEN_RUN_CP && $MAKE_JAR_PROGRAM_CPLST $DO_TAR_CLASSPATH $_GEN_USERSCRIPTS $_PACK_JDK ${hide;kv:"p JP"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}
  1063. # tag:java-specific
  1064. # UBERJAR program link command
  1065. LINK_UBERJAR_PROGRAM=${hide:JAVA_FAKEID} ${hide;kv:"p UJ"} ${MAKE_JAVA_CLASSPATH_FILE} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} $TARGET \
  1066. && $FS_TOOLS md ${BINDIR}/${REALPRJNAME} \
  1067. && $FS_TOOLS link_or_copy ${BINDIR}/${REALPRJNAME}.jar $TARGET \
  1068. && $FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${BINDIR}/${REALPRJNAME}.jar ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS} --ya-end-command-file ${BINDIR}/${REALPRJNAME} ${hide;output;ext=.jar;pre=$BINDIR/$REALPRJNAME/:REALPRJNAME} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} \
  1069. $DO_TAR_CLASSPATH \
  1070. $_GEN_USERSCRIPTS \
  1071. $_PACK_JDK
  1072. # tag:java-specific
  1073. RUN_WITH_SOURCES=no
  1074. # TODO jbuild creates tar with all classpath deps by default and some projects rely on this. In ymake build this tar file creation is not needed and should be disabled by default in future
  1075. TARED_CLASSPATH=yes
  1076. _JAR_SRCS_CALLED=no
  1077. # tag:java-specific
  1078. macro _MARK_JAVA_PROG_WITH_SOURCES(Args...) {
  1079. ENABLE(_JAR_SRCS_CALLED)
  1080. }
  1081. # tag:java-specific
  1082. module _JAR_RUNNABLE: _COMPILABLE_JAR_BASE {
  1083. .FINAL_TARGET=yes
  1084. .CMD=LINK_JAR_PROGRAM
  1085. .SEM=IGNORED
  1086. .ALIASES=JAVA_SRCS=_MARK_JAVA_PROG_WITH_SOURCES GENERATE_SCRIPT=_YMAKE_GENERATE_SCRIPT
  1087. .ALLOWED=WITH_JDK
  1088. .PEERDIR_POLICY=as_build_from
  1089. MODULE_SUFFIX=.run.cp.jar
  1090. CONSUME_NON_MANAGEABLE_PEERS=yes
  1091. when ($RUN_WITH_SOURCES == "yes") {
  1092. _SOURCE_JARS=${ext=.jar;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE} ${hide;late_out;ext=.jar;nopath;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE}
  1093. _SOURCE_JARS_CPLIST=${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE}
  1094. }
  1095. when ($TARED_CLASSPATH == "yes") {
  1096. DO_TAR_CLASSPATH=$TAR_CLASSPATH
  1097. }
  1098. when ($DISABLE_SCRIPTGEN) {
  1099. DO_GEN_JAVA_RUN_SH=
  1100. }
  1101. otherwise {
  1102. DO_GEN_JAVA_RUN_SH=$GEN_JAVA_RUN_SH
  1103. PEERDIR+=build/platform/java/scriptgen
  1104. }
  1105. when ($MAKE_UBERJAR_VALUE == "yes") {
  1106. LINK_JAR_PROGRAM=$LINK_UBERJAR_PROGRAM
  1107. DYNAMIC_LINK=no
  1108. _SCRIPTGEN_FLAGS=-D IS_UBERJAR=yes
  1109. }
  1110. otherwise {
  1111. _SCRIPTGEN_FLAGS=-D IS_UBERJAR=no
  1112. }
  1113. CHECK_PROVIDES()
  1114. }
  1115. # tag:java-specific
  1116. LINK_JAR_TEST=${hide:JAVA_FAKEID} ${WRITER_PY} --file ${BINDIR}/run-bf.txt -Q -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file && ${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/run-bf.txt ${TARGET} ${hide;kv:"p JT"}
  1117. module _JAR_TEST: _COMPILABLE_JAR_BASE {
  1118. .FINAL_TARGET=yes
  1119. .CMD=LINK_JAR_TEST
  1120. .DEFAULT_NAME_GENERATOR=FullPath
  1121. CONSUME_NON_MANAGEABLE_PEERS=yes
  1122. SET(MODULE_SUFFIX .test.cp.jar)
  1123. JAVA_TEST()
  1124. CHECK_PROVIDES()
  1125. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1126. }
  1127. # tag:java-specific
  1128. JAVA_SWIG_DELIM=JAVA_SWIG_DELIM
  1129. # tag:java-specific
  1130. JDK_REAL_VERSION=
  1131. JDK_VERSION=
  1132. when ($JDK_VERSION == "23") {
  1133. JDK_REAL_VERSION=23
  1134. }
  1135. elsewhen ($JDK_VERSION == "22") {
  1136. JDK_REAL_VERSION=22
  1137. }
  1138. elsewhen ($JDK_VERSION == "21") {
  1139. JDK_REAL_VERSION=21
  1140. }
  1141. elsewhen ($JDK_VERSION == "20") {
  1142. JDK_REAL_VERSION=20
  1143. }
  1144. elsewhen ($JDK_VERSION == "17") {
  1145. JDK_REAL_VERSION=17
  1146. }
  1147. elsewhen ($JDK_VERSION == "11") {
  1148. JDK_REAL_VERSION=11
  1149. }
  1150. elsewhen ($MAPSMOBI_BUILD_TARGET && $OS_ANDROID) {
  1151. JDK_REAL_VERSION=11
  1152. }
  1153. otherwise {
  1154. JDK_REAL_VERSION=17
  1155. }
  1156. # tag:java-specific
  1157. # remove extra peerdir to jdk11 after https://st.yandex-team.ru/DEVTOOLS-8851 is done
  1158. when ($USE_SYSTEM_JDK) {
  1159. JDK_RESOURCE_PEERDIR=
  1160. }
  1161. otherwise {
  1162. when ($JDK_REAL_VERSION == "23") {
  1163. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk23 build/platform/java/jdk/jdk17
  1164. }
  1165. when ($JDK_REAL_VERSION == "22") {
  1166. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk22 build/platform/java/jdk/jdk17
  1167. }
  1168. when ($JDK_REAL_VERSION == "21") {
  1169. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk21 build/platform/java/jdk/jdk17
  1170. }
  1171. when ($JDK_REAL_VERSION == "20") {
  1172. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk20 build/platform/java/jdk/jdk17
  1173. }
  1174. when ($JDK_REAL_VERSION == "17") {
  1175. # need jdk11 for spare parts in "host" platform
  1176. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk17 build/platform/java/jdk/jdk11
  1177. }
  1178. when ($JDK_REAL_VERSION == "11") {
  1179. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk11 build/platform/java/jdk/jdk17
  1180. }
  1181. }
  1182. # tag:java-specific
  1183. when ($JDK_REAL_VERSION == "23") {
  1184. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar23
  1185. }
  1186. when ($JDK_REAL_VERSION == "22") {
  1187. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar22
  1188. }
  1189. when ($JDK_REAL_VERSION == "21") {
  1190. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar21
  1191. }
  1192. when ($JDK_REAL_VERSION == "20") {
  1193. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar20
  1194. }
  1195. when ($JDK_REAL_VERSION == "17") {
  1196. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar17
  1197. }
  1198. when ($JDK_REAL_VERSION == "11") {
  1199. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar11
  1200. }
  1201. # tag:java-specific
  1202. JAVAC_OPTS=
  1203. when ($USE_SYSTEM_JDK) {
  1204. JDK_RESOURCE=$USE_SYSTEM_JDK
  1205. }
  1206. otherwise {
  1207. when ($JDK_REAL_VERSION == "23") {
  1208. JDK_RESOURCE=$JDK23_RESOURCE_GLOBAL
  1209. }
  1210. when ($JDK_REAL_VERSION == "22") {
  1211. JDK_RESOURCE=$JDK22_RESOURCE_GLOBAL
  1212. }
  1213. when ($JDK_REAL_VERSION == "21") {
  1214. JDK_RESOURCE=$JDK21_RESOURCE_GLOBAL
  1215. }
  1216. when ($JDK_REAL_VERSION == "20") {
  1217. JDK_RESOURCE=$JDK20_RESOURCE_GLOBAL
  1218. }
  1219. when ($JDK_REAL_VERSION == "17") {
  1220. JDK_RESOURCE=$JDK17_RESOURCE_GLOBAL
  1221. }
  1222. when ($JDK_REAL_VERSION == "11") {
  1223. JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL
  1224. }
  1225. }
  1226. # tag:java-specific
  1227. when (!$USE_SYSTEM_ERROR_PRONE) {
  1228. # Still not done: DTCC-667
  1229. when ($JDK_REAL_VERSION == "11") {
  1230. ERROR_PRONE_VERSION=2.7.1
  1231. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.7.1
  1232. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_7_1_RESOURCE_GLOBAL
  1233. }
  1234. elsewhen ($JDK_REAL_VERSION == "17") {
  1235. ERROR_PRONE_VERSION=2.10.0
  1236. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.10.0
  1237. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_10_0_RESOURCE_GLOBAL
  1238. }
  1239. elsewhen ($JDK_REAL_VERSION == "20") {
  1240. ERROR_PRONE_VERSION=2.18.0
  1241. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.18.0
  1242. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_18_0_RESOURCE_GLOBAL
  1243. }
  1244. elsewhen ($JDK_REAL_VERSION == "21") {
  1245. ERROR_PRONE_VERSION=2.30.0
  1246. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.30.0
  1247. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_30_0_RESOURCE_GLOBAL
  1248. }
  1249. elsewhen ($JDK_REAL_VERSION == "22") {
  1250. ERROR_PRONE_VERSION=2.30.0
  1251. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.30.0
  1252. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_30_0_RESOURCE_GLOBAL
  1253. }
  1254. elsewhen ($JDK_REAL_VERSION == "23") {
  1255. ERROR_PRONE_VERSION=2.30.0
  1256. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.30.0
  1257. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_30_0_RESOURCE_GLOBAL
  1258. }
  1259. otherwise {
  1260. ERROR_PRONE_VERSION=2.7.1
  1261. ERROR_PRONE_PEERDIR=build/platform/java/error_prone
  1262. ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL
  1263. }
  1264. }
  1265. otherwise {
  1266. ERROR_PRONE_VERSION=2.7.1
  1267. ERROR_PRONE_PEERDIR=build/platform/java/error_prone
  1268. ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL
  1269. }
  1270. # tag:java-specific
  1271. when ($USE_SYSTEM_UBERJAR) {
  1272. UBERJAR_RESOURCE=$USE_SYSTEM_UBERJAR
  1273. }
  1274. otherwise {
  1275. when ($JDK_REAL_VERSION == "23") {
  1276. UBERJAR_RESOURCE=$UBERJAR23_RESOURCE_GLOBAL
  1277. }
  1278. when ($JDK_REAL_VERSION == "22") {
  1279. UBERJAR_RESOURCE=$UBERJAR22_RESOURCE_GLOBAL
  1280. }
  1281. when ($JDK_REAL_VERSION == "21") {
  1282. UBERJAR_RESOURCE=$UBERJAR21_RESOURCE_GLOBAL
  1283. }
  1284. when ($JDK_REAL_VERSION == "20") {
  1285. UBERJAR_RESOURCE=$UBERJAR20_RESOURCE_GLOBAL
  1286. }
  1287. when ($JDK_REAL_VERSION == "17") {
  1288. UBERJAR_RESOURCE=$UBERJAR17_RESOURCE_GLOBAL
  1289. }
  1290. when ($JDK_REAL_VERSION == "11") {
  1291. UBERJAR_RESOURCE=$UBERJAR11_RESOURCE_GLOBAL
  1292. }
  1293. }
  1294. # tag:java-specific
  1295. when ($JDK_REAL_VERSION == "23") {
  1296. WITH_JDK_RESOURCE=$WITH_JDK23_RESOURCE_GLOBAL
  1297. }
  1298. when ($JDK_REAL_VERSION == "22") {
  1299. WITH_JDK_RESOURCE=$WITH_JDK22_RESOURCE_GLOBAL
  1300. }
  1301. when ($JDK_REAL_VERSION == "21") {
  1302. WITH_JDK_RESOURCE=$WITH_JDK21_RESOURCE_GLOBAL
  1303. }
  1304. when ($JDK_REAL_VERSION == "20") {
  1305. WITH_JDK_RESOURCE=$WITH_JDK20_RESOURCE_GLOBAL
  1306. }
  1307. when ($JDK_REAL_VERSION == "17") {
  1308. WITH_JDK_RESOURCE=$WITH_JDK17_RESOURCE_GLOBAL
  1309. }
  1310. when ($JDK_REAL_VERSION == "11") {
  1311. WITH_JDK_RESOURCE=$WITH_JDK11_RESOURCE_GLOBAL
  1312. }
  1313. # tag:java-specific
  1314. EXTERNAL_JAVA_JDK_RESOURCE=
  1315. EXTERNAL_JAVA_EXTRA_PEERDIR=
  1316. when ($USE_SYSTEM_JDK) {
  1317. EXTERNAL_JAVA_EXTRA_PEERDIR=
  1318. EXTERNAL_JAVA_JDK_RESOURCE=$USE_SYSTEM_JDK
  1319. }
  1320. elsewhen ($JDK_VERSION == "") {
  1321. EXTERNAL_JAVA_JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL
  1322. EXTERNAL_JAVA_EXTRA_PEERDIR=build/platform/java/jdk/jdk11
  1323. }
  1324. otherwise {
  1325. EXTERNAL_JAVA_JDK_RESOURCE=$JDK_RESOURCE
  1326. }
  1327. COMPILE_JAVA=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/compile_java.py"} --ya-start-command-file --java-bin $EXTERNAL_JAVA_JDK_RESOURCE/bin/java --javac-bin $EXTERNAL_JAVA_JDK_RESOURCE/bin/javac --jar-bin $JDK_RESOURCE/bin/jar --kotlin-compiler $KOTLIN_COMPILER_RESOURCE_GLOBAL/kotlin-compiler.jar $JAVA_VCS_MF_ARG $PACKAGE_PREFIX_ARGS --jar-output $TARGET --srcs-jar-output ${output;suf=-sources.jar:REALPRJNAME} $AUTO_INPUT DELIM $JAVAC_OPTS DELIM $MANAGED_PEERS_CLOSURE DELIM -no-stdlib -module-name $REALPRJNAME -jvm-target ${KOTLIN_JVM_TARGET} ${KOTLINC_OPTS_VALUE} --ya-end-command-file ${hide;kv:"p JV"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"} ${requirements;hide:"cpu:2"} ${hide;input:"build/scripts/java_command_file.py"} ${hide;input:"build/scripts/process_command_files.py"}
  1328. ARGS_DELIM="MACRO_CALLS_DELIM"
  1329. SYSTEM_PROPERTIES_VALUE=
  1330. ### @usage: SYSTEM_PROPERTIES([<Key Value>...] [<File Path>...])
  1331. ###
  1332. ### List of Key,Value pairs that will be available to test via System.getProperty().
  1333. ### FILE means that parst should be read from file specifies as Path.
  1334. ###
  1335. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  1336. macro SYSTEM_PROPERTIES(Args...) {
  1337. SET_APPEND(SYSTEM_PROPERTIES_VALUE $Args)
  1338. }
  1339. # tag:java-specific
  1340. JVM_ARGS_VALUE=-ea
  1341. ### @usage: JVM_ARGS(Args...)
  1342. ###
  1343. ### Arguments to run Java programs in tests.
  1344. ###
  1345. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  1346. macro JVM_ARGS(Args...) {
  1347. SET_APPEND(JVM_ARGS_VALUE $Args)
  1348. }
  1349. # tag:java-specific
  1350. CHECK_JAVA_DEPS_VALUE=
  1351. ### @usage: CHECK_JAVA_DEPS(<yes|no|strict>)
  1352. ###
  1353. ### Check for different classes with duplicate name in classpath.
  1354. ###
  1355. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  1356. macro CHECK_JAVA_DEPS(Arg) {
  1357. SET(CHECK_JAVA_DEPS_VALUE $Arg)
  1358. }
  1359. ERROR_PRONE_VALUE=
  1360. ### @usage: USE_ERROR_PRONE()
  1361. ###
  1362. ### Use errorprone instead of javac for .java compilation.
  1363. macro USE_ERROR_PRONE() {
  1364. SET(ERROR_PRONE_VALUE yes)
  1365. }
  1366. # tag:java-specific
  1367. MAKE_UBERJAR_VALUE=
  1368. ### @usage: UBERJAR()
  1369. ###
  1370. ### UBERJAR is a single all-in-one jar-archive that includes all its Java dependencies (reachable PEERDIR).
  1371. ### It also supports shading classes inside the archive by moving them to a different package (similar to the maven-shade-plugin).
  1372. ### Use UBERJAR inside JAVA_PROGRAM module.
  1373. ###
  1374. ### You can use the following macros to configure the archive:
  1375. ### 1. UBERJAR_HIDING_PREFIX prefix for classes to shade (classes remain in their packages by default)
  1376. ### 2. UBERJAR_HIDE_INCLUDE_PATTERN include classes matching this patterns to shading, include LDC mapping
  1377. ### 3. UBERJAR_HIDE_EXCLUDE_PATTERN exclude classes matching this patterns from shading (if enabled).
  1378. ### 4. UBERJAR_PATH_EXCLUDE_PREFIX the prefix for classes that should not get into the jar archive (all classes are placed into the archive by default)
  1379. ### 5. UBERJAR_MANIFEST_TRANSFORMER_MAIN add ManifestResourceTransformer class to uberjar processing and specify main-class
  1380. ### 6. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE add ManifestResourceTransformer class to uberjar processing and specify some attribute
  1381. ### 7. UBERJAR_APPENDING_TRANSFORMER add AppendingTransformer class to uberjar processing
  1382. ### 8. UBERJAR_SERVICES_RESOURCE_TRANSFORMER add ServicesResourceTransformer class to uberjar processing
  1383. ###
  1384. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  1385. ###
  1386. ### @see: [JAVA_PROGRAM](#module_JAVA_PROGRAM), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX), [UBERJAR_HIDE_INCLUDE_PATTERN](#macro_UBERJAR_HIDE_INCLUDE_PATTERN) [UBERJAR_HIDE_EXCLUDE_PATTERN](#macro_UBERJAR_HIDE_EXCLUDE_PATTERN), [UBERJAR_PATH_EXCLUDE_PREFIX](#macro_UBERJAR_PATH_EXCLUDE_PREFIX)
  1387. macro UBERJAR() {
  1388. SET(MAKE_UBERJAR_VALUE yes)
  1389. DISABLE(PASS_PEERS)
  1390. }
  1391. # tag:java-specific
  1392. UBERJAR_PREFIX_VALUE=
  1393. UBERJAR_PREFIX_FLAG=
  1394. ### @usage: UBERJAR_HIDING_PREFIX(Arg)
  1395. ###
  1396. ### Set prefix for classes to shade. All classes in UBERJAR will be moved into package prefixed with Arg.
  1397. ### Classes remain in their packages by default.
  1398. ###
  1399. ### @see: [UBERJAR](#macro_UBERJAR)
  1400. macro UBERJAR_HIDING_PREFIX(Arg) {
  1401. SET(UBERJAR_PREFIX_VALUE $Arg)
  1402. SET(UBERJAR_PREFIX_FLAG ${pre=--shade-prefix :Arg})
  1403. }
  1404. # tag:java-specific
  1405. UBERJAR_HIDE_EXCLUDE_VALUE=
  1406. UBERJAR_HIDE_EXCLUDE_FLAGS=
  1407. ### @usage: UBERJAR_HIDE_EXCLUDE_PATTERN(Args...)
  1408. ###
  1409. ### Exclude classes matching this patterns from shading (if enabled).
  1410. ### Pattern may contain '*' and '**' globs.
  1411. ### Shading is enabled for UBERJAR program using UBERJAR_HIDING_PREFIX macro. If this macro is not specified all classes are shaded.
  1412. ###
  1413. ### @see: [UBERJAR](#macro_UBERJAR), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX)
  1414. macro UBERJAR_HIDE_EXCLUDE_PATTERN(Args...) {
  1415. SET_APPEND(UBERJAR_HIDE_EXCLUDE_VALUE $ARGS_DELIM $Args)
  1416. SET_APPEND(UBERJAR_HIDE_EXCLUDE_FLAGS ${pre=--shade-exclude :Args})
  1417. }
  1418. UBERJAR_HIDE_INCLUDE_VALUE=
  1419. UBERJAR_HIDE_INCLUDE_FLAGS=
  1420. ### @usage: UBERJAR_HIDE_INCLUDE_PATTERN(Args...)
  1421. ###
  1422. ### Include classes matching this patterns to shading, enabled LDC processing.
  1423. ### Pattern may contain '*' and '**' globs.
  1424. ### Shading is enabled for UBERJAR program using UBERJAR_HIDING_PREFIX macro. If this macro is not specified all classes are shaded.
  1425. ###
  1426. ### @see: [UBERJAR](#macro_UBERJAR), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX)
  1427. macro UBERJAR_HIDE_INCLUDE_PATTERN(Args...) {
  1428. SET_APPEND(UBERJAR_HIDE_INCLUDE_VALUE $ARGS_DELIM $Args)
  1429. SET_APPEND(UBERJAR_HIDE_INCLUDE_FLAGS ${pre=--shade-include :Args})
  1430. }
  1431. # tag:java-specific
  1432. UBERJAR_PATH_EXCLUDES=
  1433. UBERJAR_PATH_EXCLUDE_VALUE=
  1434. ### @usage: UBERJAR_PATH_EXCLUDE_PREFIX(Args...)
  1435. ###
  1436. ### Exclude classes matching this patterns from UBERJAR.
  1437. ### By default all dependencies of UBERJAR program will lend in a .jar archive.
  1438. ###
  1439. ### @see: [UBERJAR](#macro_UBERJAR)
  1440. macro UBERJAR_PATH_EXCLUDE_PREFIX(Args...) {
  1441. SET_APPEND(UBERJAR_PATH_EXCLUDE_VALUE $ARGS_DELIM $Args)
  1442. SET_APPEND(UBERJAR_PATH_EXCLUDES ${pre=--uber-exclude :Args})
  1443. }
  1444. # tag:java-specific
  1445. UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE=
  1446. UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG=
  1447. ### @usage: UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main)
  1448. ###
  1449. ### Transform manifest.mf for UBERJAR() java programs, set main-class attribute
  1450. ###
  1451. ### @see: [UBERJAR](#macro_UBERJAR)
  1452. macro UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main) {
  1453. SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE $Main)
  1454. SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG --manifest-main $Main)
  1455. }
  1456. # tag:java-specific
  1457. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE=
  1458. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS=
  1459. ### @usage: UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Value)
  1460. ###
  1461. ### Transform manifest.mf for UBERJAR() java programs, set attribute
  1462. ###
  1463. ### @see: [UBERJAR](#macro_UBERJAR)
  1464. macro UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Values...) {
  1465. SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE $ARGS_DELIM $Key : $Values)
  1466. SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS --manifest-attribute ${Key}:'${Values}')
  1467. }
  1468. # tag:java-specific
  1469. UBERJAR_APPENDING_TRANSFORMER_VALUE=
  1470. UBERJAR_APPENDING_TRANSFORMER_FLAGS=
  1471. ### @usage: UBERJAR_APPENDING_TRANSFORMER(Resource)
  1472. ###
  1473. ### Add AppendingTransformer for UBERJAR() java programs
  1474. ###
  1475. ### Parameters:
  1476. ### - Resource - Resource name
  1477. ###
  1478. ### @see: [UBERJAR](#macro_UBERJAR)
  1479. macro UBERJAR_APPENDING_TRANSFORMER(Resources...) {
  1480. SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_VALUE $ARGS_DELIM $Resources)
  1481. SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_FLAGS ${pre=--append-transformer :Resources})
  1482. }
  1483. # tag:java-specific
  1484. UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE=
  1485. UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG=
  1486. ### @usage: UBERJAR_SERVICES_RESOURCE_TRANSFORMER()
  1487. ###
  1488. ### Add ServicesResourceTransformer for UBERJAR() java programs
  1489. ###
  1490. ### @see: [UBERJAR](#macro_UBERJAR)
  1491. macro UBERJAR_SERVICES_RESOURCE_TRANSFORMER() {
  1492. SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE yes)
  1493. SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG --service-transformer)
  1494. }
  1495. # tag:idea-specific
  1496. IDEA_EXCLUDE_DIRS_VALUE=
  1497. ### @usage: IDEA_EXCLUDE_DIRS(<excluded dirs>)
  1498. ###
  1499. ### Exclude specified directories from an idea project generated by ya ide idea
  1500. ### Have no effect on regular build.
  1501. macro IDEA_EXCLUDE_DIRS(Args...) {
  1502. SET_APPEND(IDEA_EXCLUDE_DIRS_VALUE $Args)
  1503. }
  1504. # tag:idea-specific
  1505. IDEA_RESOURCE_DIRS_VALUE=
  1506. ### @usage: IDEA_RESOURCE_DIRS(<additional dirs>)
  1507. ###
  1508. ### Set specified resource directories in an idea project generated by ya ide idea
  1509. ### Have no effect on regular build.
  1510. macro IDEA_RESOURCE_DIRS(Args...) {
  1511. SET_APPEND(IDEA_RESOURCE_DIRS_VALUE $Args)
  1512. }
  1513. # tag:idea-specific
  1514. IDEA_MODULE_NAME_VALUE=
  1515. ### @usage: IDEA_MODULE_NAME(module_name)
  1516. ###
  1517. ### Set module name in an idea project generated by ya ide idea
  1518. ### Have no effect on regular build.
  1519. macro IDEA_MODULE_NAME(Name) {
  1520. SET(IDEA_MODULE_NAME_VALUE $Name)
  1521. }
  1522. # tag:java-specific
  1523. JAVAC_FLAGS_VALUE=
  1524. _JAVAC_SEM=
  1525. ### @usage: JAVAC_FLAGS(Args...)
  1526. ###
  1527. ### Set additional Java compilation flags.
  1528. macro JAVAC_FLAGS(Args...) {
  1529. SET_APPEND(JAVAC_OPTS $Args)
  1530. SET_APPEND(JAVAC_FLAGS_VALUE $ARGS_DELIM $Args)
  1531. SET_APPEND(_JAVAC_SEM && javac-flags $Args)
  1532. }
  1533. # tag:java-specific
  1534. ENABLE_PREVIEW_VALUE=
  1535. _ENABLE_PREVIEW_SEM=
  1536. ### @usage: ENABLE_PREVIEW()
  1537. ###
  1538. ### Enable java preview features.
  1539. macro ENABLE_PREVIEW() {
  1540. SET_APPEND(JVM_ARGS_VALUE --enable-preview)
  1541. SET_APPEND(JAVAC_OPTS --enable-preview --release $JDK_REAL_VERSION)
  1542. SET_APPEND(JAVAC_FLAGS_VALUE --enable-preview --release $JDK_REAL_VERSION)
  1543. SET(ENABLE_PREVIEW_VALUE yes)
  1544. SET(_ENABLE_PREVIEW_SEM && enable_preview)
  1545. }
  1546. # tag:java-specific
  1547. SAVE_JAVAC_GENERATED_SRCS=
  1548. SAVE_JAVAC_GENERATED_SRCS_DIR=
  1549. SAVE_JAVAC_GENERATED_SRCS_TAR=
  1550. when ($SAVE_JAVAC_GENERATED_SRCS) {
  1551. SAVE_JAVAC_GENERATED_SRCS_DIR=${BINDIR}/__javac_generated_srcs__
  1552. SAVE_JAVAC_GENERATED_SRCS_TAR=${BINDIR}/javac_generated.tar
  1553. JAVAC_FLAGS_VALUE+=-s $SAVE_JAVAC_GENERATED_SRCS_DIR
  1554. }
  1555. # tag:java-specific
  1556. MAVEN_EXPORT_GROUP_ID=ru.yandex
  1557. ### @usage: MAVEN_GROUP_ID(group_id_for_maven_export)
  1558. ###
  1559. ### Set maven export group id for JAVA_PROGRAM() and JAVA_LIBRARY().
  1560. ### Have no effect on regular build.
  1561. macro MAVEN_GROUP_ID(Arg, VERSION="no") {
  1562. SET(MAVEN_EXPORT_GROUP_ID $Arg)
  1563. SET(PUBLISH_MAVEN_VERSION $VERSION)
  1564. }
  1565. # tag:java-specific
  1566. ANNOTATION_PROCESSOR_VALUE=
  1567. ### @usage: ANNOTATION_PROCESSOR(processors...)
  1568. ###
  1569. ### The macro is in development.
  1570. ### Used to specify annotation processors to build JAVA_PROGRAM() and JAVA_LIBRARY().
  1571. macro ANNOTATION_PROCESSOR(Args...) {
  1572. SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Args)
  1573. }
  1574. EXCLUDE_VALUE=
  1575. ### EXCLUDE(prefixes)
  1576. ###
  1577. ### Specifies which libraries should be excluded from the classpath.
  1578. macro EXCLUDE(Args...) {
  1579. SET_APPEND(EXCLUDE_VALUE $ARGS_DELIM $Args)
  1580. }
  1581. # tag:java-specific
  1582. JAVA_SRCS_VALUE=
  1583. ### Fill JAVA_SRCS_VALUE for ya ide idea, skip SKIP_CHECK_SRCDIR option
  1584. macro _IDEA_JAVA_SRCS_VALUE(RESOURCES?"RESOURCES":"", SKIP_CHECK_SRCDIR?"SKIP_CHECK_SRCDIR":"", Args...) {
  1585. # RESOURCES must be at first position, else ya ide idea will fault
  1586. SET_APPEND(JAVA_SRCS_VALUE $ARGS_DELIM $RESOURCES $Args)
  1587. }
  1588. ### @usage: JAVA_SRCS(srcs)
  1589. ###
  1590. ### Specify java source files and resources. A macro can be contained in any of four java modules.
  1591. ### Keywords:
  1592. ### 1. SRCDIR x - specify the directory x is performed relatively to search the source code for these patterns. If there is no SRCDIR, the source will be searched relative to the module directory.
  1593. ### 2. PACKAGE_PREFIX x - use if source paths relative to the SRCDIR does not coincide with the full class names. For example, if all sources of module are in the same package, you can create a directory package/name , and just put the source code in the SRCDIR and specify PACKAGE_PREFIX package.name.
  1594. ###
  1595. ### @example:
  1596. ### - example/ya.make
  1597. ###
  1598. ### JAVA_PROGRAM()
  1599. ### JAVA_SRCS(SRCDIR src/main/java **/*)
  1600. ### END()
  1601. ###
  1602. ### - example/src/main/java/ru/yandex/example/HelloWorld.java
  1603. ###
  1604. ### package ru.yandex.example;
  1605. ### public class HelloWorld {
  1606. ### public static void main(String[] args) {
  1607. ### System.out.println("Hello, World!");
  1608. ### }
  1609. ### }
  1610. ###
  1611. ### Documentation: https://wiki.yandex-team.ru/yatool/java/#javasrcs
  1612. macro JAVA_SRCS(Args...) {
  1613. # TODO Use FULL_JAVA_SRCS
  1614. _IDEA_JAVA_SRCS_VALUE($Args)
  1615. # Fill semantic for non-standard sources/resources
  1616. _SEM_JAR_SOURCE_SET($Args)
  1617. }
  1618. # tag:java-specific
  1619. JAVA_ADD_DLLS_VALUE=no
  1620. macro ADD_DLLS_TO_JAR() {
  1621. SET(JAVA_ADD_DLLS_VALUE yes)
  1622. }
  1623. # tag:java-specific
  1624. MANAGED_PEERS=
  1625. MANAGED_PEERS_CLOSURE=
  1626. MANAGEABLE_PEERS_ROOTS=contrib/java
  1627. HAS_MANAGEABLE_PEERS=no
  1628. PROPAGATES_MANAGEABLE_PEERS=no
  1629. # tag:java-specific
  1630. DEPENDENCY_MANAGEMENT_VALUE=
  1631. ### @usage: DEPENDENCY_MANAGEMENT(path/to/lib1 path/to/lib2 ...)
  1632. ###
  1633. ### Lock version of the library from the contrib/java at some point, so that all unversioned PEERDIRs to this library refer to the specified version.
  1634. ###
  1635. ### For example, if the module has PEERDIR (contrib/java/junit/junit), and
  1636. ### 1. specifies DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12),
  1637. ### the PEERDIR is automatically replaced by contrib/java/junit/junit/4.12;
  1638. ### 2. doesn't specify DEPENDENCY_MANAGEMENT, PEERDIR automatically replaced
  1639. ### with the default from contrib/java/junit/junit/ya.make.
  1640. ### These defaults are always there and are supported by maven-import, which puts
  1641. ### there the maximum version available in contrib/java.
  1642. ###
  1643. ### The property is transitive. That is, if module A PEERDIRs module B, and B has PEERDIR(contrib/java/junit/junit), and this junit was replaced by junit-4.12, then junit-4.12 will come to A through B.
  1644. ###
  1645. ### If some module has both DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12) and PERDIR(contrib/java/junit/junit/4.11), the PEERDIR wins.
  1646. ###
  1647. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  1648. macro DEPENDENCY_MANAGEMENT(Args...) {
  1649. SET_APPEND(DEPENDENCY_MANAGEMENT_VALUE $ARGS_DELIM $Args)
  1650. _GHOST_PEERDIR($Args)
  1651. }
  1652. # tag:java-specific
  1653. WITH_JDK_VALUE=
  1654. ### @usage: WITH_JDK()
  1655. ###
  1656. ### Add directory with JDK to JAVA_PROGRAM output
  1657. macro WITH_JDK() {
  1658. when ($REALPRJNAME == "jdk") {
  1659. _OK=no
  1660. }
  1661. otherwise {
  1662. _PACK_JDK= && ${YMAKE_PYTHON} ${input:"build/scripts/tar_directory.py"} ${output;tared:"jdk.tar"} $WITH_JDK_RESOURCE $WITH_JDK_RESOURCE
  1663. WITH_JDK_VALUE=yes
  1664. }
  1665. ASSERT(_OK [[alt1]]jdk[[rst]] name is prohibited for [[imp]]JAVA_PROGRAM[[rst]] module when [[imp]]WITH_JDK[[rst]] is used, [[imp]]WITH_JDK[[rst]] will be ignored.)
  1666. }
  1667. # tag:kotlin-specific
  1668. WITH_KOTLIN_VALUE=
  1669. _WITH_KOTLIN_SEM=
  1670. _KOTLIN_VERSION_SEM=
  1671. ### @usage: WITH_KOTLIN()
  1672. ###
  1673. ### Compile kotlin source code in this java module
  1674. macro WITH_KOTLIN() {
  1675. SET(WITH_KOTLIN_VALUE yes)
  1676. SET(_WITH_KOTLIN_SEM && with_kotlin)
  1677. SET(_KOTLIN_VERSION_SEM && kotlin_version ${_KOTLIN_VERSION})
  1678. }
  1679. # tag:kotlin-specific
  1680. WITH_KAPT_VALUE=
  1681. ### @usage: WITH_KAPT()
  1682. ###
  1683. ### Use kapt for as annotation processor
  1684. macro WITH_KAPT() {
  1685. SET(WITH_KAPT_VALUE yes)
  1686. }
  1687. # tag:kotlin-specific
  1688. KOTLINC_FLAGS_VALUE=-Xjvm-default=all
  1689. ### @usage: KOTLINC_FLAGS(-flags)
  1690. ###
  1691. ### Set additional Kotlin compilation flags.
  1692. macro KOTLINC_FLAGS(Args...) {
  1693. SET_APPEND(KOTLINC_OPTS_VALUE $Args)
  1694. }
  1695. # tag:kotlin-sppecific
  1696. WITH_KOTLINC_PLUGIN_ALLOPEN=
  1697. _WITH_KOTLINC_PLUGIN_ALLOPEN_SEM=
  1698. macro _WITH_KOTLINC_ALLOPEN(Options...) {
  1699. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.allopen\::Options})
  1700. SET(WITH_KOTLINC_PLUGIN_ALLOPEN yes)
  1701. SET(_WITH_KOTLINC_PLUGIN_ALLOPEN_SEM && with_kotlinc_plugin_allopen default $Options)
  1702. }
  1703. # tag:kotlin-specific
  1704. ### @usage: WITH_KOTLINC_ALLOPEN(-flags)
  1705. ###
  1706. ### Enable allopen kotlin compiler plugin https://kotlinlang.org/docs/all-open-plugin.html
  1707. macro WITH_KOTLINC_ALLOPEN(HEAD, TAIL...) {
  1708. _WITH_KOTLINC_ALLOPEN($HEAD $TAIL)
  1709. }
  1710. # tag:kotlin-specific
  1711. WITH_KOTLINC_PLUGIN_LOMBOK=
  1712. _WITH_KOTLINC_PLUGIN_LOMBOK_SEM=
  1713. ### @usage: WITH_KOTLINC_LOMBOK(-flags)
  1714. ###
  1715. ### Enable lombok kotlin compiler plugin https://kotlinlang.org/docs/lombok.html
  1716. macro WITH_KOTLINC_LOMBOK(Options...) {
  1717. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.lombok\::Options})
  1718. SET(WITH_KOTLINC_PLUGIN_LOMBOK yes)
  1719. SET(_WITH_KOTLINC_PLUGIN_LOMBOK_SEM && with_kotlinc_plugin_lombok default $Options)
  1720. }
  1721. # tag:kotlin-specific
  1722. WITH_KOTLINC_PLUGIN_NOARG=
  1723. _WITH_KOTLINC_PLUGIN_NOARG_SEM=
  1724. ### @usage: WITH_KOTLINC_NOARG(-flags)
  1725. ###
  1726. ### Enable noarg kotlin compiler plugin https://kotlinlang.org/docs/no-arg-plugin.html
  1727. macro WITH_KOTLINC_NOARG(Options...) {
  1728. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.noarg\::Options})
  1729. SET(WITH_KOTLINC_PLUGIN_NOARG yes)
  1730. SET(_WITH_KOTLINC_PLUGIN_NOARG_SEM && with_kotlinc_plugin_noarg default $Options)
  1731. }
  1732. # tag:kotlin-specific
  1733. WITH_KOTLINC_PLUGIN_SERIALIZATION=
  1734. _WITH_KOTLINC_PLUGIN_SERIALIZATION_SEM=
  1735. ### @usage: WITH_KOTLINC_SERIALIZATION()
  1736. ###
  1737. ### Enable serialization kotlin compiler plugin https://kotlinlang.org/docs/serialization.html
  1738. macro WITH_KOTLINC_SERIALIZATION() {
  1739. SET(WITH_KOTLINC_PLUGIN_SERIALIZATION yes)
  1740. SET(_WITH_KOTLINC_PLUGIN_SERIALIZATION_SEM && with_kotlinc_plugin_serialization default)
  1741. }
  1742. # tag:kotlin-specific
  1743. WITH_KOTLINC_PLUGIN_DETEKT=
  1744. _WITH_KOTLINC_PLUGIN_DETEKT_SEM=
  1745. ### @usage: WITH_KOTLINC_DETEKT(-flags)
  1746. ###
  1747. ### Enable detekt kotlin compiler plugin https://detekt.dev/docs/gettingstarted/compilerplugin/
  1748. macro WITH_KOTLINC_DETEKT(Options...) {
  1749. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:detekt-compiler-plugin\::Options})
  1750. SET(WITH_KOTLINC_PLUGIN_DETEKT yes)
  1751. SET(_WITH_KOTLINC_PLUGIN_DETEKT_SEM && with_kotlinc_plugin_detekt)
  1752. }
  1753. # tag:kotlin-specific
  1754. ### Also search for _KAPT_OPTS and change version there
  1755. _KOTLIN_VERSION=1.9.24
  1756. KOTLIN_VERSION=1.9.24
  1757. KOTLIN_BOM_FILE=${ARCADIA_ROOT}/contrib/java/org/jetbrains/kotlin/kotlin-bom/1.9.24/ya.dependency_management.inc
  1758. DETEKT_VERSION=1.23.7
  1759. _KOTLIN_SEM= \
  1760. ${_WITH_KOTLIN_SEM} \
  1761. ${_KOTLIN_VERSION_SEM} \
  1762. ${_WITH_KOTLIN_GRPC_SEM} \
  1763. ${_WITH_KOTLINC_PLUGIN_ALLOPEN_SEM} \
  1764. ${_WITH_KOTLINC_PLUGIN_LOMBOK_SEM} \
  1765. ${_WITH_KOTLINC_PLUGIN_NOARG_SEM} \
  1766. ${_WITH_KOTLINC_PLUGIN_SERIALIZATION_SEM} \
  1767. ${_WITH_KOTLINC_PLUGIN_DETEKT_SEM}
  1768. _JAVA_PROTO_GRPC_SEM=
  1769. when ($_GRPC_ENABLED == "yes") {
  1770. _JAVA_PROTO_GRPC_SEM= && proto_grpc && proto_grpc_version ${JAVA_GRPC_VERSION}
  1771. }
  1772. _JAVA_PROTO_NAMESPACE_SEM=
  1773. when ($PROTO_NAMESPACE != "") {
  1774. _JAVA_PROTO_NAMESPACE_SEM= && proto_namespace $PROTO_NAMESPACE
  1775. }
  1776. _JAVA_PROTO_SEM= \
  1777. ${_JAVA_PROTO_NAMESPACE_SEM} \
  1778. && proto_compiler_version ${JAVA_PROTO_COMPILER_VERSION} \
  1779. && proto_runtime_version ${JAVA_PROTO_RUNTIME_VERSION} \
  1780. && proto_common_version ${JAVA_PROTO_COMMON_VERSION} \
  1781. ${_JAVA_PROTO_GRPC_SEM}
  1782. # tag:java-specific
  1783. DIRECT_DEPS_ONLY_VALUE=
  1784. ### @usage: DIRECT_DEPS_ONLY
  1785. ###
  1786. ### Add direct PEERDIR's only in java compile classpath
  1787. macro DIRECT_DEPS_ONLY() {
  1788. SET(DIRECT_DEPS_ONLY_VALUE yes)
  1789. }
  1790. # tag:java-specific
  1791. JAVA_EXTERNAL_DEPENDENCIES_VALUE=
  1792. ### @usage: JAVA_EXTERNAL_DEPENDENCIES(file1 file2 ...)
  1793. ###
  1794. ### Add non-source java external build dependency (like lombok config file)
  1795. macro JAVA_EXTERNAL_DEPENDENCIES(Args...) {
  1796. SET_APPEND(JAVA_EXTERNAL_DEPENDENCIES_VALUE $Args)
  1797. }
  1798. # tag:java-specific
  1799. JAVA_CLASSPATH_CMD_TYPE_VALUE=
  1800. # tag:java-specific
  1801. ### @usage:TEST_JAVA_CLASSPATH_CMD_TYPE(Type)
  1802. ### Available types: MANIFEST(default), COMMAND_FILE, LIST
  1803. ### Method for passing a classpath value to a java command line
  1804. ### MANIFEST via empty jar file with manifest that contains Class-Path attribute
  1805. ### COMMAND_FILE via @command_file
  1806. ### LIST via flat args
  1807. macro TEST_JAVA_CLASSPATH_CMD_TYPE(Type) {
  1808. SET(JAVA_CLASSPATH_CMD_TYPE_VALUE $Type)
  1809. }
  1810. # tag:java-specific
  1811. IGNORE_JAVA_DEPENDENCIES_CONFIGURATION=no
  1812. JAVA_DEPENDENCIES_CONFIGURATION_VALUE=
  1813. # tag:java-specific
  1814. ### @usage JAVA_DEPENDENCIES_CONFIGURATION(Vetos...)
  1815. ### Validate contrib/java dependencies
  1816. ### Valid arguments
  1817. ### FORBID_DIRECT_PEERDIRS - fail when module have direct PEERDIR (with version) (non-transitive)
  1818. ### FORBID_CONFLICT - fail when module have resolved without DEPENDENCY_MANAGEMENT version conflict (transitive)
  1819. ### FORBID_CONFLICT_DM - fail when module have resolved with DEPENDENCY_MANAGEMENT version conflict (transitive)
  1820. ### FORBID_CONFLICT_DM_RECENT - like FORBID_CONFLICT_DM but fail only when dependency have more recent version than specified in DEPENDENCY_MANAGEMENT
  1821. ### REQUIRE_DM - all dependencies must be specified in DEPENDENCY_MANAGEMENT (transitive)
  1822. macro JAVA_DEPENDENCIES_CONFIGURATION(Args...) {
  1823. SET_APPEND(JAVA_DEPENDENCIES_CONFIGURATION_VALUE $Args)
  1824. }
  1825. # tag:java-specific
  1826. # TODO(DEVTOOLS-6901): remove this variable when there are no more references to it in jbuild
  1827. JAVA_FORBIDDEN_LIBRARIES_VALUE=
  1828. # tag:java-specific
  1829. JAR_INCLUDE_FILTER_VALUE=
  1830. JAR_EXCLUDE_FILTER_VALUE=
  1831. # tag:java-specific
  1832. ### @usage:JAR_INCLUDE(Filters...)
  1833. ### Filter .jar file content: keep only matched files
  1834. ### * and ** patterns are supported (like JAVA_SRCS)
  1835. macro JAR_INCLUDE(Filters...) {
  1836. SET_APPEND(JAR_INCLUDE_FILTER_VALUE $Filters)
  1837. }
  1838. # tag:java-specific
  1839. ### @usage:JAR_EXCLUDE(Filters...)
  1840. ### Filter .jar file content: remove matched files
  1841. ### * and ** patterns are supported (like JAVA_SRCS)
  1842. macro JAR_EXCLUDE(Filters...) {
  1843. SET_APPEND(JAR_EXCLUDE_FILTER_VALUE $Filters)
  1844. }
  1845. # tag:java-specific
  1846. _COMPILE_JSRC=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/compile_jsrc.py"} --input $AUTO_INPUT --output $TARGET --prefix $BINDIR ${hide;kv:"p JC"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}
  1847. # tag:java-specific
  1848. COMPILE_JSRC_MF=$_COMPILE_JSRC && $GENERATE_MF
  1849. # tag:java-specific tag:internal
  1850. ### @usage: JSRC_LIBRARY() # internal
  1851. module JSRC_LIBRARY: _BARE_UNIT {
  1852. .CMD=COMPILE_JSRC_MF
  1853. .EXTS=.java
  1854. .PEERDIR_POLICY=as_include
  1855. .FINAL_TARGET=no
  1856. .ALIASES=SRCS=FILES
  1857. PEERDIR_TAGS=JAVA JAVA_PROTO JAVA_FBS JAVA_IDL
  1858. MODULE_TYPE=LIBRARY
  1859. SET(MODULE_SUFFIX .jsrc)
  1860. SET(DONT_RESOLVE_INCLUDES yes)
  1861. SET(NEED_PLATFORM_PEERDIRS no)
  1862. SET(MODULE_LANG JAVA)
  1863. NO_RUNTIME()
  1864. }
  1865. # tag:java-specific
  1866. JAVA_PROGRAM_CP_USE_COMMAND_FILE=yes
  1867. when ($JDK_REAL_VERSION == "8") {
  1868. JAVA_PROGRAM_CP_USE_COMMAND_FILE=no
  1869. }
  1870. # tag:kotlin-specific
  1871. KOTLIN_JVM_TARGET=
  1872. when ($JDK_REAL_VERSION == "8") {
  1873. KOTLIN_JVM_TARGET=1.8
  1874. }
  1875. elsewhen ($JDK_REAL_VERSION == "22") {
  1876. # remove when kotlin starts supporting jdk21 bytecode
  1877. # see also devtools/ya/jbuild/gen/actions/idea.py
  1878. KOTLIN_JVM_TARGET=21
  1879. }
  1880. elsewhen ($JDK_REAL_VERSION == "23") {
  1881. # remove when kotlin starts supporting jdk21 bytecode
  1882. # see also devtools/ya/jbuild/gen/actions/idea.py
  1883. KOTLIN_JVM_TARGET=21
  1884. }
  1885. otherwise {
  1886. KOTLIN_JVM_TARGET=$JDK_REAL_VERSION
  1887. }
  1888. # tag:java-specific tag:internal
  1889. ### @usage: _JDK_VERSION_INTERNAL(Version) #internal
  1890. ###
  1891. ### Specify JDK version for module
  1892. macro _JDK_VERSION_INTERNAL(Arg) {
  1893. .SEM=required_jdk $Arg ${hide;output:"JdkVersionFakeProp.java"}
  1894. SET(JDK_REAL_VERSION $Arg)
  1895. _JDK_VERSION_MACRO_CHECK($Arg)
  1896. }
  1897. # tag:java-specific
  1898. ### @usage: JDK_VERSION(Version)
  1899. ###
  1900. ### Specify JDK version for module
  1901. macro JDK_VERSION(Arg) {
  1902. _JDK_VERSION_INTERNAL($Arg)
  1903. }
  1904. # tag:java-specific
  1905. ### @usage: DEFAULT_JDK_VERSION(Version)
  1906. ###
  1907. ### Specify JDK version for module, can be overridden by setting the JDK_VERSION variable
  1908. macro DEFAULT_JDK_VERSION(Arg) {
  1909. _SET_FIRST_VALUE(_JDK_VERSION $JDK_VERSION $Arg)
  1910. _JDK_VERSION_INTERNAL($_JDK_VERSION)
  1911. }
  1912. # tag:java-specific
  1913. # local jdk and tools
  1914. USE_SYSTEM_JDK=
  1915. USE_SYSTEM_UBERJAR=
  1916. USE_SYSTEM_ERROR_PRONE=
  1917. # tag:kotlin-specific
  1918. _USE_KTLINT_OLD=no
  1919. # tag:kotlin-specific
  1920. ### @usage: USE_KTLINT_OLD()
  1921. ### Marks that need use the old version of ktlint
  1922. macro USE_KTLINT_OLD() {
  1923. ENABLE(_USE_KTLINT_OLD)
  1924. }
  1925. # tag:kotlin-specific
  1926. _KTLINT_BASELINE_FILE=
  1927. # tag:kotlin-specific
  1928. ### @usage: #deprecated KTLINT_BASELINE_FILE(ktlint-baseline.xml "https://st.yandex-team.ru/REMOVE-BASELINE-1")
  1929. ### Path to baseline file for ktlint test and ticket to fix all ktlint warnings in file and then remove it
  1930. macro KTLINT_BASELINE_FILE(File, Ticket) {
  1931. SET(_KTLINT_BASELINE_FILE $File)
  1932. }
  1933. # tag:kotlin-specific
  1934. _WITH_YA_1931=no
  1935. # tag:kotlin-specific
  1936. ### @usage: WITH_YA_1931()
  1937. ### Interim macro to temporarily remove ALL_SRCDIRS from being added to ktlint test sources.
  1938. macro WITH_YA_1931() {
  1939. MESSAGE(WARNING Some files in this project have style errors that were not caught by prior ktlint runs. Remove WITH_YA_1931 macro to see them.)
  1940. ENABLE(_WITH_YA_1931)
  1941. }