java.conf 90 KB

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