Skip to content

Commit 043e445

Browse files
committed
Build dist jars using buck
At least for the client jar.
1 parent 49305c8 commit 043e445

File tree

10 files changed

+142
-22
lines changed

10 files changed

+142
-22
lines changed

.idea/libraries/javaparser.xml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rakefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ end
442442

443443

444444
task :'prep-release-zip' => [
445-
'//java/client/src/org/openqa/selenium:client-combined:zip',
445+
'//java/client/src/org/openqa/selenium:client-combined-zip',
446446
'//java/server/src/org/openqa/grid/selenium:selenium:zip',
447447
'//java/server/src/org/openqa/selenium/server/htmlrunner:selenium-runner'] do
448448

@@ -451,9 +451,7 @@ task :'prep-release-zip' => [
451451
cp Rake::Task['//java/server/src/org/openqa/grid/selenium:selenium:zip'].out, "build/dist/selenium-server-#{version}.zip"
452452
`jar uf build/dist/selenium-server-#{version}.zip NOTICE LICENSE`
453453
`cd java && jar uf ../build/dist/selenium-server-#{version}.zip CHANGELOG`
454-
cp Rake::Task['//java/client/src/org/openqa/selenium:client-combined:zip'].out, "build/dist/selenium-java-#{version}.zip"
455-
`jar uf build/dist/selenium-java-#{version}.zip NOTICE LICENSE`
456-
`cd java && jar uf ../build/dist/selenium-server-#{version}.zip CHANGELOG`
454+
cp Rake::Task['//java/client/src/org/openqa/selenium:client-combined-zip'].out, "build/dist/selenium-java-#{version}.zip"
457455
cp Rake::Task['//java/server/src/org/openqa/selenium/server/htmlrunner:selenium-runner'].out, "build/dist/selenium-html-runner-#{version}.jar"
458456
end
459457

java/client/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@
4545
<classpathentry kind="lib" path="/third-party/java/testng/testng-6.9.9.jar" sourcepath="/third-party/java/testng/testng-6.9.9-sources.jar"/>
4646
<classpathentry kind="lib" path="/third-party/java/github/org.eclipse.egit.github.core-2.1.5.jar" sourcepath="/third-party/java/github/org.eclipse.egit.github.core-2.1.5.jar-sources.jar"/>
4747
<classpathentry kind="lib" path="/third-party/java/bytebuddy/byte-buddy-1.7.5.jar" sourcepath="/third-party/java/bytebuddy/byte-buddy-1.7.5-sources.jar"/>
48+
<classpathentry kind="lib" path="/third-party/java/javaparser/javaparser-core-3.4.0.jar" sourcepath="/third-party/java/javaparser/javaparser-core-3.4.0-sources.jar"/>
4849
<classpathentry kind="output" path="build/production"/>
4950
</classpath>

java/client/client.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<orderEntry type="inheritedJdk" />
1818
<orderEntry type="sourceFolder" forTests="false" />
1919
<orderEntry type="library" name="byte-buddy" level="project" />
20-
<orderEntry type="library" name="cglib" level="project" />
2120
<orderEntry type="library" scope="RUNTIME" name="commons-codec" level="project" />
2221
<orderEntry type="library" scope="RUNTIME" name="commons-collections" level="project" />
2322
<orderEntry type="library" name="commons-exec" level="project" />
@@ -49,6 +48,7 @@
4948
<orderEntry type="library" scope="TEST" name="websocket" level="project" />
5049
<orderEntry type="library" scope="TEST" name="jetty-util" level="project" />
5150
<orderEntry type="library" scope="TEST" name="github" level="project" />
51+
<orderEntry type="library" name="javaparser" level="project" />
5252
</component>
5353
<component name="sonarModuleSettings">
5454
<option name="alternativeWorkingDirPath" value="" />

java/client/src/org/openqa/selenium/BUCK

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ java_library(name = 'selenium',
2323
visibility = ['PUBLIC'],
2424
)
2525

26+
export_file(
27+
name = 'template-pom',
28+
src = 'pom.xml',
29+
out = 'pom.xml',
30+
visibility = ['PUBLIC'],
31+
)
32+
2633
java_library(name = 'core',
2734
maven_coords = 'org.seleniumhq.selenium:selenium-api:' + SE_VERSION,
2835
maven_pom_template = ':template-pom',
@@ -186,6 +193,22 @@ java_library(
186193
],
187194
)
188195

196+
197+
# This isn't very elegant, but we can build a dist zip like this:
198+
zip_file(
199+
name = 'client-combined-zip',
200+
out = 'selenium-java-' + SE_VERSION + '.zip',
201+
srcs = [
202+
':client-combined-' + SE_VERSION,
203+
':client-combined-source-zip',
204+
':client-libs',
205+
'//java:changelog',
206+
'//:notice',
207+
'//:license',
208+
],
209+
)
210+
211+
# The jar file containing merged first party code
189212
java_binary(
190213
name = 'client-combined-' + SE_VERSION,
191214
blacklist = [
@@ -196,29 +219,27 @@ java_binary(
196219
],
197220
)
198221

199-
# Output of this rule is named a source jar so we can do merging later
222+
# The first party source, as a source jar which we don't want merged
200223
genrule(
201-
name = 'client-libs',
202-
out = 'libs-sources.jar',
203-
cmd = 'mkdir libs && echo $(classpath :client-combined) | tr : "\\n" | grep third_party/java | grep .jar | xargs -J % cp % libs && jar cMf $OUT libs/*',
224+
name = 'client-combined-sources',
225+
out = 'client-combined-' + SE_VERSION + '-sources.jar',
226+
cmd = 'mkdir temp && echo $(query_paths "inputs(kind(java_library, deps(//java/client/src/org/openqa/selenium:client-combined)))") | xargs $(exe //java/client/src/org/openqa/selenium/tools:package) $OUT',
204227
)
205228

229+
# So we hide it in another zip file, which will be merged. Zip file merging isn't recursive.
206230
zip_file(
207-
name = 'client-combined-zip',
208-
out = 'selenium-java-' + SE_VERSION + '.zip',
231+
name = 'client-combined-source-zip',
232+
out = 'selenium-java-sources.jar',
233+
merge_source_zips = False,
209234
srcs = [
210-
':client-combined-' + SE_VERSION,
211-
':client-libs',
212-
'//java:changelog',
213-
'//:notice',
214-
'//:license',
235+
':client-combined-sources'
215236
],
216237
)
217238

218-
219-
export_file(
220-
name = 'template-pom',
221-
src = 'pom.xml',
222-
out = 'pom.xml',
223-
visibility = ['PUBLIC'],
239+
# The third party libraries we depend on, as a source jar for merging
240+
genrule(
241+
name = 'client-libs',
242+
out = 'libs-sources.jar',
243+
cmd = 'mkdir libs && echo $(classpath :client-combined) | tr : "\\n" | grep third_party/java | grep .jar | xargs -J % cp % libs && jar cMf $OUT libs/*',
224244
)
245+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
java_library(
2+
name = "package-lib",
3+
srcs = [
4+
"PackageParser.java",
5+
],
6+
deps = [
7+
"//third_party/java/javaparser:javaparser-core",
8+
],
9+
)
10+
11+
java_binary(
12+
name = "package",
13+
main_class = "org.openqa.selenium.tools.PackageParser",
14+
deps = [
15+
":package-lib",
16+
],
17+
visibility = [
18+
"//java/client/src/org/openqa/selenium:client-combined-sources",
19+
],
20+
)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package org.openqa.selenium.tools;
2+
3+
import com.github.javaparser.JavaParser;
4+
import com.github.javaparser.ast.CompilationUnit;
5+
6+
import java.io.File;
7+
import java.io.IOException;
8+
import java.nio.file.Files;
9+
import java.nio.file.Path;
10+
import java.nio.file.Paths;
11+
import java.util.Calendar;
12+
import java.util.Map;
13+
import java.util.TreeMap;
14+
import java.util.zip.ZipEntry;
15+
import java.util.zip.ZipOutputStream;
16+
17+
public class PackageParser {
18+
private final static long TIME_STAMP;
19+
static {
20+
Calendar c = Calendar.getInstance();
21+
c.set(1985, 1, 1, 0, 0, 0);
22+
TIME_STAMP = c.getTimeInMillis();
23+
}
24+
25+
26+
public static void main(String[] args) throws IOException {
27+
Path out = Paths.get(args[0]);
28+
29+
Map<String, Path> outToIn = new TreeMap<>();
30+
31+
for (int i = 1; i < args.length; i++) {
32+
Path source = Paths.get(args[i]);
33+
CompilationUnit unit = JavaParser.parse(source);
34+
String packageName = unit.getPackageDeclaration()
35+
.map(decl -> decl.getName().asString())
36+
.orElse("");
37+
Path target = Paths.get(packageName.replace('.', File.separatorChar))
38+
.resolve(source.getFileName());
39+
40+
outToIn.put(target.toString(), source);
41+
}
42+
43+
try (ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(out))) {
44+
outToIn.forEach((target, source) -> {
45+
ZipEntry entry = new ZipEntry(target);
46+
entry.setMethod(ZipEntry.DEFLATED);
47+
entry.setTime(TIME_STAMP);
48+
try {
49+
zos.putNextEntry(entry);
50+
Files.copy(source, zos);
51+
zos.closeEntry();
52+
} catch (IOException e) {
53+
throw new RuntimeException(e);
54+
}
55+
});
56+
}
57+
}
58+
59+
}

third_party/java/javaparser/BUCK

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
prebuilt_jar(
2+
name = 'javaparser-core',
3+
maven_coords = 'com.github.javaparser:javaparser-core:jar:3.4.0',
4+
binary_jar = 'javaparser-core-3.4.0.jar',
5+
source_jar = 'javaparser-core-3.4.0-sources.jar',
6+
visibility = [
7+
'//java/client/src/org/openqa/selenium/tools:',
8+
],
9+
)
10+
525 KB
Binary file not shown.
907 KB
Binary file not shown.

0 commit comments

Comments
 (0)