Skip to content

Commit 500f3e1

Browse files
committed
Build selenium server dist jar using buck
1 parent 043e445 commit 500f3e1

File tree

4 files changed

+69
-12
lines changed

4 files changed

+69
-12
lines changed

Rakefile

+2-4
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,12 @@ end
443443

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

449449
mkdir_p "build/dist"
450450
cp Rake::Task['//java/server/src/org/openqa/grid/selenium:selenium'].out, "build/dist/selenium-server-standalone-#{version}.jar"
451-
cp Rake::Task['//java/server/src/org/openqa/grid/selenium:selenium:zip'].out, "build/dist/selenium-server-#{version}.zip"
452-
`jar uf build/dist/selenium-server-#{version}.zip NOTICE LICENSE`
453-
`cd java && jar uf ../build/dist/selenium-server-#{version}.zip CHANGELOG`
451+
cp Rake::Task['//java/server/src/org/openqa/grid/selenium:selenium-zip'].out, "build/dist/selenium-server-#{version}.zip"
454452
cp Rake::Task['//java/client/src/org/openqa/selenium:client-combined-zip'].out, "build/dist/selenium-java-#{version}.zip"
455453
cp Rake::Task['//java/server/src/org/openqa/selenium/server/htmlrunner:selenium-runner'].out, "build/dist/selenium-html-runner-#{version}.jar"
456454
end

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

+1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ java_binary(
1616
],
1717
visibility = [
1818
"//java/client/src/org/openqa/selenium:client-combined-sources",
19+
"//java/server/src/org/openqa/grid/selenium:selenium-server-sources",
1920
],
2021
)

java/client/src/org/openqa/selenium/tools/PackageParser.java

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.openqa.selenium.tools;
22

33
import com.github.javaparser.JavaParser;
4+
import com.github.javaparser.ParseProblemException;
45
import com.github.javaparser.ast.CompilationUnit;
56

67
import java.io.File;
@@ -30,14 +31,22 @@ public static void main(String[] args) throws IOException {
3031

3132
for (int i = 1; i < args.length; i++) {
3233
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);
34+
if (!source.getFileName().toString().endsWith(".java")) {
35+
continue;
36+
}
37+
38+
try {
39+
CompilationUnit unit = JavaParser.parse(source);
40+
String packageName = unit.getPackageDeclaration()
41+
.map(decl -> decl.getName().asString())
42+
.orElse("");
43+
Path target = Paths.get(packageName.replace('.', File.separatorChar))
44+
.resolve(source.getFileName());
45+
46+
outToIn.put(target.toString(), source);
47+
} catch (ParseProblemException ignored) {
48+
// carry on
49+
}
4150
}
4251

4352
try (ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(out))) {

java/server/src/org/openqa/grid/selenium/BUCK

+49
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,52 @@ java_library(name = 'classes',
4343
'//java/server/test/org/openqa/grid/e2e:tests',
4444
],
4545
)
46+
47+
# This isn't very elegant, but we can build a dist zip like this:
48+
zip_file(
49+
name = 'selenium-zip',
50+
out = 'selenium-server-' + SE_VERSION + '.zip',
51+
srcs = [
52+
':selenium-' + SE_VERSION + '-nodeps',
53+
':selenium-server-source-zip',
54+
':server-libs',
55+
'//java:changelog',
56+
'//:notice',
57+
'//:license',
58+
],
59+
)
60+
61+
# The jar file containing merged first party code
62+
java_binary(
63+
name = 'selenium-' + SE_VERSION + '-nodeps',
64+
blacklist = [
65+
'^(?!com.thoughtworks.selenium.*|org.openqa.selenium.*|org.openqa.grid.*)',
66+
],
67+
deps = [
68+
':selenium',
69+
],
70+
)
71+
72+
# The first party source, as a source jar which we don't want merged
73+
genrule(
74+
name = 'selenium-server-sources',
75+
out = 'selenium-' + SE_VERSION + '-nodeps-sources.jar',
76+
cmd = 'mkdir temp && echo $(query_paths "inputs(kind(java_library, deps(:selenium)))") | xargs $(exe //java/client/src/org/openqa/selenium/tools:package) $OUT',
77+
)
78+
79+
# So we hide it in another zip file, which will be merged. Zip file merging isn't recursive.
80+
zip_file(
81+
name = 'selenium-server-source-zip',
82+
out = 'selenium-server-sources.jar',
83+
merge_source_zips = False,
84+
srcs = [
85+
':selenium-server-sources'
86+
],
87+
)
88+
89+
# The third party libraries we depend on, as a source jar for merging
90+
genrule(
91+
name = 'server-libs',
92+
out = 'server-libs-sources.jar',
93+
cmd = 'mkdir libs && echo $(classpath :selenium) | tr : "\\n" | grep third_party/java | grep .jar | xargs -J % cp % libs && jar cMf $OUT libs/*',
94+
)

0 commit comments

Comments
 (0)