Howto build Gerrit with buck and use a locally build Version of gwtorm

175 views
Skip to first unread message

Christian Halstrick

unread,
Aug 14, 2013, 5:13:40 PM8/14/13
to repo-d...@googlegroups.com
I want to build gerrit with my special version of gwtorm. I have build a modified version of gwtorm with 'mvn clean install'. Now I want to configure the Buck build of gerrit to use this Version of gwtorm. My version of gwtorm should be included in gerrit.war. How would i do that?

Ciao
Chris

David Ostrovsky

unread,
Aug 14, 2013, 6:25:58 PM8/14/13
to repo-d...@googlegroups.com, repo-discuss


On Wednesday, August 14, 2013 11:13:40 PM UTC+2, Christian Halstrick wrote:
I want to build gerrit with my special version of gwtorm. I have build a modified version of gwtorm with 'mvn clean install'. Now I want to configure the Buck build of gerrit to use this Version of gwtorm. My version of gwtorm should be included in gerrit.war. How would i do that?

Well, that's easy. You define a new repository in BUCK: your local maven repo and route the gwtorm to that repo.
I just uploaded the working patch in contrib directory with instructions how to use it:



Dave Borowitz

unread,
Aug 14, 2013, 6:26:07 PM8/14/13
to Christian Halstrick, repo-discuss
Modify lib/BUCK in a local branch?



--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Shawn Pearce

unread,
Aug 14, 2013, 6:42:27 PM8/14/13
to David Ostrovsky, repo-discuss
We can at least standardize MAVEN_LOCAL.
https://gerrit-review.googlesource.com/48791

Christian Halstrick

unread,
Aug 15, 2013, 1:12:34 AM8/15/13
to Dave Borowitz, repo-discuss
I played with this file already but I am new to buck and didn't suceeded. The reference in lib/BUCK is done with a maven_jar macro. That contains a repository element for which I don't know how to express it should be from my local ~/.m2/repository. Then there are two sha1's in this element which I don't know how to set them for a local build. Here is the original:

maven_jar(
  name = 'gwtorm',
  id = 'gwtorm:gwtorm:1.7',
  bin_sha1 = 'ee3b316a023f1422dd4b6654a3d51d0e5690809c',
  src_sha1 = 'a145bde4cc87a4ff4cec283880e2a03be32cc868',
  license = 'Apache2.0',
  repository = GERRIT,
)

Shawn Pearce

unread,
Aug 15, 2013, 1:51:55 AM8/15/13
to Christian Halstrick, Dave Borowitz, repo-discuss
On Wed, Aug 14, 2013 at 10:12 PM, Christian Halstrick
<christian...@gmail.com> wrote:
> I played with this file already but I am new to buck and didn't suceeded.
> The reference in lib/BUCK is done with a maven_jar macro. That contains a
> repository element for which I don't know how to express it should be from
> my local ~/.m2/repository. Then there are two sha1's in this element which I
> don't know how to set them for a local build. Here is the original:
>
> maven_jar(
> name = 'gwtorm',
> id = 'gwtorm:gwtorm:1.7',
> bin_sha1 = 'ee3b316a023f1422dd4b6654a3d51d0e5690809c',
> src_sha1 = 'a145bde4cc87a4ff4cec283880e2a03be32cc868',
> license = 'Apache2.0',
> repository = GERRIT,
> )

Set bin_sha1 and src_sha1 to None and repository to MAVEN_LOCAL. The
MAVEN_LOCAL definition is recent as of e585fc0449 (Aug 14 15:40
-0700).

Christian Halstrick

unread,
Aug 15, 2013, 3:59:43 PM8/15/13
to repo-d...@googlegroups.com, Christian Halstrick, Dave Borowitz
Hi,

On Thursday, August 15, 2013 7:51:55 AM UTC+2, Shawn Pearce wrote:
Set bin_sha1 and src_sha1 to None and repository to MAVEN_LOCAL. The
MAVEN_LOCAL definition is recent as of e585fc0449 (Aug 14 15:40
-0700).

Looks promising but isn't working completely for me. Look at this log:

~/git/gwtorm-internal> mvn  clean install -DskipTests
...
[INFO] ------------------------------------------------------------------------
[INFO] Building gwtorm 1.7-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
[INFO] --- maven-install-plugin:2.3:install (default-install) @ gwtorm ---
[INFO] Installing /home/user/git/gwtorm-internal/target/gwtorm-1.7-SNAPSHOT.jar to /home/user/.m2/repository/gwtorm/gwtorm/1.7-SNAPSHOT/gwtorm-1.7-SNAPSHOT.jar
[INFO] Installing /home/user/git/gwtorm-internal/pom.xml to /home/user/.m2/repository/gwtorm/gwtorm/1.7-SNAPSHOT/gwtorm-1.7-SNAPSHOT.pom
[INFO] Installing /home/user/git/gwtorm-internal/target/gwtorm-1.7-SNAPSHOT-sources.jar to /home/user/.m2/repository/gwtorm/gwtorm/1.7-SNAPSHOT/gwtorm-1.7-SNAPSHOT-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
...
~/git/gwtorm-internal> cd ../gerrit
~/git/gerrit> git status
# Not currently on any branch.
nothing to commit, working directory clean
~/git/gerrit> git describe
v2.7-rc3-1177-g4c74694
~/git/gerrit> vi lib/BUCK   #### Modify the lib/BUCK file
~/git/gerrit> git diff
diff --git a/lib/BUCK b/lib/BUCK
index 053d20e..3d88e2f 100644
--- a/lib/BUCK
+++ b/lib/BUCK
@@ -22,11 +22,11 @@ define_license(name = 'DO_NOT_DISTRIBUTE')
 
 maven_jar(
   name = 'gwtorm',
-  id = 'gwtorm:gwtorm:1.7',
-  bin_sha1 = 'ee3b316a023f1422dd4b6654a3d51d0e5690809c',
-  src_sha1 = 'a145bde4cc87a4ff4cec283880e2a03be32cc868',
+  id = 'gwtorm:gwtorm:1.7-SNAPSHOT',
+  bin_sha1 = None,
+  src_sha1 = None,
   license = 'Apache2.0',
-  repository = GERRIT,
+  repository = MAVEN_LOCAL,
 )
 
 maven_jar(
~/git/gerrit> buck clean
~/git/gerrit> buck build gerrit
[+] PARSING BUILD FILES...1.64s
BUILD FAILED: The build file that should contain //lib:gwtorm_src has already been parsed (/home/user/git/gerrit/lib/BUCK), but //lib:gwtorm_src was not found. Please make sure that //lib:gwtorm_src is defined in /home/user/git/gerrit/lib/BUCK.
~/git/gerrit> 

Shawn Pearce

unread,
Aug 15, 2013, 4:52:19 PM8/15/13
to Christian Halstrick, repo-discuss, Dave Borowitz
Add attach_source = True to the maven_jar() call.

Christian Halstrick

unread,
Aug 16, 2013, 1:00:23 AM8/16/13
to Shawn Pearce, repo-discuss, Dave Borowitz
does this work for you? I still get the same error that "//lib:gwtorm_src can't be found".

~/git/gerrit> git describe
v2.7-rc3-1177-g4c74694
~/git/gerrit> git diff
diff --git a/lib/BUCK b/lib/BUCK
index 053d20e..ab0a7fd 100644
--- a/lib/BUCK
+++ b/lib/BUCK
@@ -22,11 +22,12 @@ define_license(name = 'DO_NOT_DISTRIBUTE')
 
 maven_jar(
   name = 'gwtorm',
-  id = 'gwtorm:gwtorm:1.7',
-  bin_sha1 = 'ee3b316a023f1422dd4b6654a3d51d0e5690809c',
-  src_sha1 = 'a145bde4cc87a4ff4cec283880e2a03be32cc868',
+  id = 'gwtorm:gwtorm:1.7-SNAPSHOT',
+  bin_sha1 = None,
+  src_sha1 = None,
   license = 'Apache2.0',
-  repository = GERRIT,
+  repository = MAVEN_LOCAL,
+  attach_source = True,
 )
 
 maven_jar(
~/git/gerrit> buck clean
~/git/gerrit> buck build gerrit
[+] PARSING BUILD FILES...0.96s
BUILD FAILED: The build file that should contain //lib:gwtorm_src has already been parsed (/home/user/git/gerrit/lib/BUCK), but //lib:gwtorm_src was not found. Please make sure that //lib:gwtorm_src is defined in /home/user/git/gerrit/lib/BUCK.
~/git/gerrit> ls ~/.m2/repository/gwtorm/gwtorm/1.7-SNAPSHOT/
gwtorm-1.7-SNAPSHOT.jar  gwtorm-1.7-SNAPSHOT.pom  gwtorm-1.7-SNAPSHOT-sources.jar  maven-metadata-local.xml  _maven.repositories  resolver-status.properties
~/git/gerrit> 


Ciao
  Chris

David Ostrovsky

unread,
Aug 16, 2013, 1:59:04 AM8/16/13
to repo-d...@googlegroups.com, Shawn Pearce, Dave Borowitz
You are right, it doesn't. Probably we have some issues if sha1 not defined.
So currently, it only works like i described in my original mail. Make follow modifications:

1. gwtorm: use version without "SNAPSHOT" suffix, i. e. 2.0 woked for me, then issue mvn clean install
2. verify that you have:

ls -1 /home/davido/.m2/repository/gwtorm/gwtorm/2.0/gwtorm-2.0*.jar
/home/davido/.m2/repository/gwtorm/gwtorm/2.0/gwtorm-2.0.jar
/home/davido/.m2/repository/gwtorm/gwtorm/2.0/gwtorm-2.0-sources.jar

3. compute sha1 for bin and src artifacts: 
sha1sum /home/davido/.m2/repository/gwtorm/gwtorm/2.0/gwtorm-2.0.jar /home/davido/.m2/repository/gwtorm/gwtorm/2.0/gwtorm-2.0-sources.jar 
d2ae0d475e5e01e7e293e5f8da4fcdd067e67d05  /home/davido/.m2/repository/gwtorm/gwtorm/2.0/gwtorm-2.0.jar
bbeeff78b7cb1f46bb4be4aa3d5a9c9cf258e5d0  /home/davido/.m2/repository/gwtorm/gwtorm/2.0/gwtorm-2.0-sources.jar

4. adapt the gwtorm section in lib/BUCK to be:

maven_jar(
  name = 'gwtorm',
  id = 'gwtorm:gwtorm:2.0',
  bin_sha1 = 'd2ae0d475e5e01e7e293e5f8da4fcdd067e67d05',
  src_sha1 = 'bbeeff78b7cb1f46bb4be4aa3d5a9c9cf258e5d0',
  license = 'Apache2.0',
  repository = MAVEN_LOCAL,
)

where bin_sha1 & src_sha1 the new computed values for your custom gwtorm version from step 3

5. Modify MAVEN_LOCAL definition in tools/download_file.py:

'MAVEN_LOCAL': 'file:///home/davido/.m2/repository',

replace "davido" with your home directory

6. buck build gerrit 

Christian Halstrick

unread,
Aug 16, 2013, 4:22:08 AM8/16/13
to repo-d...@googlegroups.com, Shawn Pearce, Dave Borowitz
Great! This worked. Thanks a lot.

David Ostrovsky

unread,
Aug 16, 2013, 12:35:18 PM8/16/13
to repo-d...@googlegroups.com, Shawn Pearce, Dave Borowitz


On Friday, August 16, 2013 10:22:08 AM UTC+2, Christian Halstrick wrote:
Great! This worked. Thanks a lot.

With this patch [1] you only need to change gwtorm in lib/BUCK to:

maven_jar(
   name = 'gwtorm',
   id = 'gwtorm:gwtorm:2.0',
   license = 'Apache2.0',
   repository = MAVEN_LOCAL,
 )
Reply all
Reply to author
Forward
0 new messages