{"id":177,"date":"2017-07-05T09:49:03","date_gmt":"2017-07-05T17:49:03","guid":{"rendered":"http:\/\/www.gauntletwizard.net\/wordpress\/?p=177"},"modified":"2017-07-05T09:49:03","modified_gmt":"2017-07-05T17:49:03","slug":"migrating-a-sbt-project-to-bazel","status":"publish","type":"post","link":"https:\/\/www.gauntletwizard.net\/wordpress\/?p=177","title":{"rendered":"Migrating a SBT project to Bazel."},"content":{"rendered":"<p>I&#8217;ve been working today on migrating a SBT project to Bazel. I&#8217;ve taken a few wrong turns, and I&#8217;ll document them later, but this will be my working doc and I&#8217;ll add some failures to the end.<\/p>\n<p>Two major components &#8211; Bazel&#8217;s <a href=\"https:\/\/bazel.build\/versions\/master\/docs\/external.html#generate-a-workspace-file\">generate_workspace<\/a> tool, and SBT&#8217;s <a href=\"http:\/\/www.scala-sbt.org\/0.12.4\/docs\/Detailed-Topics\/Publishing.html\">make-pom<\/a> command. You&#8217;ll create a POM file with the dependencies and repos.<br \/>\n<code><br \/>\n ted:growth$ sbt make-pom<br \/>\n[warn] Executing in batch mode.<br \/>\n[warn]   For better performance, hit [ENTER] to switch to interactive mode, or<br \/>\n[warn]   consider launching sbt without any commands, or explicitly passing 'shell'<br \/>\n[info] Loading project definition from \/Users\/ted\/dev\/growth\/project<br \/>\nSLF4J: Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".<br \/>\nSLF4J: Defaulting to no-operation (NOP) logger implementation<br \/>\nSLF4J: See http:\/\/www.slf4j.org\/codes.html#StaticLoggerBinder for further details.<br \/>\n[info] Set current project to growth (in build file:\/Users\/ted\/dev\/growth\/)<br \/>\n[warn] Multiple resolvers having different access mechanism configured with same name 'Artifactory-lib'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`).<br \/>\n[info] Wrote \/Users\/ted\/dev\/growth\/target\/scala-2.11\/growth_2.11-resurrector-9449dfb1de3b816c5fd74c4948f16496b38952ab.pom<br \/>\n[success] Total time: 5 s, completed Jun 14, 2017 4:00:17 PM<br \/>\n<\/code><br \/>\nThis generates a pom file, but not exactly as generate_workspace wants it. It requires a directory with a pom.xml, so go ahead and turn that into one by making a tempdir and copying the file to it <code>TMPDIR=\"$(mktemp -d)\"; cp \/Users\/ted\/dev\/growth\/target\/scala-2.11\/growth_2.11-resurrector-9449dfb1de3b816c5fd74c4948f16496b38952ab.pom \"${TMPDIR}\/pom.xml\"<\/code><\/p>\n<p>Next, build <\/p>\n<p>So, on to the failures:<br \/>\nI initially tried to do my own workspace code generation. I took the output of <code>sbt libraryDependencies<\/code> and turned it into mvn_jar stanzas via script. This didn&#8217;t work, for the simple reason that I wasn&#8217;t doing it transitively, they mention that in the generate_workspace docs. I also tried specifying that list of deps as a big list of &#8211;archive stanzas; That turned out to be a mistake, mostly because of alternate repos. I also had to clean out a broken SBT set of repos; bazel does not play well with repeated repo definitions, while SBT is happy to ignore them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been working today on migrating a SBT project to Bazel. I&#8217;ve taken a few wrong turns, and I&#8217;ll document them later, but this will be my working doc and I&#8217;ll add some failures to the end. Two major components &#8211; Bazel&#8217;s generate_workspace tool, and SBT&#8217;s make-pom command. You&#8217;ll create a POM file with the &hellip; <a href=\"https:\/\/www.gauntletwizard.net\/wordpress\/?p=177\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Migrating a SBT project to Bazel.<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/177"}],"collection":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=177"}],"version-history":[{"count":4,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":184,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions\/184"}],"wp:attachment":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}