buck icon indicating copy to clipboard operation
buck copied to clipboard

buck publish: allow to publish to local repositories

Open davido opened this issue 10 years ago • 7 comments

Currently only remote and central repositories can be specified with publish command. So the Publisher needs to be taught how to handle file: URIs:

  $ buck publish --remote-repo file:///home/johndoe/.m2/repository //:foo

or if it is safe to assume that the local repository is always located in the same directory: $HOME/.m2/repository, then it could be sufficient to just say this:

$ buck publish --local //:foo

davido avatar Dec 07 '15 22:12 davido

Has this been implemented?

victorssilva avatar Nov 03 '16 15:11 victorssilva

Nope.

davido avatar Nov 03 '16 16:11 davido

There is a workaround, though, to use Bucklets.

davido avatar Nov 03 '16 16:11 davido

Any pointers on how to use it? There isn't a readme there.

victorssilva avatar Nov 03 '16 17:11 victorssilva

Check https://github.com/GerritCodeReview/gitiles where it's used (clone recursively).

Then check this rule in main BUCK file:

maven_package(
  repository = 'gerrit-maven-repository',
  url = 'gs://gerrit-maven',
  version = GITILES_VERSION,
  group = 'com.google.gitiles',
  jar = {
    'blame-cache': '//blame-cache:lib',
    'gitiles-servlet': '//gitiles-servlet:servlet',
  },
  src = {
    'blame-cache': '//blame-cache:src',
    'gitiles-servlet': '//gitiles-servlet:src',
  },
  doc = {
    'blame-cache': '//blame-cache:javadoc',
    'gitiles-servlet': '//gitiles-servlet:javadoc',
  },
)

This is defined in this buckets.

davido avatar Nov 03 '16 17:11 davido

I'll check it out. Thanks!

victorssilva avatar Nov 03 '16 18:11 victorssilva

Check buck build :mvn_install:

$  buck targets --json mvn_install 
[+] PARSING BUCK FILES...0.1s
[
{
  "bash" : null,
  "buck.base_path" : "",
  "buck.direct_dependencies" : [ "//blame-cache:javadoc", "//blame-cache:lib", "//blame-cache:src", "//bucklets/tools:mvn", "//gitiles-servlet:javadoc", "//gitiles-servlet:servlet", "//gitiles-servlet:src" ],
  "buck.type" : "genrule",
  "cmd" : "$(exe //bucklets/tools:mvn) -g com.google.gitiles -v 0.1-10 -o $OUT -s gitiles-servlet:jar:$(location //gitiles-servlet:servlet) -s blame-cache:jar:$(location //blame-cache:lib) -s gitiles-servlet:java-source:$(location //gitiles-servlet:src) -s blame-cache:java-source:$(location //blame-cache:src) -s gitiles-servlet:javadoc:$(location //gitiles-servlet:javadoc) -s blame-cache:javadoc:$(location //blame-cache:javadoc) -a install",
  "cmdExe" : null,
  "executable" : null,
  "fully_qualified_name" : "//:install",
  "licenses" : [ ],
  "name" : "install",
  "out" : "install.info",
  "srcs" : [ ],
  "tests" : [ ],
  "visibility" : [ ]
}
]

But note, that this is a wrong approach, because the rule will only be executed, when there were changes, but deployments shoud be triggered always. So the correct approach instead is to let build tool chain generate a deployment script from the build data. This was recently implemented in Gerrit Code Review:

  $ ./tools/maven/api.sh install buck

This would generate a shell script with this rule:

  $ buck build :gen_api_install

in this location:

  $ buck targets --show_output //tools/maven:gen_api_install
  //tools/maven:gen_api_install buck-out/gen/tools/maven/gen_api_install/api_install.sh

with this content and execute it.

davido avatar Nov 03 '16 19:11 davido