java.conf 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143
  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 ${input;hide: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 ${output_include;hide:OUTPUT_INCLUDES} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"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} ${kv;hide:"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=22
  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;input;context=TEXT:IN_NOPARSE} \
  427. && runs-out ${OUT} ${hide;output:OUT} ${OUT_NOAUTO} ${hide;output;noauto: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=${kv;hide:"p RJ"} ${kv;hide:"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} ${output;hide:STDOUT} ${pre=--file=:STDOUT_NOAUTO} ${output;hide;noauto: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) ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output;noauto;hide:OUT_NOAUTO} ${output;hide:OUT} ${tool;hide: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 ${"$"}{input;hide:$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. }
  511. # tag:java-specific
  512. macro _FETCH_CONTRIB(Id, Out, SBR="sbr:") {
  513. .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} ${input;hide:"build/scripts/fetch_from.py"} ${requirements;hide:"network:full"} ${kv;hide:"p SB"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  514. ADD_CHECK(check.resource $Id)
  515. }
  516. # tag:java-specific
  517. LOCAL_JAR_PATH=
  518. LOCAL_SOURCES_JAR_PATH=
  519. JAR_RESOURCE_ID=
  520. SRC_RESOURCE_ID=
  521. FETCH_SRCS_JAR=
  522. FETCH_TARGET_JAR=
  523. FETCH_CONTRIB_JAR=${hide:JAVA_FAKEID} $FETCH_TARGET_JAR $FETCH_SRCS_JAR
  524. # tag:java-specific
  525. macro JAR_RESOURCE(Id) {
  526. SET(JAR_RESOURCE_ID $Id)
  527. }
  528. # tag:java-specific
  529. macro SRC_RESOURCE(Id) {
  530. SET(SRC_RESOURCE_ID $Id)
  531. }
  532. # tag:java-specific
  533. macro LOCAL_JAR(File) {
  534. SET(LOCAL_JAR_PATH $File)
  535. }
  536. # tag:java-specific
  537. macro LOCAL_SOURCES_JAR(File) {
  538. SET(LOCAL_SOURCES_JAR_PATH $File)
  539. }
  540. JAVA_CONTRIB_SEM= \
  541. ${hide:TARGET} ${hide:AUTO_INPUT} \
  542. consumer-classpath $EXPORT_GRADLE_CLASSPATH \
  543. && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
  544. && consumer-type contrib \
  545. $_JAVAC_SEM \
  546. && IGNORED
  547. # tag:java-specific
  548. module JAVA_CONTRIB: _JAR_BASE {
  549. .CMD=FETCH_CONTRIB_JAR
  550. .PEERDIR_POLICY=as_include
  551. .SEM=JAVA_CONTRIB_SEM
  552. .FINAL_TARGET=yes
  553. .GLOBAL=MAVEN_EXPORT_COORDS
  554. when ($JAR_RESOURCE_ID) {
  555. FETCH_TARGET_JAR= && $_FETCH_CONTRIB($JAR_RESOURCE_ID ${BINDIR}/${MODULE_PREFIX}${REALPRJNAME}${MODULE_SUFFIX})
  556. }
  557. otherwise {
  558. when ($LOCAL_JAR_PATH) {
  559. FETCH_TARGET_JAR= && $FS_TOOLS copy ${input:LOCAL_JAR_PATH} $TARGET
  560. }
  561. otherwise {
  562. FETCH_TARGET_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && ${cwd:BINDIR} $JDK_RESOURCE/bin/jar cfvm $TARGET $VCS_JAVA .
  563. PEERDIR+=build/platform/java/jdk
  564. PEERDIR+=$JDK_RESOURCE_PEERDIR
  565. }
  566. }
  567. when ($SRC_RESOURCE_ID) {
  568. FETCH_SRCS_JAR= && $_FETCH_CONTRIB($SRC_RESOURCE_ID ${BINDIR}/${REALPRJNAME}-sources.jar)
  569. }
  570. otherwise {
  571. when ($LOCAL_SOURCES_JAR_PATH) {
  572. FETCH_SRCS_JAR= && $FS_TOOLS copy ${input:LOCAL_SOURCES_JAR_PATH} ${output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME}
  573. }
  574. otherwise {
  575. 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 .
  576. PEERDIR+=build/platform/java/jdk
  577. PEERDIR+=$JDK_RESOURCE_PEERDIR
  578. }
  579. }
  580. when ($MAVEN_EXPORT == "yes") {
  581. _MAKEFILE_INCLUDE_LIKE_DEPS+=pom.xml
  582. FETCH_CONTRIB_JAR+= && $MAVEN_EXPORT_GEN_DEPLST
  583. }
  584. SET(MODULE_SUFFIX .jar)
  585. _SETUP_MAVEN_EXPORT_COORDS_IF_NEED($MODDIR)
  586. }
  587. MAKE_JAVA_CLASSPATH_FILE=$YMAKE_PYTHON ${input:"build/scripts/make_java_classpath_file.py"} ${input;hide:"build/scripts/process_command_files.py"}
  588. # tag:kotlin-specific
  589. KOTLINC_OPTS_VALUE=
  590. # tag:kotlin-specific
  591. KT_SRCLIST=${BINDIR}/misc/all-kt-sources.txt
  592. KT_SRSCLIST_FLAG=--kotlin $KT_SRCLIST
  593. KT_CLASSES_DIR=${BINDIR}/kt_cls
  594. KT_CLASSPATH=${BINDIR}/kt_cp.txt
  595. COLLECT_KT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/kt_bfg.txt -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file
  596. LINK_KT_CLASSPATH=${MAKE_JAVA_CLASSPATH_FILE} ${BINDIR}/kt_bfg.txt $KT_CLASSPATH && $FS_TOOLS md $KT_CLASSES_DIR
  597. COMPILE_KT= \
  598. ${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} \
  599. ${input;hide:"build/scripts/build_java_with_error_prone2.py"} \
  600. ${input;hide:"build/scripts/setup_java_tmpdir.py"} \
  601. --kotlin --sources-list $KT_SRCLIST \
  602. $JDK_RESOURCE/bin/java -jar $KOTLIN_COMPILER_RESOURCE_GLOBAL/kotlin-compiler.jar -no-stdlib -module-name $REALPRJNAME \
  603. -jvm-target ${KOTLIN_JVM_TARGET} @$KT_SRCLIST -classpath @$KT_CLASSPATH $KOTLINC_FLAGS_VALUE -d $KT_CLASSES_DIR $KOTLINC_OPTS_VALUE
  604. ALL_KT_COMMANDS=
  605. KT_CLASSPATH_ITEM=
  606. # tag:kotlin-specific
  607. KT_KAPT_SOURCES_DIR=${BINDIR}/kapt_gen_src
  608. KT_KAPT_STUBS_DIR=${BINDIR}/kapt_gen_stubs
  609. KT_KAPT_AP_CLASSPATH=
  610. 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
  611. ### @usage: KAPT_OPTS(opts...)
  612. ###
  613. ### Used to specify annotation processor qualified class names.
  614. ### If specified multiple times, only last specification is used.
  615. macro KAPT_OPTS(Args...) {
  616. SET_APPEND(KT_KAPT_PLUGIN_OPTS ${pre=-P :Args})
  617. }
  618. ### @usage: KAPT_ANNOTATION_PROCESSOR(processors...)
  619. ###
  620. ### Used to specify annotation processor qualified class names.
  621. ### If specified multiple times, only last specification is used.
  622. macro KAPT_ANNOTATION_PROCESSOR(Args...) {
  623. KAPT_OPTS(${pre="plugin:org.jetbrains.kotlin.kapt3:processors=":Args})
  624. }
  625. ### @usage: KAPT_ANNOTATION_PROCESSOR_CLASSPATH(jars...)
  626. ###
  627. ### Used to specify classpath for annotation processors.
  628. ### If specified multiple times, all specifications are used.
  629. macro KAPT_ANNOTATION_PROCESSOR_CLASSPATH(Args...) {
  630. PEERDIR($Args)
  631. SET_APPEND(KT_KAPT_AP_CLASSPATH $Args)
  632. }
  633. # tag:java-specific
  634. JAVAC_CMD=$JDK_RESOURCE/bin/javac
  635. RUN_JAVAC_ARGS=
  636. # tag:java-specific tag:codenav
  637. JAVA_YNDEXING=no
  638. # tag:java-specific
  639. when ($USE_SYSTEM_KYTHE) {
  640. KYTHE_RESOURCE=$USE_SYSTEM_KYTHE
  641. }
  642. otherwise {
  643. KYTHE_RESOURCE=$KYTHE_RESOURCE_GLOBAL
  644. }
  645. # tag:java-specific tag:codenav
  646. _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
  647. _DO_JAVA_YNDEXING=
  648. # tag:java-specific
  649. SOURCES_JAR=no
  650. when ($BUILD_TYPE == "DEBUG" && $NO_DEBUGINFO != "yes") {
  651. SOURCES_JAR=yes
  652. }
  653. _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 .
  654. _PACK_SRC_JAR=
  655. # tag:java-specific
  656. _PACK_JNI=
  657. _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
  658. # tag:java-specific
  659. _MAKE_JSTYLE_FILE_LIST=
  660. # tag:java-specific
  661. _LINK_UBERJAR=
  662. _UBERJAR_SELF=
  663. _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} \
  664. && $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} $BINDIR/_empty/META-INF \
  665. && $YMAKE_PYTHON ${input:"build/scripts/touch.py"} $BINDIR/_empty/META-INF/MANIFEST.MF \
  666. && $UPDATE_VCS_JAVA_INFO_NODEP($TARGET) \
  667. && ${cwd;suf=/_empty:BINDIR} ${JDK_RESOURCE}/bin/jar ufv ${TARGET} META-INF/MANIFEST.MF \
  668. && $JDK_RESOURCE/bin/jar ufvm $TARGET $VCS_JAVA
  669. # tag:java-specific
  670. macro _PACK_JAR_HELPER(Out) {
  671. .CMD=${cwd;suf=/cls:BINDIR} ${env:"LC_ALL=en_US.UTF-8"} $JDK_RESOURCE/bin/jar cfvm $Out $VCS_JAVA .
  672. }
  673. # tag:java-specific
  674. macro _JAVAC_RUN_HELPER(JAVAC_CMD_WITH_ARGS...) {
  675. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} ${input;hide:"build/scripts/build_java_with_error_prone2.py"} ${input;hide:"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
  676. }
  677. # tag:java-specific
  678. 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
  679. ERROR_PRONE_2_7_1_FORCED_OPTS=-Xep:InlineMeInliner:OFF -Xep:SameNameButDifferent:OFF
  680. # tag:java-specific
  681. macro _ADD_OPTS_IF_NON_EMPTY(Opt, Args...) {
  682. .CMD=${pre=$Opt :Args}
  683. }
  684. macro _ADD_GEN_POM_FROM_COORD_FILES_ARGS(Deps...) {
  685. .CMD=${pre=--deps-coords ;ext=.jar;suf=.mvn_coords:Deps}
  686. }
  687. MAVEN_BIN=$MAVEN_RESOURCE_GLOBAL/bin/mvn
  688. MAVEN_EXPORT_OUT_DIR_FLAG=$_ADD_OPTS_IF_NON_EMPTY(--output-dir ${MAVEN_EXPORT_OUT_DIR})
  689. MAVEN_EXPORT_SOURCE_DIRS=$_ADD_OPTS_IF_NON_EMPTY(--source-dirs ${ALL_SRCDIRS})
  690. MAVEN_EXPORT_DEPS_COORS=$_ADD_GEN_POM_FROM_COORD_FILES_ARGS(${MANAGED_PEERS_CLOSURE})
  691. MAVEN_EXPORT_OUT_DIR=
  692. MAVEN_EXPORT=no
  693. MAVEN_DEPLOY=no
  694. MAVEN_DEPLOY_SOURCES=
  695. MAVEN_EXPORT_VERSION={vcs_revision}
  696. MAVEN_EXPORT_GEN_DEPLST= \
  697. $WRITER_PY \
  698. --file ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mvn_coords:REALPRJNAME} \
  699. --ya-start-command-file -m ${pre=D=:MAVEN_EXPORT_COORDS_GLOBAL} ${pre=E=:EXCLUDED_MAVEN_EXPORT_COORDS_GLOBAL} --ya-end-command-file \
  700. ${hide:APPLIED_EXCLUDES}
  701. MAVEN_EXPORT_GEN_POM=${kv;hide:"mvn_export yes"} \
  702. $YMAKE_PYTHON ${input:"build/scripts/generate_pom.py"} \
  703. --from-coord-files \
  704. --vcs-info $(VCS)/vcs.json \
  705. --target-path $MODDIR \
  706. $MAVEN_EXPORT_SOURCE_DIRS \
  707. $MAVEN_EXPORT_DEPS_COORS \
  708. $MAVEN_EXPORT_OUT_DIR_FLAG \
  709. --target-coords ${suf=.mvn_coords:TARGET} \
  710. --pom-path ${output:"pom.xml"}
  711. MAVEN_DEPLOY_CMD=$YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} $MAVEN_BIN \
  712. deploy:deploy-file -DpomFile=$BINDIR/pom.xml \
  713. -Dfile=$TARGET -DrepositoryId=$MAVEN_REPO_ID -Durl=$MAVEN_REPO_URL -Djava.net.preferIPv4Addresses=false -Djava.net.preferIPv6Addresses=true \
  714. ${MAVEN_DEPLOY_SOURCES} \
  715. $_ADD_OPTS_IF_NON_EMPTY(-gs $MAVEN_EXPORT_SETTINGS) \
  716. $_ADD_OPTS_IF_NON_EMPTY(-s $MAVEN_EXPORT_SETTINGS)
  717. MAVEN_EXPORT_CMD=
  718. # tag:java-specific
  719. JAVA_COVERAGE_SRCLIST_FLAG=--coverage ${output;pre=${MODULE_PREFIX};suf=.cpsf:REALPRJNAME} --source-root ${ARCADIA_ROOT}
  720. JAVA_COVERAGE_SRCLIST=
  721. PREPARE_JAVA_BUILD_DIRS=$FS_TOOLS md ${BINDIR}/cls && $FS_TOOLS md ${BINDIR}/misc
  722. EXTRACT_GENDIRS=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --unpack --ext .gentar ${ext=.gentar:AUTO_INPUT}
  723. COLLECT_JAVA_SRCLIST=${YMAKE_PYTHON} ${input:"build/scripts/make_java_srclists.py"} ${input;hide:"build/scripts/process_command_files.py"} ${input;hide:"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
  724. COLLECT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/bfg.txt -m --ya-start-command-file ${rootrel:MANAGED_PEERS_CLOSURE} $KT_CLASSPATH_ITEM --ya-end-command-file
  725. LINK_CLASSPATH=${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/bfg.txt ${ARCADIA_BUILD_ROOT}/bfg.jar
  726. COMPILE_JAVA_SRCLIST=$_JAVAC_RUN_HELPER($JAVAC_CMD)
  727. PACK_JAR=$_PACK_JAR_HELPER($TARGET)
  728. # NOTE: No && before LINK_JAR_RESOURCES, ALL_KT_COMMANDS and JAR_GEN_SRCS needed since those vars either empty or starts with &&
  729. LINK_JAR=${hide:JAVA_FAKEID} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} ${requirements;hide:"cpu:2"} \
  730. $PREPARE_JAVA_BUILD_DIRS \
  731. && $EXTRACT_GENDIRS \
  732. && $COLLECT_JAVA_SRCLIST \
  733. $JAR_GEN_SRCS \
  734. $ALL_KT_COMMANDS \
  735. && $COLLECT_CLASSPATH \
  736. && $LINK_CLASSPATH \
  737. && $COMPILE_JAVA_SRCLIST \
  738. $LINK_JAR_RESOURCES \
  739. && ${cwd;suf=/cls:BINDIR} $GENERATE_VCS_JAVA_INFO_NODEP . \
  740. $_PACK_SRC_JAR \
  741. $_PACK_JNI \
  742. && $PACK_JAR \
  743. $_DO_JAVA_YNDEXING \
  744. $_MAKE_JSTYLE_FILE_LIST \
  745. $_LINK_UBERJAR \
  746. $MAVEN_EXPORT_CMD \
  747. $_ADD_HIDDEN_INPUTS($JAVA_EXTERNAL_DEPENDENCIES_VALUE)
  748. # tag:java-specific
  749. _EXT_SRC_JAR=
  750. _EXT_JAR=
  751. _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} .
  752. _DO_USE_EXT_JAR=${hide:JAVA_FAKEID} $FS_TOOLS copy ${input:_EXT_JAR} $TARGET $_COPY_EXT_SRC_JAR $MAVEN_EXPORT_CMD
  753. _DO_COPY_EXT_SRC_JAR= && $FS_TOOLS copy $_EXT_SRC_JAR ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME}
  754. macro JAVA_RESOURCE(JAR, SOURCES="") {
  755. SET(_EXT_SRC_JAR $SOURCES)
  756. SET(_EXT_JAR $JAR)
  757. }
  758. # tag:java-specific tag:fbs
  759. JAVA_FLATBUFFERS_VERSION = 24.3.25
  760. _KOTLIN_ALLOWED_VERSIONS = contrib/java/org/jetbrains/kotlin/kotlin-allopen/${_KOTLIN_VERSION} \
  761. contrib/java/org/jetbrains/kotlin/kotlin-allopen-compiler-plugin/${_KOTLIN_VERSION} \
  762. contrib/java/org/jetbrains/kotlin/kotlin-annotation-processing/${_KOTLIN_VERSION} \
  763. contrib/java/org/jetbrains/kotlin/kotlin-compiler/${_KOTLIN_VERSION} \
  764. contrib/java/org/jetbrains/kotlin/kotlin-compiler-embeddable/${_KOTLIN_VERSION} \
  765. contrib/java/org/jetbrains/kotlin/kotlin-daemon-client/${_KOTLIN_VERSION} \
  766. contrib/java/org/jetbrains/kotlin/kotlin-daemon-embeddable/${_KOTLIN_VERSION} \
  767. contrib/java/org/jetbrains/kotlin/kotlin-gradle-plugin-api/${_KOTLIN_VERSION} \
  768. contrib/java/org/jetbrains/kotlin/kotlin-gradle-plugin-model/${_KOTLIN_VERSION} \
  769. contrib/java/org/jetbrains/kotlin/kotlin-lombok-compiler-plugin/${_KOTLIN_VERSION} \
  770. contrib/java/org/jetbrains/kotlin/kotlin-main-kts/${_KOTLIN_VERSION} \
  771. contrib/java/org/jetbrains/kotlin/kotlin-maven-allopen/${_KOTLIN_VERSION} \
  772. contrib/java/org/jetbrains/kotlin/kotlin-maven-lombok/${_KOTLIN_VERSION} \
  773. contrib/java/org/jetbrains/kotlin/kotlin-maven-noarg/${_KOTLIN_VERSION} \
  774. contrib/java/org/jetbrains/kotlin/kotlin-maven-serialization/${_KOTLIN_VERSION} \
  775. contrib/java/org/jetbrains/kotlin/kotlin-noarg-compiler-plugin/${_KOTLIN_VERSION} \
  776. contrib/java/org/jetbrains/kotlin/kotlin-osgi-bundle/${_KOTLIN_VERSION} \
  777. contrib/java/org/jetbrains/kotlin/kotlin-reflect/${_KOTLIN_VERSION} \
  778. contrib/java/org/jetbrains/kotlin/kotlin-scripting-common/${_KOTLIN_VERSION} \
  779. contrib/java/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/${_KOTLIN_VERSION} \
  780. contrib/java/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/${_KOTLIN_VERSION} \
  781. contrib/java/org/jetbrains/kotlin/kotlin-scripting-ide-services/${_KOTLIN_VERSION} \
  782. contrib/java/org/jetbrains/kotlin/kotlin-scripting-jsr223/${_KOTLIN_VERSION} \
  783. contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm/${_KOTLIN_VERSION} \
  784. contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm-host/${_KOTLIN_VERSION} \
  785. contrib/java/org/jetbrains/kotlin/kotlin-script-runtime/${_KOTLIN_VERSION} \
  786. contrib/java/org/jetbrains/kotlin/kotlin-script-util/${_KOTLIN_VERSION} \
  787. contrib/java/org/jetbrains/kotlin/kotlin-serialization-compiler-plugin/${_KOTLIN_VERSION} \
  788. contrib/java/org/jetbrains/kotlin/kotlin-stdlib/${_KOTLIN_VERSION} \
  789. contrib/java/org/jetbrains/kotlin/kotlin-stdlib-common/${_KOTLIN_VERSION} \
  790. contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk7/${_KOTLIN_VERSION} \
  791. contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${_KOTLIN_VERSION} \
  792. contrib/java/org/jetbrains/kotlin/kotlin-stdlib-js/${_KOTLIN_VERSION} \
  793. contrib/java/org/jetbrains/kotlin/kotlin-test/${_KOTLIN_VERSION} \
  794. contrib/java/org/jetbrains/kotlin/kotlin-test-annotations-common/${_KOTLIN_VERSION} \
  795. contrib/java/org/jetbrains/kotlin/kotlin-test-common/${_KOTLIN_VERSION} \
  796. contrib/java/org/jetbrains/kotlin/kotlin-test-js/${_KOTLIN_VERSION} \
  797. contrib/java/org/jetbrains/kotlin/kotlin-test-junit/${_KOTLIN_VERSION} \
  798. contrib/java/org/jetbrains/kotlin/kotlin-test-junit5/${_KOTLIN_VERSION} \
  799. contrib/java/org/jetbrains/kotlin/kotlin-test-testng/${_KOTLIN_VERSION}
  800. # tag:java-specific
  801. module _COMPILABLE_JAR_BASE : _JAR_BASE {
  802. _GHOST_PEERDIR($_FORCED_DEPENDENCY_MANAGEMENT_VALUE)
  803. # flatbuffers-java
  804. DEPENDENCY_MANAGEMENT(contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  805. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/flatbuffers/flatbuffers-java EXCEPT contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  806. # protobuf-java
  807. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  808. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java EXCEPT contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  809. # protobuf-javalite
  810. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  811. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-javalite EXCEPT contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  812. # protobuf-java-util
  813. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION})
  814. 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})
  815. # protobuf-kotlin
  816. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION})
  817. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-kotlin EXCEPT contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION})
  818. # kotlin
  819. DEPENDENCY_MANAGEMENT($_KOTLIN_ALLOWED_VERSIONS)
  820. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib/${_KOTLIN_VERSION})
  821. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk7 EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk7/${_KOTLIN_VERSION})
  822. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8 EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${_KOTLIN_VERSION})
  823. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib-js EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib-js/${_KOTLIN_VERSION})
  824. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-stdlib-common EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-stdlib-common/${_KOTLIN_VERSION})
  825. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-reflect EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-reflect/${_KOTLIN_VERSION})
  826. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-osgi-bundle EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-osgi-bundle/${_KOTLIN_VERSION})
  827. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test/${_KOTLIN_VERSION})
  828. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-junit EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-junit/${_KOTLIN_VERSION})
  829. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-junit5 EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-junit5/${_KOTLIN_VERSION})
  830. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-testng EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-testng/${_KOTLIN_VERSION})
  831. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-js EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-js/${_KOTLIN_VERSION})
  832. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-test-common EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-test-common/${_KOTLIN_VERSION})
  833. 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})
  834. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-main-kts EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-main-kts/${_KOTLIN_VERSION})
  835. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-script-runtime EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-script-runtime/${_KOTLIN_VERSION})
  836. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-script-util EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-script-util/${_KOTLIN_VERSION})
  837. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-scripting-common EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-scripting-common/${_KOTLIN_VERSION})
  838. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-scripting-jsr223 EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-scripting-jsr223/${_KOTLIN_VERSION})
  839. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-scripting-jvm/${_KOTLIN_VERSION})
  840. 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})
  841. 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})
  842. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-compiler EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-compiler/${_KOTLIN_VERSION})
  843. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-compiler-embeddable EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-compiler-embeddable/${_KOTLIN_VERSION})
  844. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/org/jetbrains/kotlin/kotlin-daemon-client EXCEPT contrib/java/org/jetbrains/kotlin/kotlin-daemon-client/${_KOTLIN_VERSION})
  845. }
  846. _JAR_MAIN_CLASS=
  847. macro JAR_MAIN_CLASS(Class) {
  848. SET(_JAR_MAIN_CLASS ${Class})
  849. }
  850. _JAR_MAIN_SEM=
  851. _ADD_JAR_MAIN_SEM= && app_main_class ${_JAR_MAIN_CLASS}
  852. GRADLE_EXPORT_PUBLISHING=no
  853. _GRADLE_EXPORT_PUBLISHING_SEM=
  854. PUBLISH_MAVEN_VERSION=no
  855. _DO_GRADLE_EXPORT_PUBLISHING_SEM= \
  856. && publish \
  857. && publish_group $MAVEN_EXPORT_GROUP_ID \
  858. && publish_version $PUBLISH_MAVEN_VERSION
  859. BUILD_JAR_SEM= \
  860. ${hide:TARGET} ${hide:AUTO_INPUT} ${hide:APPLIED_EXCLUDES} \
  861. jar $MODDIR $REALPRJNAME \
  862. && consumer-classpath $EXPORT_GRADLE_CLASSPATH \
  863. && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
  864. && consumer-type library \
  865. $_JAVAC_SEM \
  866. $_KOTLIN_SEM \
  867. $_JAR_MAIN_SEM \
  868. $_GRADLE_EXPORT_PUBLISHING_SEM \
  869. $_ANN_PROCESSORS_SEM \
  870. $_USE_ANNOTATION_PROCESSOR_SEM \
  871. $_ENABLE_PREVIEW_SEM \
  872. $SEM_JAR_SOURCE_SET
  873. BUILD_PROTO_JAR_SEM= \
  874. ${hide:target} ${hide:AUTO_INPUT} \
  875. jar_proto $MODDIR $REALPRJNAME \
  876. $_JAVA_PROTO_SEM \
  877. && consumer-classpath $EXPORT_GRADLE_CLASSPATH \
  878. && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
  879. && consumer-type library \
  880. $_JAVAC_SEM \
  881. $_ANN_PROCESSORS_SEM \
  882. $_USE_ANNOTATION_PROCESSOR_SEM \
  883. $_ENABLE_PREVIEW_SEM \
  884. $_KOTLIN_SEM
  885. # tag:java-specific tag:internal
  886. ### @usage: JAR_LIBRARY() #internal
  887. ###
  888. ### Reimplementation of the JAVA_LIBRARY with ymake.core.conf and ymake based dependency management
  889. module JAR_LIBRARY: _COMPILABLE_JAR_BASE {
  890. .EXTS=.jsrc .java .jar .mf .gentar .kt
  891. .CMD=LINK_JAR
  892. .SEM=BUILD_JAR_SEM
  893. .FINAL_TARGET=yes
  894. .ALIASES=JAVA_SRCS=FULL_JAVA_SRCS ANNOTATION_PROCESSOR=JAR_ANNOTATION_PROCESSOR
  895. .RESTRICTED=EXTERNAL_JAR
  896. .GLOBAL=MAVEN_EXPORT_COORDS
  897. MODULE_SUFFIX=.jar
  898. PEERDIR(build/platform/java/jdk)
  899. PEERDIR+=$JDK_RESOURCE_PEERDIR
  900. when ($_EXT_SRC_JAR) {
  901. _COPY_EXT_SRC_JAR=_DO_COPY_EXT_SRC_JAR
  902. }
  903. when ($_EXT_JAR) {
  904. LINK_JAR=$_DO_USE_EXT_JAR
  905. }
  906. when ($OPENSOURCE_EXPORT == "no") {
  907. BUILD_JAR_SEM=IGNORED
  908. }
  909. when ($_JAR_MAIN_CLASS) {
  910. _JAR_MAIN_SEM=$_ADD_JAR_MAIN_SEM
  911. }
  912. when ($GRADLE_EXPORT_PUBLISHING == "yes") {
  913. _GRADLE_EXPORT_PUBLISHING_SEM=$_DO_GRADLE_EXPORT_PUBLISHING_SEM
  914. }
  915. # in the ideal world this statement must be under condition bellow
  916. DEPENDENCY_MANAGEMENT(contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${_KOTLIN_VERSION})
  917. when ($WITH_KOTLIN_VALUE) {
  918. KT_SRSCLIST=$KT_SRSCLIST_FLAG
  919. _MAKE_LINT_KT_FILES_LIST = $YMAKE_PYTHON ${input:"build/scripts/kt_copy.py"} $KT_SRCLIST ${output;noauto:"all-kt-sources.txt"} $(SOURCE_ROOT) $(BUILD_ROOT)
  920. ALL_KT_COMMANDS=&& $COLLECT_KT_CLASSPATH && $LINK_KT_CLASSPATH
  921. when ($WITH_KAPT_VALUE == "yes") {
  922. # For Kapt usage see: https://kotlinlang.org/docs/kapt.html#using-in-cli
  923. # See for kapt.kotlin.generated: https://github.com/JetBrains/kotlin/blob/master/plugins/kapt3/kapt3-cli/testData/integration/kotlinFileGeneration/build.txt
  924. _KAPT_OPTS=-Xplugin=${tool:"contrib/java/org/jetbrains/kotlin/kotlin-annotation-processing/1.9.24"} $KT_KAPT_PLUGIN_OPTS
  925. _RUN_KAPT=${YMAKE_PYTHON} ${input:"build/scripts/with_kapt_args.py"} ${pre=--ap-classpath :KT_KAPT_AP_CLASSPATH} -- $COMPILE_KT $_KAPT_OPTS
  926. _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
  927. ALL_KT_COMMANDS+=&& $_RUN_KAPT && $_APPEND_KAPT_GENERATED_SRCS
  928. }
  929. ALL_KT_COMMANDS+=&& $COMPILE_KT && $_MAKE_LINT_KT_FILES_LIST
  930. LINK_JAR_RESOURCES+=&& $FS_TOOLS copy_all_files ${KT_CLASSES_DIR} ${BINDIR}/cls
  931. PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8
  932. when($WITH_KOTLINC_PLUGIN_ALLOPEN) {
  933. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-allopen-plugin.jar
  934. }
  935. when($WITH_KOTLINC_PLUGIN_LOMBOK) {
  936. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-lombok-plugin.jar
  937. }
  938. when($WITH_KOTLINC_PLUGIN_NOARG) {
  939. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-noarg-plugin.jar
  940. }
  941. when($WITH_KOTLINC_PLUGIN_SERIALIZATION) {
  942. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-serialization-plugin.jar
  943. }
  944. # Must be in sync with KT_CLASSES_DIR!
  945. # There are problems in JDK13 with abs paths in classpath baked into jar file manifest. Using relative path
  946. # here assumes that jar file with classpath for javac located in the $ARCADIA_BUILD_ROOT
  947. KT_CLASSPATH_ITEM=$MODDIR/kt_cls
  948. }
  949. otherwise {
  950. KT_SRSCLIST=
  951. ALL_KT_COMMANDS=
  952. KT_CLASSES=
  953. }
  954. when ($MAVEN_EXPORT == "yes") {
  955. when ($MAVEN_DEPLOY == "yes") {
  956. PEERDIR+=build/external_resources/maven
  957. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM && $MAVEN_DEPLOY_CMD
  958. }
  959. otherwise {
  960. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM
  961. }
  962. MAVEN_EXPORT_COORDS_GLOBAL=$MAVEN_EXPORT_GROUP_ID:${MODULE_PREFIX}${REALPRJNAME}:${MAVEN_EXPORT_VERSION}:
  963. }
  964. when ($SOURCES_JAR == "yes") {
  965. _PACK_SRC_JAR=$_PACK_SRC_JAR_IMPL
  966. MAVEN_DEPLOY_SOURCES=-Dsources=${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME}
  967. }
  968. when ($JAVA_COVERAGE == "yes") {
  969. JAVA_COVERAGE_SRCLIST=$JAVA_COVERAGE_SRCLIST_FLAG
  970. }
  971. when ($MAKE_UBERJAR_VALUE == "yes") {
  972. _LINK_UBERJAR=$_DO_LINK_UBERJAR
  973. PACK_JAR=$_PACK_JAR_HELPER(${BINDIR}/${REALPRJNAME}.lib.jar)
  974. # TODO: This condition is incorrect in case of autoinputs _UBERJAR_SELF should be empty only for
  975. # modules without AUTO_INPUT and without JAVA_SRCS added inputs.
  976. when($ALL_JAR_SOURCES) {
  977. _UBERJAR_SELF=--jar ${BINDIR}/${REALPRJNAME}.lib.jar
  978. }
  979. PEERDIR+=build/platform/java/uberjar
  980. PEERDIR+=$UBERJAR_RESOURCE_PEERDIR
  981. }
  982. when($JAVA_YNDEXING == "yes") {
  983. PEERDIR+=build/platform/java/kythe
  984. _DO_JAVA_YNDEXING=&& $_JAVAC_RUN_HELPER($_JAVA_YNDEXING_CMD) && ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} kindex.tar .kzip ${output;hide;tared:"kindex.tar"}
  985. }
  986. when($ERROR_PRONE_VALUE) {
  987. PEERDIR+=$ERROR_PRONE_PEERDIR
  988. RUN_JAVAC_ARGS=--error-prone $ERROR_PRONE_RESOURCE/error_prone.jar
  989. }
  990. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "17") {
  991. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  992. JAVAC_OPTS+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  993. }
  994. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "20") {
  995. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  996. JAVAC_OPTS+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  997. }
  998. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "21") {
  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 == "22") {
  1003. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1004. JAVAC_OPTS+=$ERROR_PRONE_JDK16PLUS_ADD_OPENS
  1005. }
  1006. when($ERROR_PRONE_VALUE && $ERROR_PRONE_VERSION == "2.7.1") {
  1007. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_2_7_1_FORCED_OPTS
  1008. JAVAC_OPTS+=$ERROR_PRONE_2_7_1_FORCED_OPTS
  1009. }
  1010. when ($JAVA_ADD_DLLS_VALUE == "yes") {
  1011. CONSUME_NON_MANAGEABLE_PEERS=yes
  1012. _PACK_JNI=$_PACK_JNI_CMD
  1013. }
  1014. when ($LINT_LEVEL_VALUE != "none") {
  1015. _MAKE_JSTYLE_FILE_LIST= && ${WRITER_PY} --file ${output;noauto:"lint-java.srclst"} -m --ya-start-command-file $LINT_JAVA_SOURCES --ya-end-command-file
  1016. }
  1017. SET(MODULE_TYPE JAVA_LIBRARY)
  1018. ENABLE(YMAKE_JAVA_TEST)
  1019. _ADD_KOTLIN_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/all-kt-sources.txt REQUIREMENTS cpu:2)
  1020. _ADD_JAVA_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/lint-java.srclst::$(SOURCE_ROOT))
  1021. _ADD_CLASSPATH_CLASH_CHECK()
  1022. JAVA_MODULE()
  1023. }
  1024. # tag:java-specific
  1025. _SCRIPTGEN_FLAGS=
  1026. macro _GEN_JAVA_SCRIPT_IMPL(Out, Template, Props...) {
  1027. .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
  1028. }
  1029. # tag:java-specific
  1030. _GEN_USERSCRIPTS=
  1031. macro _ADD_GEN_JAVA_SCRIPT(Out, Template, Props...) {
  1032. SET_APPEND(_GEN_USERSCRIPTS && \$_GEN_JAVA_SCRIPT_IMPL($Out $Template $Props))
  1033. }
  1034. # tag:java-specific
  1035. _PACK_JDK=
  1036. # tag:java-specific
  1037. DO_GEN_JAVA_RUN_SH=
  1038. _SOURCE_JARS=
  1039. _SOURCE_JARS_CPLIST=
  1040. _GEN_JAVA_RUN_SH_OUTPUT=run.sh
  1041. when ($HOST_OS_WINDOWS == "yes") {
  1042. _GEN_JAVA_RUN_SH_OUTPUT=run.bat
  1043. }
  1044. 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}
  1045. 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}
  1046. 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}
  1047. 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
  1048. TAR_CLASSPATH= && $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} ${output;pre=$MODULE_PREFIX;suf=.tar:REALPRJNAME} ${cwd;pre=$BINDIR/:REALPRJNAME}
  1049. DO_TAR_CLASSPATH=
  1050. 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 ${kv;hide:"p JP"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  1051. # tag:java-specific
  1052. # UBERJAR program link command
  1053. LINK_UBERJAR_PROGRAM=${hide:JAVA_FAKEID} ${kv;hide:"p UJ"} ${MAKE_JAVA_CLASSPATH_FILE} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} $TARGET \
  1054. && $FS_TOOLS md ${BINDIR}/${REALPRJNAME} \
  1055. && $FS_TOOLS link_or_copy ${BINDIR}/${REALPRJNAME}.jar $TARGET \
  1056. && $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} \
  1057. $DO_TAR_CLASSPATH \
  1058. $_GEN_USERSCRIPTS \
  1059. $_PACK_JDK
  1060. # tag:java-specific
  1061. RUN_WITH_SOURCES=no
  1062. # 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
  1063. TARED_CLASSPATH=yes
  1064. _JAR_SRCS_CALLED=no
  1065. # tag:java-specific
  1066. macro _MARK_JAVA_PROG_WITH_SOURCES(Args...) {
  1067. ENABLE(_JAR_SRCS_CALLED)
  1068. }
  1069. # tag:java-specific
  1070. module _JAR_RUNNABLE: _COMPILABLE_JAR_BASE {
  1071. .FINAL_TARGET=yes
  1072. .CMD=LINK_JAR_PROGRAM
  1073. .SEM=IGNORED
  1074. .ALIASES=JAVA_SRCS=_MARK_JAVA_PROG_WITH_SOURCES GENERATE_SCRIPT=_YMAKE_GENERATE_SCRIPT
  1075. .ALLOWED=WITH_JDK
  1076. .PEERDIR_POLICY=as_build_from
  1077. MODULE_SUFFIX=.run.cp.jar
  1078. CONSUME_NON_MANAGEABLE_PEERS=yes
  1079. when ($RUN_WITH_SOURCES == "yes") {
  1080. _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}
  1081. _SOURCE_JARS_CPLIST=${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE}
  1082. }
  1083. when ($TARED_CLASSPATH == "yes") {
  1084. DO_TAR_CLASSPATH=$TAR_CLASSPATH
  1085. }
  1086. when ($DISABLE_SCRIPTGEN) {
  1087. DO_GEN_JAVA_RUN_SH=
  1088. }
  1089. otherwise {
  1090. DO_GEN_JAVA_RUN_SH=$GEN_JAVA_RUN_SH
  1091. PEERDIR+=build/platform/java/scriptgen
  1092. }
  1093. when ($MAKE_UBERJAR_VALUE == "yes") {
  1094. LINK_JAR_PROGRAM=$LINK_UBERJAR_PROGRAM
  1095. DYNAMIC_LINK=no
  1096. _SCRIPTGEN_FLAGS=-D IS_UBERJAR=yes
  1097. }
  1098. otherwise {
  1099. _SCRIPTGEN_FLAGS=-D IS_UBERJAR=no
  1100. }
  1101. CHECK_PROVIDES()
  1102. }
  1103. # tag:java-specific
  1104. 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} ${kv;hide:"p JT"}
  1105. YMAKE_JAVA_TEST=
  1106. module _JAR_TEST: _COMPILABLE_JAR_BASE {
  1107. .FINAL_TARGET=yes
  1108. .CMD=LINK_JAR_TEST
  1109. .DEFAULT_NAME_GENERATOR=FullPath
  1110. CONSUME_NON_MANAGEABLE_PEERS=yes
  1111. SET(MODULE_SUFFIX .test.cp.jar)
  1112. ENABLE(YMAKE_JAVA_TEST)
  1113. JAVA_TEST()
  1114. CHECK_PROVIDES()
  1115. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1116. }
  1117. # tag:java-specific
  1118. JAVA_SWIG_DELIM=JAVA_SWIG_DELIM
  1119. # tag:java-specific
  1120. JDK_REAL_VERSION=
  1121. JDK_VERSION=
  1122. when ($JDK_VERSION == "22") {
  1123. JDK_REAL_VERSION=22
  1124. }
  1125. elsewhen ($JDK_VERSION == "21") {
  1126. JDK_REAL_VERSION=21
  1127. }
  1128. elsewhen ($JDK_VERSION == "20") {
  1129. JDK_REAL_VERSION=20
  1130. }
  1131. elsewhen ($JDK_VERSION == "17") {
  1132. JDK_REAL_VERSION=17
  1133. }
  1134. elsewhen ($JDK_VERSION == "11") {
  1135. JDK_REAL_VERSION=11
  1136. }
  1137. elsewhen ($MAPSMOBI_BUILD_TARGET && $OS_ANDROID) {
  1138. JDK_REAL_VERSION=11
  1139. }
  1140. otherwise {
  1141. JDK_REAL_VERSION=17
  1142. }
  1143. # tag:java-specific
  1144. # remove extra peerdir to jdk11 after https://st.yandex-team.ru/DEVTOOLS-8851 is done
  1145. when ($USE_SYSTEM_JDK) {
  1146. JDK_RESOURCE_PEERDIR=
  1147. }
  1148. otherwise {
  1149. when ($JDK_REAL_VERSION == "22") {
  1150. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk22 build/platform/java/jdk/jdk17
  1151. }
  1152. when ($JDK_REAL_VERSION == "21") {
  1153. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk21 build/platform/java/jdk/jdk17
  1154. }
  1155. when ($JDK_REAL_VERSION == "20") {
  1156. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk20 build/platform/java/jdk/jdk17
  1157. }
  1158. when ($JDK_REAL_VERSION == "17") {
  1159. # need jdk11 for spare parts in "host" platform
  1160. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk17 build/platform/java/jdk/jdk11
  1161. }
  1162. when ($JDK_REAL_VERSION == "11") {
  1163. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk11 build/platform/java/jdk/jdk17
  1164. }
  1165. }
  1166. # tag:java-specific
  1167. when ($JDK_REAL_VERSION == "22") {
  1168. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar22
  1169. }
  1170. when ($JDK_REAL_VERSION == "21") {
  1171. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar21
  1172. }
  1173. when ($JDK_REAL_VERSION == "20") {
  1174. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar20
  1175. }
  1176. when ($JDK_REAL_VERSION == "17") {
  1177. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar17
  1178. }
  1179. when ($JDK_REAL_VERSION == "11") {
  1180. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar11
  1181. }
  1182. # tag:java-specific
  1183. JAVAC_OPTS=
  1184. when ($USE_SYSTEM_JDK) {
  1185. JDK_RESOURCE=$USE_SYSTEM_JDK
  1186. }
  1187. otherwise {
  1188. when ($JDK_REAL_VERSION == "22") {
  1189. JDK_RESOURCE=$JDK22_RESOURCE_GLOBAL
  1190. }
  1191. when ($JDK_REAL_VERSION == "21") {
  1192. JDK_RESOURCE=$JDK21_RESOURCE_GLOBAL
  1193. }
  1194. when ($JDK_REAL_VERSION == "20") {
  1195. JDK_RESOURCE=$JDK20_RESOURCE_GLOBAL
  1196. }
  1197. when ($JDK_REAL_VERSION == "17") {
  1198. JDK_RESOURCE=$JDK17_RESOURCE_GLOBAL
  1199. }
  1200. when ($JDK_REAL_VERSION == "11") {
  1201. JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL
  1202. }
  1203. }
  1204. # tag:java-specific
  1205. when (!$USE_SYSTEM_ERROR_PRONE) {
  1206. # Still not done: DTCC-667
  1207. when ($JDK_REAL_VERSION == "11") {
  1208. ERROR_PRONE_VERSION=2.7.1
  1209. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.7.1
  1210. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_7_1_RESOURCE_GLOBAL
  1211. }
  1212. elsewhen ($JDK_REAL_VERSION == "17") {
  1213. ERROR_PRONE_VERSION=2.10.0
  1214. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.10.0
  1215. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_10_0_RESOURCE_GLOBAL
  1216. }
  1217. elsewhen ($JDK_REAL_VERSION == "20") {
  1218. ERROR_PRONE_VERSION=2.18.0
  1219. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.18.0
  1220. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_18_0_RESOURCE_GLOBAL
  1221. }
  1222. elsewhen ($JDK_REAL_VERSION == "21") {
  1223. ERROR_PRONE_VERSION=2.30.0
  1224. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.30.0
  1225. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_30_0_RESOURCE_GLOBAL
  1226. }
  1227. elsewhen ($JDK_REAL_VERSION == "22") {
  1228. ERROR_PRONE_VERSION=2.30.0
  1229. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.30.0
  1230. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_30_0_RESOURCE_GLOBAL
  1231. }
  1232. otherwise {
  1233. ERROR_PRONE_VERSION=2.7.1
  1234. ERROR_PRONE_PEERDIR=build/platform/java/error_prone
  1235. ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL
  1236. }
  1237. }
  1238. otherwise {
  1239. ERROR_PRONE_VERSION=2.7.1
  1240. ERROR_PRONE_PEERDIR=build/platform/java/error_prone
  1241. ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL
  1242. }
  1243. # tag:java-specific
  1244. when ($USE_SYSTEM_UBERJAR) {
  1245. UBERJAR_RESOURCE=$USE_SYSTEM_UBERJAR
  1246. }
  1247. otherwise {
  1248. when ($JDK_REAL_VERSION == "22") {
  1249. UBERJAR_RESOURCE=$UBERJAR22_RESOURCE_GLOBAL
  1250. }
  1251. when ($JDK_REAL_VERSION == "21") {
  1252. UBERJAR_RESOURCE=$UBERJAR21_RESOURCE_GLOBAL
  1253. }
  1254. when ($JDK_REAL_VERSION == "20") {
  1255. UBERJAR_RESOURCE=$UBERJAR20_RESOURCE_GLOBAL
  1256. }
  1257. when ($JDK_REAL_VERSION == "17") {
  1258. UBERJAR_RESOURCE=$UBERJAR17_RESOURCE_GLOBAL
  1259. }
  1260. when ($JDK_REAL_VERSION == "11") {
  1261. UBERJAR_RESOURCE=$UBERJAR11_RESOURCE_GLOBAL
  1262. }
  1263. }
  1264. # tag:java-specific
  1265. when ($JDK_REAL_VERSION == "22") {
  1266. WITH_JDK_RESOURCE=$WITH_JDK22_RESOURCE_GLOBAL
  1267. }
  1268. when ($JDK_REAL_VERSION == "21") {
  1269. WITH_JDK_RESOURCE=$WITH_JDK21_RESOURCE_GLOBAL
  1270. }
  1271. when ($JDK_REAL_VERSION == "20") {
  1272. WITH_JDK_RESOURCE=$WITH_JDK20_RESOURCE_GLOBAL
  1273. }
  1274. when ($JDK_REAL_VERSION == "17") {
  1275. WITH_JDK_RESOURCE=$WITH_JDK17_RESOURCE_GLOBAL
  1276. }
  1277. when ($JDK_REAL_VERSION == "11") {
  1278. WITH_JDK_RESOURCE=$WITH_JDK11_RESOURCE_GLOBAL
  1279. }
  1280. # tag:java-specific
  1281. EXTERNAL_JAVA_JDK_RESOURCE=
  1282. EXTERNAL_JAVA_EXTRA_PEERDIR=
  1283. when ($USE_SYSTEM_JDK) {
  1284. EXTERNAL_JAVA_EXTRA_PEERDIR=
  1285. EXTERNAL_JAVA_JDK_RESOURCE=$USE_SYSTEM_JDK
  1286. }
  1287. elsewhen ($JDK_VERSION == "") {
  1288. EXTERNAL_JAVA_JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL
  1289. EXTERNAL_JAVA_EXTRA_PEERDIR=build/platform/java/jdk/jdk11
  1290. }
  1291. otherwise {
  1292. EXTERNAL_JAVA_JDK_RESOURCE=$JDK_RESOURCE
  1293. }
  1294. 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 ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} ${requirements;hide:"cpu:2"} ${hide;input:"build/scripts/java_command_file.py"} ${hide;input:"build/scripts/process_command_files.py"}
  1295. ARGS_DELIM="MACRO_CALLS_DELIM"
  1296. SYSTEM_PROPERTIES_VALUE=
  1297. ### @usage: SYSTEM_PROPERTIES([<Key Value>...] [<File Path>...])
  1298. ###
  1299. ### List of Key,Value pairs that will be available to test via System.getProperty().
  1300. ### FILE means that parst should be read from file specifies as Path.
  1301. ###
  1302. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  1303. macro SYSTEM_PROPERTIES(Args...) {
  1304. SET_APPEND(SYSTEM_PROPERTIES_VALUE $Args)
  1305. }
  1306. # tag:java-specific
  1307. JVM_ARGS_VALUE=-ea
  1308. ### @usage: JVM_ARGS(Args...)
  1309. ###
  1310. ### Arguments to run Java programs in tests.
  1311. ###
  1312. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  1313. macro JVM_ARGS(Args...) {
  1314. SET_APPEND(JVM_ARGS_VALUE $Args)
  1315. }
  1316. # tag:java-specific
  1317. CHECK_JAVA_DEPS_VALUE=
  1318. ### @usage: CHECK_JAVA_DEPS(<yes|no|strict>)
  1319. ###
  1320. ### Check for different classes with duplicate name in classpath.
  1321. ###
  1322. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  1323. macro CHECK_JAVA_DEPS(Arg) {
  1324. SET(CHECK_JAVA_DEPS_VALUE $Arg)
  1325. }
  1326. ERROR_PRONE_VALUE=
  1327. ### @usage: USE_ERROR_PRONE()
  1328. ###
  1329. ### Use errorprone instead of javac for .java compilation.
  1330. macro USE_ERROR_PRONE() {
  1331. SET(ERROR_PRONE_VALUE yes)
  1332. }
  1333. # tag:java-specific
  1334. MAKE_UBERJAR_VALUE=
  1335. ### @usage: UBERJAR()
  1336. ###
  1337. ### UBERJAR is a single all-in-one jar-archive that includes all its Java dependencies (reachable PEERDIR).
  1338. ### It also supports shading classes inside the archive by moving them to a different package (similar to the maven-shade-plugin).
  1339. ### Use UBERJAR inside JAVA_PROGRAM module.
  1340. ###
  1341. ### You can use the following macros to configure the archive:
  1342. ### 1. UBERJAR_HIDING_PREFIX prefix for classes to shade (classes remain in their packages by default)
  1343. ### 2. UBERJAR_HIDE_INCLUDE_PATTERN include classes matching this patterns to shading, include LDC mapping
  1344. ### 3. UBERJAR_HIDE_EXCLUDE_PATTERN exclude classes matching this patterns from shading (if enabled).
  1345. ### 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)
  1346. ### 5. UBERJAR_MANIFEST_TRANSFORMER_MAIN add ManifestResourceTransformer class to uberjar processing and specify main-class
  1347. ### 6. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE add ManifestResourceTransformer class to uberjar processing and specify some attribute
  1348. ### 7. UBERJAR_APPENDING_TRANSFORMER add AppendingTransformer class to uberjar processing
  1349. ### 8. UBERJAR_SERVICES_RESOURCE_TRANSFORMER add ServicesResourceTransformer class to uberjar processing
  1350. ###
  1351. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  1352. ###
  1353. ### @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)
  1354. macro UBERJAR() {
  1355. SET(MAKE_UBERJAR_VALUE yes)
  1356. DISABLE(PASS_PEERS)
  1357. }
  1358. # tag:java-specific
  1359. UBERJAR_PREFIX_VALUE=
  1360. UBERJAR_PREFIX_FLAG=
  1361. ### @usage: UBERJAR_HIDING_PREFIX(Arg)
  1362. ###
  1363. ### Set prefix for classes to shade. All classes in UBERJAR will be moved into package prefixed with Arg.
  1364. ### Classes remain in their packages by default.
  1365. ###
  1366. ### @see: [UBERJAR](#macro_UBERJAR)
  1367. macro UBERJAR_HIDING_PREFIX(Arg) {
  1368. SET(UBERJAR_PREFIX_VALUE $Arg)
  1369. SET(UBERJAR_PREFIX_FLAG ${pre=--shade-prefix :Arg})
  1370. }
  1371. # tag:java-specific
  1372. UBERJAR_HIDE_EXCLUDE_VALUE=
  1373. UBERJAR_HIDE_EXCLUDE_FLAGS=
  1374. ### @usage: UBERJAR_HIDE_EXCLUDE_PATTERN(Args...)
  1375. ###
  1376. ### Exclude classes matching this patterns from shading (if enabled).
  1377. ### Pattern may contain '*' and '**' globs.
  1378. ### Shading is enabled for UBERJAR program using UBERJAR_HIDING_PREFIX macro. If this macro is not specified all classes are shaded.
  1379. ###
  1380. ### @see: [UBERJAR](#macro_UBERJAR), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX)
  1381. macro UBERJAR_HIDE_EXCLUDE_PATTERN(Args...) {
  1382. SET_APPEND(UBERJAR_HIDE_EXCLUDE_VALUE $ARGS_DELIM $Args)
  1383. SET_APPEND(UBERJAR_HIDE_EXCLUDE_FLAGS ${pre=--shade-exclude :Args})
  1384. }
  1385. UBERJAR_HIDE_INCLUDE_VALUE=
  1386. UBERJAR_HIDE_INCLUDE_FLAGS=
  1387. ### @usage: UBERJAR_HIDE_INCLUDE_PATTERN(Args...)
  1388. ###
  1389. ### Include classes matching this patterns to shading, enabled LDC processing.
  1390. ### Pattern may contain '*' and '**' globs.
  1391. ### Shading is enabled for UBERJAR program using UBERJAR_HIDING_PREFIX macro. If this macro is not specified all classes are shaded.
  1392. ###
  1393. ### @see: [UBERJAR](#macro_UBERJAR), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX)
  1394. macro UBERJAR_HIDE_INCLUDE_PATTERN(Args...) {
  1395. SET_APPEND(UBERJAR_HIDE_INCLUDE_VALUE $ARGS_DELIM $Args)
  1396. SET_APPEND(UBERJAR_HIDE_INCLUDE_FLAGS ${pre=--shade-include :Args})
  1397. }
  1398. # tag:java-specific
  1399. UBERJAR_PATH_EXCLUDES=
  1400. UBERJAR_PATH_EXCLUDE_VALUE=
  1401. ### @usage: UBERJAR_PATH_EXCLUDE_PREFIX(Args...)
  1402. ###
  1403. ### Exclude classes matching this patterns from UBERJAR.
  1404. ### By default all dependencies of UBERJAR program will lend in a .jar archive.
  1405. ###
  1406. ### @see: [UBERJAR](#macro_UBERJAR)
  1407. macro UBERJAR_PATH_EXCLUDE_PREFIX(Args...) {
  1408. SET_APPEND(UBERJAR_PATH_EXCLUDE_VALUE $ARGS_DELIM $Args)
  1409. SET_APPEND(UBERJAR_PATH_EXCLUDES ${pre=--uber-exclude :Args})
  1410. }
  1411. # tag:java-specific
  1412. UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE=
  1413. UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG=
  1414. ### @usage: UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main)
  1415. ###
  1416. ### Transform manifest.mf for UBERJAR() java programs, set main-class attribute
  1417. ###
  1418. ### @see: [UBERJAR](#macro_UBERJAR)
  1419. macro UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main) {
  1420. SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE $Main)
  1421. SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG --manifest-main $Main)
  1422. }
  1423. # tag:java-specific
  1424. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE=
  1425. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS=
  1426. ### @usage: UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Value)
  1427. ###
  1428. ### Transform manifest.mf for UBERJAR() java programs, set attribute
  1429. ###
  1430. ### @see: [UBERJAR](#macro_UBERJAR)
  1431. macro UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Values...) {
  1432. SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE $ARGS_DELIM $Key : $Values)
  1433. SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS --manifest-attribute ${Key}:'${Values}')
  1434. }
  1435. # tag:java-specific
  1436. UBERJAR_APPENDING_TRANSFORMER_VALUE=
  1437. UBERJAR_APPENDING_TRANSFORMER_FLAGS=
  1438. ### @usage: UBERJAR_APPENDING_TRANSFORMER(Resource)
  1439. ###
  1440. ### Add AppendingTransformer for UBERJAR() java programs
  1441. ###
  1442. ### Parameters:
  1443. ### - Resource - Resource name
  1444. ###
  1445. ### @see: [UBERJAR](#macro_UBERJAR)
  1446. macro UBERJAR_APPENDING_TRANSFORMER(Resources...) {
  1447. SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_VALUE $ARGS_DELIM $Resources)
  1448. SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_FLAGS ${pre=--append-transformer :Resources})
  1449. }
  1450. # tag:java-specific
  1451. UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE=
  1452. UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG=
  1453. ### @usage: UBERJAR_SERVICES_RESOURCE_TRANSFORMER()
  1454. ###
  1455. ### Add ServicesResourceTransformer for UBERJAR() java programs
  1456. ###
  1457. ### @see: [UBERJAR](#macro_UBERJAR)
  1458. macro UBERJAR_SERVICES_RESOURCE_TRANSFORMER() {
  1459. SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE yes)
  1460. SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG --service-transformer)
  1461. }
  1462. # tag:idea-specific
  1463. IDEA_EXCLUDE_DIRS_VALUE=
  1464. ### @usage: IDEA_EXCLUDE_DIRS(<excluded dirs>)
  1465. ###
  1466. ### Exclude specified directories from an idea project generated by ya ide idea
  1467. ### Have no effect on regular build.
  1468. macro IDEA_EXCLUDE_DIRS(Args...) {
  1469. SET_APPEND(IDEA_EXCLUDE_DIRS_VALUE $Args)
  1470. }
  1471. # tag:idea-specific
  1472. IDEA_RESOURCE_DIRS_VALUE=
  1473. ### @usage: IDEA_RESOURCE_DIRS(<additional dirs>)
  1474. ###
  1475. ### Set specified resource directories in an idea project generated by ya ide idea
  1476. ### Have no effect on regular build.
  1477. macro IDEA_RESOURCE_DIRS(Args...) {
  1478. SET_APPEND(IDEA_RESOURCE_DIRS_VALUE $Args)
  1479. }
  1480. # tag:idea-specific
  1481. IDEA_MODULE_NAME_VALUE=
  1482. ### @usage: IDEA_MODULE_NAME(module_name)
  1483. ###
  1484. ### Set module name in an idea project generated by ya ide idea
  1485. ### Have no effect on regular build.
  1486. macro IDEA_MODULE_NAME(Name) {
  1487. SET(IDEA_MODULE_NAME_VALUE $Name)
  1488. }
  1489. # tag:java-specific
  1490. JAVAC_FLAGS_VALUE=
  1491. _JAVAC_SEM=
  1492. ### @usage: JAVAC_FLAGS(Args...)
  1493. ###
  1494. ### Set additional Java compilation flags.
  1495. macro JAVAC_FLAGS(Args...) {
  1496. SET_APPEND(JAVAC_OPTS $Args)
  1497. SET_APPEND(JAVAC_FLAGS_VALUE $ARGS_DELIM $Args)
  1498. SET_APPEND(_JAVAC_SEM && javac-flags $Args)
  1499. }
  1500. # tag:java-specific
  1501. ENABLE_PREVIEW_VALUE=
  1502. _ENABLE_PREVIEW_SEM=
  1503. ### @usage: ENABLE_PREVIEW()
  1504. ###
  1505. ### Enable java preview features.
  1506. macro ENABLE_PREVIEW() {
  1507. SET_APPEND(JVM_ARGS_VALUE --enable-preview)
  1508. SET_APPEND(JAVAC_OPTS --enable-preview --release $JDK_REAL_VERSION)
  1509. SET_APPEND(JAVAC_FLAGS_VALUE --enable-preview --release $JDK_REAL_VERSION)
  1510. SET(ENABLE_PREVIEW_VALUE yes)
  1511. SET(_ENABLE_PREVIEW_SEM && enable_preview)
  1512. }
  1513. # tag:java-specific
  1514. SAVE_JAVAC_GENERATED_SRCS=
  1515. SAVE_JAVAC_GENERATED_SRCS_DIR=
  1516. SAVE_JAVAC_GENERATED_SRCS_TAR=
  1517. when ($SAVE_JAVAC_GENERATED_SRCS) {
  1518. SAVE_JAVAC_GENERATED_SRCS_DIR=${BINDIR}/__javac_generated_srcs__
  1519. SAVE_JAVAC_GENERATED_SRCS_TAR=${BINDIR}/javac_generated.tar
  1520. JAVAC_FLAGS_VALUE+=-s $SAVE_JAVAC_GENERATED_SRCS_DIR
  1521. }
  1522. # tag:java-specific
  1523. # TODO: MAVEN_GROUP_ID_VALUE is only used by jbuild remove it after YMAKE-45 and YMAKE-46
  1524. MAVEN_GROUP_ID_VALUE=
  1525. MAVEN_EXPORT_GROUP_ID=ru.yandex
  1526. ### @usage: MAVEN_GROUP_ID(group_id_for_maven_export)
  1527. ###
  1528. ### Set maven export group id for JAVA_PROGRAM() and JAVA_LIBRARY().
  1529. ### Have no effect on regular build.
  1530. macro MAVEN_GROUP_ID(Arg, VERSION="no") {
  1531. SET(MAVEN_GROUP_ID_VALUE $Arg)
  1532. SET(MAVEN_EXPORT_GROUP_ID $Arg)
  1533. SET(PUBLISH_MAVEN_VERSION $VERSION)
  1534. }
  1535. # tag:java-specific
  1536. ANNOTATION_PROCESSOR_VALUE=
  1537. ### @usage: ANNOTATION_PROCESSOR(processors...)
  1538. ###
  1539. ### The macro is in development.
  1540. ### Used to specify annotation processors to build JAVA_PROGRAM() and JAVA_LIBRARY().
  1541. macro ANNOTATION_PROCESSOR(Args...) {
  1542. SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Args)
  1543. }
  1544. EXCLUDE_VALUE=
  1545. ### EXCLUDE(prefixes)
  1546. ###
  1547. ### Specifies which libraries should be excluded from the classpath.
  1548. macro EXCLUDE(Args...) {
  1549. SET_APPEND(EXCLUDE_VALUE $ARGS_DELIM $Args)
  1550. }
  1551. # tag:java-specific
  1552. JAVA_SRCS_VALUE=
  1553. ### Fill JAVA_SRCS_VALUE for ya ide idea, skip SKIP_CHECK_SRCDIR option
  1554. macro _IDEA_JAVA_SRCS_VALUE(RESOURCES?"RESOURCES":"", SKIP_CHECK_SRCDIR?"SKIP_CHECK_SRCDIR":"", Args...) {
  1555. # RESOURCES must be at first position, else ya ide idea will fault
  1556. SET_APPEND(JAVA_SRCS_VALUE $ARGS_DELIM $RESOURCES $Args)
  1557. }
  1558. ### @usage: JAVA_SRCS(srcs)
  1559. ###
  1560. ### Specify java source files and resources. A macro can be contained in any of four java modules.
  1561. ### Keywords:
  1562. ### 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.
  1563. ### 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.
  1564. ###
  1565. ### @example:
  1566. ### - example/ya.make
  1567. ###
  1568. ### JAVA_PROGRAM()
  1569. ### JAVA_SRCS(SRCDIR src/main/java **/*)
  1570. ### END()
  1571. ###
  1572. ### - example/src/main/java/ru/yandex/example/HelloWorld.java
  1573. ###
  1574. ### package ru.yandex.example;
  1575. ### public class HelloWorld {
  1576. ### public static void main(String[] args) {
  1577. ### System.out.println("Hello, World!");
  1578. ### }
  1579. ### }
  1580. ###
  1581. ### Documentation: https://wiki.yandex-team.ru/yatool/java/#javasrcs
  1582. macro JAVA_SRCS(Args...) {
  1583. # TODO Use FULL_JAVA_SRCS
  1584. _IDEA_JAVA_SRCS_VALUE($Args)
  1585. # Fill semantic for non-standard sources/resources
  1586. _SEM_JAR_SOURCE_SET($Args)
  1587. }
  1588. # tag:java-specific
  1589. JAVA_ADD_DLLS_VALUE=no
  1590. macro ADD_DLLS_TO_JAR() {
  1591. SET(JAVA_ADD_DLLS_VALUE yes)
  1592. }
  1593. # tag:java-specific
  1594. MANAGED_PEERS=
  1595. MANAGED_PEERS_CLOSURE=
  1596. MANAGEABLE_PEERS_ROOTS=contrib/java
  1597. HAS_MANAGEABLE_PEERS=no
  1598. PROPAGATES_MANAGEABLE_PEERS=no
  1599. # All items of this list must be PEERS, GHOST PEERS or TOOLS of the test module or module itself.
  1600. # All items of this list must has at least one of HAS_MANAGEABLE_PEERS or PROPAGATES_MANAGEABLE_PEERS flags set yes.
  1601. # This variable is used by JUnit tests but not TestNG.
  1602. TEST_CLASSPATH_VALUE=
  1603. # Calculated and replaced by ymake can be used in DART DATA
  1604. TEST_CLASSPATH_MANAGED=
  1605. # tag:java-specific
  1606. DEPENDENCY_MANAGEMENT_VALUE=
  1607. ### @usage: DEPENDENCY_MANAGEMENT(path/to/lib1 path/to/lib2 ...)
  1608. ###
  1609. ### 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.
  1610. ###
  1611. ### For example, if the module has PEERDIR (contrib/java/junit/junit), and
  1612. ### 1. specifies DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12),
  1613. ### the PEERDIR is automatically replaced by contrib/java/junit/junit/4.12;
  1614. ### 2. doesn't specify DEPENDENCY_MANAGEMENT, PEERDIR automatically replaced
  1615. ### with the default from contrib/java/junit/junit/ya.make.
  1616. ### These defaults are always there and are supported by maven-import, which puts
  1617. ### there the maximum version available in contrib/java.
  1618. ###
  1619. ### 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.
  1620. ###
  1621. ### If some module has both DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12) and PERDIR(contrib/java/junit/junit/4.11), the PEERDIR wins.
  1622. ###
  1623. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  1624. macro DEPENDENCY_MANAGEMENT(Args...) {
  1625. SET_APPEND(DEPENDENCY_MANAGEMENT_VALUE $ARGS_DELIM $Args)
  1626. _GHOST_PEERDIR($Args)
  1627. }
  1628. # tag:java-specific
  1629. WITH_JDK_VALUE=
  1630. ### @usage: WITH_JDK()
  1631. ###
  1632. ### Add directory with JDK to JAVA_PROGRAM output
  1633. macro WITH_JDK() {
  1634. when ($REALPRJNAME == "jdk") {
  1635. _OK=no
  1636. }
  1637. otherwise {
  1638. _PACK_JDK= && ${YMAKE_PYTHON} ${input:"build/scripts/tar_directory.py"} ${output;tared:"jdk.tar"} $WITH_JDK_RESOURCE $WITH_JDK_RESOURCE
  1639. WITH_JDK_VALUE=yes
  1640. }
  1641. 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.)
  1642. }
  1643. # tag:kotlin-specific
  1644. WITH_KOTLIN_VALUE=
  1645. _WITH_KOTLIN_SEM=
  1646. _KOTLIN_VERSION_SEM=
  1647. ### @usage: WITH_KOTLIN()
  1648. ###
  1649. ### Compile kotlin source code in this java module
  1650. macro WITH_KOTLIN() {
  1651. SET(WITH_KOTLIN_VALUE yes)
  1652. SET(_WITH_KOTLIN_SEM && with_kotlin)
  1653. SET(_KOTLIN_VERSION_SEM && kotlin_version ${_KOTLIN_VERSION})
  1654. }
  1655. # tag:kotlin-specific
  1656. WITH_KAPT_VALUE=
  1657. ### @usage: WITH_KAPT()
  1658. ###
  1659. ### Use kapt for as annotation processor
  1660. macro WITH_KAPT() {
  1661. SET(WITH_KAPT_VALUE yes)
  1662. }
  1663. # tag:java-specific
  1664. WITH_GROOVY_VALUE=
  1665. ### @usage: WITH_GROOVY()
  1666. ###
  1667. ### Compile groovy source code in this java module
  1668. macro WITH_GROOVY() {
  1669. SET(WITH_GROOVY_VALUE yes)
  1670. }
  1671. # tag:kotlin-specific
  1672. KOTLINC_FLAGS_VALUE=-Xjvm-default=all
  1673. ### @usage: KOTLINC_FLAGS(-flags)
  1674. ###
  1675. ### Set additional Kotlin compilation flags.
  1676. macro KOTLINC_FLAGS(Args...) {
  1677. SET_APPEND(KOTLINC_OPTS_VALUE $Args)
  1678. }
  1679. # tag:kotlin-sppecific
  1680. WITH_KOTLINC_PLUGIN_ALLOPEN=
  1681. _WITH_KOTLINC_PLUGIN_ALLOPEN_SEM=
  1682. macro _WITH_KOTLINC_ALLOPEN(Options...) {
  1683. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.allopen\::Options})
  1684. SET(WITH_KOTLINC_PLUGIN_ALLOPEN yes)
  1685. SET(_WITH_KOTLINC_ALLOPEN_SEM && with_kotlinc_plugin_allopen)
  1686. }
  1687. # tag:kotlin-specific
  1688. ### @usage: WITH_KOTLINC_ALLOPEN(-flags)
  1689. ###
  1690. ### Enable allopen kotlin compiler plugin https://kotlinlang.org/docs/all-open-plugin.html
  1691. macro WITH_KOTLINC_ALLOPEN(HEAD, TAIL...) {
  1692. _WITH_KOTLINC_ALLOPEN($HEAD $TAIL)
  1693. }
  1694. # tag:kotlin-specific
  1695. WITH_KOTLINC_PLUGIN_LOMBOK=
  1696. _WITH_KOTLINC_PLUGIN_LOMBOK_SEM=
  1697. ### @usage: WITH_KOTLINC_LOMBOK(-flags)
  1698. ###
  1699. ### Enable lombok kotlin compiler plugin https://kotlinlang.org/docs/lombok.html
  1700. macro WITH_KOTLINC_LOMBOK(Options...) {
  1701. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.lombok\::Options})
  1702. SET(WITH_KOTLINC_PLUGIN_LOMBOK yes)
  1703. SET(_WITH_KOTLINC_PLUGIN_LOMBOK_SEM && with_kotlinc_plugin_lombok)
  1704. }
  1705. # tag:kotlin-specific
  1706. WITH_KOTLINC_PLUGIN_NOARG=
  1707. _WITH_KOTLINC_PLUGIN_NOARG_SEM=
  1708. ### @usage: WITH_KOTLINC_NOARG(-flags)
  1709. ###
  1710. ### Enable noarg kotlin compiler plugin https://kotlinlang.org/docs/no-arg-plugin.html
  1711. macro WITH_KOTLINC_NOARG(Options...) {
  1712. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.noarg\::Options})
  1713. SET(WITH_KOTLINC_PLUGIN_NOARG yes)
  1714. SET(_WITH_KOTLINC_PLUGIN_NOARG_SEM && with_kotlinc_plugin_noarg)
  1715. }
  1716. # tag:kotlin-specific
  1717. WITH_KOTLINC_PLUGIN_SERIALIZATION=
  1718. _WITH_KOTLINC_PLUGIN_SERIALIZATION_SEM=
  1719. ### @usage: WITH_KOTLINC_SERIALIZATION()
  1720. ###
  1721. ### Enable serialization kotlin compiler plugin https://kotlinlang.org/docs/serialization.html
  1722. macro WITH_KOTLINC_SERIALIZATION() {
  1723. SET(WITH_KOTLINC_PLUGIN_SERIALIZATION yes)
  1724. SET(_WITH_KOTLINC_PLUGIN_SERIALIZATION_SEM && with_kotlinc_plugin_serialization)
  1725. }
  1726. # tag:kotlin-specific
  1727. ### Also search for _KAPT_OPTS and change version there
  1728. _KOTLIN_VERSION=1.9.24
  1729. KOTLIN_VERSION=1.9.24
  1730. KOTLIN_BOM_FILE=${ARCADIA_ROOT}/contrib/java/org/jetbrains/kotlin/kotlin-bom/1.9.24/ya.dependency_management.inc
  1731. GROOVY_VERSION=3.0.5
  1732. _KOTLIN_SEM= \
  1733. ${_WITH_KOTLIN_SEM} \
  1734. ${_KOTLIN_VERSION_SEM} \
  1735. ${_WITH_KOTLINC_PLUGIN_ALLOPEN_SEM} \
  1736. ${_WITH_KOTLINC_PLUGIN_LOMBOK_SEM} \
  1737. ${_WITH_KOTLINC_PLUGIN_NOARG_SEM} \
  1738. ${_WITH_KOTLINC_PLUGIN_SERIALIZATION_SEM}
  1739. _JAVA_PROTO_GRPC_SEM=
  1740. when ($_GRPC_ENABLED == "yes") {
  1741. _JAVA_PROTO_GRPC_SEM= && proto_grpc && proto_grpc_version ${JAVA_GRPC_VERSION}
  1742. }
  1743. _JAVA_PROTO_NAMESPACE_SEM=
  1744. when ($PROTO_NAMESPACE != "") {
  1745. _JAVA_PROTO_NAMESPACE_SEM= && proto_namespace $PROTO_NAMESPACE
  1746. }
  1747. _JAVA_PROTO_SEM= \
  1748. ${_JAVA_PROTO_NAMESPACE_SEM} \
  1749. && proto_compiler_version ${JAVA_PROTO_COMPILER_VERSION} \
  1750. && proto_runtime_version ${JAVA_PROTO_RUNTIME_VERSION} \
  1751. && proto_common_version ${JAVA_PROTO_COMMON_VERSION} \
  1752. ${_JAVA_PROTO_GRPC_SEM}
  1753. # tag:java-specific
  1754. DIRECT_DEPS_ONLY_VALUE=
  1755. ### @usage: DIRECT_DEPS_ONLY
  1756. ###
  1757. ### Add direct PEERDIR's only in java compile classpath
  1758. macro DIRECT_DEPS_ONLY() {
  1759. SET(DIRECT_DEPS_ONLY_VALUE yes)
  1760. }
  1761. # tag:java-specific
  1762. JAVA_EXTERNAL_DEPENDENCIES_VALUE=
  1763. ### @usage: JAVA_EXTERNAL_DEPENDENCIES(file1 file2 ...)
  1764. ###
  1765. ### Add non-source java external build dependency (like lombok config file)
  1766. macro JAVA_EXTERNAL_DEPENDENCIES(Args...) {
  1767. SET_APPEND(JAVA_EXTERNAL_DEPENDENCIES_VALUE $Args)
  1768. }
  1769. # tag:java-specific
  1770. JAVA_CLASSPATH_CMD_TYPE_VALUE=
  1771. # tag:java-specific
  1772. ### @usage:TEST_JAVA_CLASSPATH_CMD_TYPE(Type)
  1773. ### Available types: MANIFEST(default), COMMAND_FILE, LIST
  1774. ### Method for passing a classpath value to a java command line
  1775. ### MANIFEST via empty jar file with manifest that contains Class-Path attribute
  1776. ### COMMAND_FILE via @command_file
  1777. ### LIST via flat args
  1778. macro TEST_JAVA_CLASSPATH_CMD_TYPE(Type) {
  1779. SET(JAVA_CLASSPATH_CMD_TYPE_VALUE $Type)
  1780. }
  1781. # tag:java-specific
  1782. IGNORE_JAVA_DEPENDENCIES_CONFIGURATION=no
  1783. JAVA_DEPENDENCIES_CONFIGURATION_VALUE=
  1784. # tag:java-specific
  1785. ### @usage JAVA_DEPENDENCIES_CONFIGURATION(Vetos...)
  1786. ### Validate contrib/java dependencies
  1787. ### Valid arguments
  1788. ### FORBID_DIRECT_PEERDIRS - fail when module have direct PEERDIR (with version) (non-transitive)
  1789. ### FORBID_CONFLICT - fail when module have resolved without DEPENDENCY_MANAGEMENT version conflict (transitive)
  1790. ### FORBID_CONFLICT_DM - fail when module have resolved with DEPENDENCY_MANAGEMENT version conflict (transitive)
  1791. ### FORBID_CONFLICT_DM_RECENT - like FORBID_CONFLICT_DM but fail only when dependency have more recent version than specified in DEPENDENCY_MANAGEMENT
  1792. ### REQUIRE_DM - all dependencies must be specified in DEPENDENCY_MANAGEMENT (transitive)
  1793. macro JAVA_DEPENDENCIES_CONFIGURATION(Args...) {
  1794. SET_APPEND(JAVA_DEPENDENCIES_CONFIGURATION_VALUE $Args)
  1795. }
  1796. # tag:java-specific
  1797. # TODO(DEVTOOLS-6901): remove this variable when there are no more references to it in jbuild
  1798. JAVA_FORBIDDEN_LIBRARIES_VALUE=
  1799. # tag:java-specific
  1800. JAR_INCLUDE_FILTER_VALUE=
  1801. JAR_EXCLUDE_FILTER_VALUE=
  1802. # tag:java-specific
  1803. ### @usage:JAR_INCLUDE(Filters...)
  1804. ### Filter .jar file content: keep only matched files
  1805. ### * and ** patterns are supported (like JAVA_SRCS)
  1806. macro JAR_INCLUDE(Filters...) {
  1807. SET_APPEND(JAR_INCLUDE_FILTER_VALUE $Filters)
  1808. }
  1809. # tag:java-specific
  1810. ### @usage:JAR_EXCLUDE(Filters...)
  1811. ### Filter .jar file content: remove matched files
  1812. ### * and ** patterns are supported (like JAVA_SRCS)
  1813. macro JAR_EXCLUDE(Filters...) {
  1814. SET_APPEND(JAR_EXCLUDE_FILTER_VALUE $Filters)
  1815. }
  1816. # tag:java-specific
  1817. _COMPILE_JSRC=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/compile_jsrc.py"} --input $AUTO_INPUT --output $TARGET --prefix $BINDIR ${kv;hide:"p JC"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  1818. # tag:java-specific
  1819. COMPILE_JSRC_MF=$_COMPILE_JSRC && $GENERATE_MF
  1820. # tag:java-specific tag:internal
  1821. ### @usage: JSRC_LIBRARY() # internal
  1822. module JSRC_LIBRARY: _BARE_UNIT {
  1823. .CMD=COMPILE_JSRC_MF
  1824. .EXTS=.java
  1825. .PEERDIR_POLICY=as_include
  1826. .FINAL_TARGET=no
  1827. .ALIASES=SRCS=FILES
  1828. PEERDIR_TAGS=JAVA JAVA_PROTO JAVA_FBS JAVA_IDL
  1829. MODULE_TYPE=LIBRARY
  1830. SET(MODULE_SUFFIX .jsrc)
  1831. SET(DONT_RESOLVE_INCLUDES yes)
  1832. SET(NEED_PLATFORM_PEERDIRS no)
  1833. SET(MODULE_LANG JAVA)
  1834. NO_RUNTIME()
  1835. }
  1836. # tag:java-specific
  1837. JAVA_PROGRAM_CP_USE_COMMAND_FILE=yes
  1838. when ($JDK_REAL_VERSION == "8") {
  1839. JAVA_PROGRAM_CP_USE_COMMAND_FILE=no
  1840. }
  1841. # tag:kotlin-specific
  1842. KOTLIN_JVM_TARGET=
  1843. when ($JDK_REAL_VERSION == "8") {
  1844. KOTLIN_JVM_TARGET=1.8
  1845. }
  1846. elsewhen ($JDK_REAL_VERSION == "22") {
  1847. # remove when kotlin starts supporting jdk21 bytecode
  1848. # see also devtools/ya/jbuild/gen/actions/idea.py
  1849. KOTLIN_JVM_TARGET=21
  1850. }
  1851. otherwise {
  1852. KOTLIN_JVM_TARGET=$JDK_REAL_VERSION
  1853. }
  1854. # tag:java-specific
  1855. ### @usage: JDK_VERSION(Version)
  1856. ###
  1857. ### Specify JDK version for module
  1858. macro JDK_VERSION(Arg) {
  1859. .SEM=required_jdk $Arg ${output;hide:"JdkVersionFakeProp.java"}
  1860. SET(JDK_REAL_VERSION $Arg)
  1861. _JDK_VERSION_MACRO_CHECK($Arg)
  1862. }
  1863. # tag:java-specific
  1864. ### @usage: DEFAULT_JDK_VERSION(Version)
  1865. ###
  1866. ### Specify JDK version for module, can be overridden by setting the JDK_VERSION variable
  1867. macro DEFAULT_JDK_VERSION(Arg) {
  1868. _SET_FIRST_VALUE(_JDK_VERSION $JDK_VERSION $Arg)
  1869. JDK_VERSION($_JDK_VERSION)
  1870. }
  1871. # tag:java-specific
  1872. # local jdk and tools
  1873. USE_SYSTEM_JDK=
  1874. USE_SYSTEM_UBERJAR=
  1875. USE_SYSTEM_ERROR_PRONE=
  1876. # tag:kotlin-specific
  1877. _USE_KTLINT_OLD=no
  1878. # tag:kotlin-specific
  1879. ### @usage: USE_KTLINT_OLD()
  1880. ### Marks that need use the old version of ktlint
  1881. macro USE_KTLINT_OLD() {
  1882. ENABLE(_USE_KTLINT_OLD)
  1883. }
  1884. # tag:kotlin-specific
  1885. _KTLINT_BASELINE_FILE=
  1886. # tag:kotlin-specific
  1887. ### @usage: #deprecated KTLINT_BASELINE_FILE(ktlint-baseline.xml "https://st.yandex-team.ru/REMOVE-BASELINE-1")
  1888. ### Path to baseline file for ktlint test and ticket to fix all ktlint warnings in file and then remove it
  1889. macro KTLINT_BASELINE_FILE(File, Ticket) {
  1890. SET(_KTLINT_BASELINE_FILE $File)
  1891. }
  1892. # tag:kotlin-specific
  1893. _WITH_YA_1931=no
  1894. # tag:kotlin-specific
  1895. ### @usage: WITH_YA_1931()
  1896. ### Interim macro to temporarily remove ALL_SRCDIRS from being added to ktlint test sources.
  1897. macro WITH_YA_1931() {
  1898. 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.)
  1899. ENABLE(_WITH_YA_1931)
  1900. }