Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.

Commit 8bf3abb

Browse files
committed
Add build system
1 parent 2165009 commit 8bf3abb

File tree

8 files changed

+677
-0
lines changed

8 files changed

+677
-0
lines changed

build.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repositories:
2+
remote:
3+
- http://repo1.maven.org/maven2
4+
- https://stocksoftware.jfrog.io/stocksoftware/public
5+
- https://stocksoftware.jfrog.io/stocksoftware/oss
6+
- https://stocksoftware.jfrog.io/stocksoftware/staging
7+
- https://stocksoftware.jfrog.io/stocksoftware/thirdparty-local
8+
9+
artifacts:
10+
idea_codestyle: au.com.stocksoftware.idea.codestyle:idea-codestyle:xml:1.12
11+
12+
anodoc: org.realityforge.anodoc:anodoc:jar:1.0.0
13+
14+
javax_jsr305: com.google.code.findbugs:jsr305:jar:3.0.1
15+
16+
# GWT deps
17+
gwt_user: com.google.gwt:gwt-user:jar:2.8.2
18+
gwt_dev: com.google.gwt:gwt-dev:jar:2.8.2
19+
20+
jsinterop_annotations: com.google.jsinterop:jsinterop-annotations:jar:1.0.2
21+
jsinterop_annotations_sources: com.google.jsinterop:jsinterop-annotations:jar:sources:1.0.2
22+
23+
jsinterop_base: com.google.jsinterop:base:jar:1.0.0-RC1
24+
jsinterop_base_sources: com.google.jsinterop:base:jar:sources:1.0.0-RC1
25+
26+
elemental2_core: com.google.elemental2:elemental2-core:jar:1.0.0-RC1
27+
elemental2_dom: com.google.elemental2:elemental2-dom:jar:1.0.0-RC1
28+
elemental2_promise: com.google.elemental2:elemental2-promise:jar:1.0.0-RC1
29+
30+
react4j_annotation: org.realityforge.react4j:react4j-annotations:jar:0.54
31+
react4j_core: org.realityforge.react4j:react4j-core:jar:0.54
32+
react4j_dom: org.realityforge.react4j:react4j-dom:jar:0.54
33+
react4j_processor: org.realityforge.react4j:react4j-processor:jar:0.54
34+
35+
braincheck: org.realityforge.braincheck:braincheck:jar:1.5.0

buildfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
require 'buildr/git_auto_version'
2+
require 'buildr/gpg'
3+
require 'buildr/gwt'
4+
5+
desc 'React4j-WindowPortal: React4j portal that renders into a Window'
6+
define 'react4j-windowportal' do
7+
project.group = 'org.realityforge.react4j.windowportal'
8+
compile.options.source = '1.8'
9+
compile.options.target = '1.8'
10+
compile.options.lint = 'all'
11+
12+
project.version = ENV['PRODUCT_VERSION'] if ENV['PRODUCT_VERSION']
13+
14+
dom_artifact = artifact(:react4j_dom)
15+
pom.include_transitive_dependencies << dom_artifact
16+
pom.dependency_filter = Proc.new {|dep| dom_artifact == dep[:artifact]}
17+
18+
project.processorpath << :react4j_processor
19+
20+
compile.with :javax_jsr305,
21+
:anodoc,
22+
:jsinterop_base,
23+
:jsinterop_base_sources,
24+
:jsinterop_annotations,
25+
:jsinterop_annotations_sources,
26+
:elemental2_core,
27+
:elemental2_dom,
28+
:elemental2_promise,
29+
:braincheck,
30+
:react4j_annotation,
31+
:react4j_core,
32+
:react4j_dom
33+
34+
gwt_enhance(project)
35+
36+
package(:jar)
37+
package(:sources)
38+
package(:javadoc)
39+
40+
doc.
41+
using(:javadoc,
42+
:windowtitle => 'React4j WindowPortal API Documentation',
43+
:linksource => true,
44+
:timestamp => false,
45+
:link => %w(https://react4j.github.io/api https://arez.github.io/api https://docs.oracle.com/javase/8/docs/api http://www.gwtproject.org/javadoc/latest/)
46+
)
47+
48+
iml.excluded_directories << project._('tmp')
49+
iml.excluded_directories << project._('node_modules')
50+
51+
ipr.add_component_from_artifact(:idea_codestyle)
52+
end

tasks/buildr_artifact_patch.rake

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
raise 'Patch already integrated into buildr code' unless Buildr::VERSION.to_s == '1.5.5'
2+
3+
module Buildr::ActsAsArtifact
4+
def upload_task(upload_to = nil)
5+
upload_to ||= Buildr.repositories.snapshot_to if snapshot? && Buildr.repositories.snapshot_to != nil && Buildr.repositories.snapshot_to[:url] != nil
6+
upload_to ||= Buildr.repositories.release_to
7+
upload_to = { :url => upload_to } unless Hash === upload_to
8+
raise ArgumentError, 'Don\'t know where to upload, perhaps you forgot to set repositories.release_to' unless upload_to[:url]
9+
10+
# Set the upload URI, including mandatory slash (we expect it to be the base directory).
11+
# Username/password may be part of URI, or separate entities.
12+
uri = URI.parse(upload_to[:url].clone)
13+
uri.path = uri.path + '/' unless uri.path[-1] == '/'
14+
to_escape = "!\"\#$%&'()*+,-./:;<=>?@{}|~`'"
15+
uri.user = URI.encode(upload_to[:username], to_escape) if upload_to[:username]
16+
uri.password = URI.encode(upload_to[:password], to_escape) if upload_to[:password]
17+
18+
path = group.gsub('.', '/') + "/#{id}/#{version}/#{upload_name}"
19+
20+
unless task = Buildr.application.lookup(uri+path)
21+
deps = [self]
22+
deps << pom.upload_task(upload_to) if pom && pom != self && classifier.nil?
23+
24+
task = Rake::Task.define_task uri + path => deps do
25+
# Upload artifact relative to base URL, need to create path before uploading.
26+
options = upload_to[:options] || { :permissions => upload_to[:permissions] }
27+
info "Deploying #{to_spec}"
28+
URI.upload uri + path, name, options
29+
if snapshot? && pom != self
30+
maven_metadata = group.gsub('.', '/') + "/#{id}/#{version}/#{MAVEN_METADATA}"
31+
URI.write uri + maven_metadata, maven_metadata_xml, :permissions => upload_to[:permissions]
32+
end
33+
end
34+
end
35+
task
36+
end
37+
end
38+
39+
class URI::HTTP
40+
private
41+
42+
def write_internal(options, &block)
43+
options ||= {}
44+
connect do |http|
45+
trace "Uploading to #{path}"
46+
content = StringIO.new
47+
while chunk = yield(RW_CHUNK_SIZE)
48+
content << chunk
49+
end
50+
headers = { 'Content-MD5' => Digest::MD5.hexdigest(content.string), 'Content-Type' => 'application/octet-stream', 'User-Agent' => "Buildr-#{Buildr::VERSION}" }
51+
request = Net::HTTP::Put.new(request_uri.empty? ? '/' : request_uri, headers)
52+
request.basic_auth URI.decode(self.user), URI.decode(self.password) if self.user
53+
response = nil
54+
with_progress_bar options[:progress], path.split('/').last, content.size do |progress|
55+
request.content_length = content.size
56+
content.rewind
57+
stream = Object.new
58+
class << stream;
59+
self;
60+
end.send :define_method, :read do |*args|
61+
bytes = content.read(*args)
62+
progress << bytes if bytes
63+
bytes
64+
end
65+
request.body_stream = stream
66+
response = http.request(request)
67+
end
68+
69+
case response
70+
when Net::HTTPRedirection
71+
# Try to download from the new URI, handle relative redirects.
72+
trace "Redirected to #{response['Location']}"
73+
content.rewind
74+
return (self + URI.parse(response['location'])).write_internal(options) {|bytes| content.read(bytes)}
75+
when Net::HTTPSuccess
76+
else
77+
raise RuntimeError, "Failed to upload #{self}: #{response.message}"
78+
end
79+
end
80+
end
81+
end

tasks/custom_pom_patch.rake

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
raise 'Patch already integrated into buildr code' unless Buildr::VERSION.to_s == '1.5.5'
2+
3+
class Buildr::CustomPom
4+
attr_accessor :dependency_filter
5+
6+
def additional_dependencies
7+
@additional_dependencies ||= []
8+
end
9+
10+
def additional_dependencies=(additional_dependencies)
11+
@additional_dependencies = additional_dependencies
12+
end
13+
14+
def include_transitive_dependencies
15+
@include_transitive_dependencies ||= []
16+
end
17+
18+
def include_transitive_dependencies=(include_transitive_dependencies)
19+
@include_transitive_dependencies = include_transitive_dependencies
20+
end
21+
22+
def self.pom_xml(project, package)
23+
Proc.new do
24+
xml = Builder::XmlMarkup.new(:indent => 2)
25+
xml.instruct!
26+
xml.project('xmlns' => 'http://maven.apache.org/POM/4.0.0',
27+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
28+
'xsi:schemaLocation' => 'http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd') do
29+
xml.modelVersion '4.0.0'
30+
xml.parent do
31+
xml.groupId 'org.sonatype.oss'
32+
xml.artifactId 'oss-parent'
33+
xml.version '8'
34+
end
35+
xml.groupId project.group
36+
xml.artifactId project.id
37+
xml.version project.version
38+
candidates = project.packages.select {|p| p.classifier.nil?}.collect {|p| p.type.to_s}
39+
packaging = !candidates.empty? ? candidates[0] : (project.compile.packaging || :zip).to_s
40+
xml.packaging packaging
41+
42+
xml.name project.pom.name if project.pom.name
43+
xml.description project.pom.description if project.pom.description
44+
xml.url project.pom.url if project.pom.url
45+
46+
xml.licenses do
47+
project.pom.licenses.each_pair do |name, url|
48+
xml.license do
49+
xml.name name
50+
xml.url url
51+
xml.distribution 'repo'
52+
end
53+
end
54+
end unless project.pom.licenses.empty?
55+
56+
if project.pom.scm_url || project.pom.scm_connection || project.pom.scm_developer_connection
57+
xml.scm do
58+
xml.connection project.pom.scm_connection if project.pom.scm_connection
59+
xml.developerConnection project.pom.scm_developer_connection if project.pom.scm_developer_connection
60+
xml.url project.pom.scm_url if project.pom.scm_url
61+
end
62+
end
63+
64+
if project.pom.issues_url
65+
xml.issueManagement do
66+
xml.url project.pom.issues_url
67+
xml.system project.pom.issues_system if project.pom.issues_system
68+
end
69+
end
70+
71+
xml.developers do
72+
project.pom.developers.each do |developer|
73+
xml.developer do
74+
xml.id developer.id
75+
xml.name developer.name if developer.name
76+
xml.email developer.email if developer.email
77+
if developer.roles
78+
xml.roles do
79+
developer.roles.each do |role|
80+
xml.role role
81+
end
82+
end
83+
end
84+
end
85+
end
86+
end unless project.pom.developers.empty?
87+
88+
provided_deps = Buildr.artifacts(project.pom.provided_dependencies)
89+
runtime_deps = Buildr.artifacts(project.pom.runtime_dependencies)
90+
additional_deps = Buildr.artifacts(project.pom.additional_dependencies)
91+
include_transitive_deps = Buildr.artifacts(project.pom.include_transitive_dependencies).collect {|dep| dep.to_s}
92+
optional_deps = Buildr.artifacts(project.pom.optional_dependencies).collect{|dep| dep.to_s}
93+
94+
done = []
95+
96+
deps = []
97+
deps += provided_deps.
98+
select {|d| d.is_a?(ActsAsArtifact)}.
99+
select {|d| !done.include?(d.to_s)}.
100+
collect {|dep| done << dep.to_s; dep.to_hash.merge(:scope => 'provided', :optional => optional_deps.include?(dep.to_s), :include_transitive => include_transitive_deps.include?(dep.to_s), :artifact => dep)}
101+
deps += runtime_deps.
102+
select {|d| d.is_a?(ActsAsArtifact)}.
103+
select {|d| !done.include?(d.to_s)}.
104+
collect {|dep| done << dep.to_s; dep.to_hash.merge(:scope => 'runtime', :optional => optional_deps.include?(dep.to_s), :include_transitive => include_transitive_deps.include?(dep.to_s), :artifact => dep)}
105+
deps += additional_deps.
106+
select {|d| d.is_a?(ActsAsArtifact)}.
107+
select {|d| !done.include?(d.to_s)}.
108+
collect {|dep| done << dep.to_s; dep.to_hash.merge(:scope => 'compile', :optional => optional_deps.include?(dep.to_s), :include_transitive => include_transitive_deps.include?(dep.to_s), :artifact => dep)}
109+
110+
deps +=
111+
Buildr.artifacts(project.compile.dependencies).
112+
select {|d| d.is_a?(ActsAsArtifact)}.
113+
select {|d| !done.include?(d.to_s)}.
114+
collect {|d| done << d.to_s; d.to_hash.merge(:scope => 'compile', :optional => optional_deps.include?(d.to_s), :include_transitive => include_transitive_deps.include?(d.to_s), :artifact => d)}
115+
116+
deps += Buildr.artifacts(project.test.compile.dependencies).
117+
select {|d| d.is_a?(ActsAsArtifact)}.
118+
select {|d| !done.include?(d.to_s)}.
119+
collect {|d| d.to_hash.merge(:scope => 'test', :include_transitive => include_transitive_deps.include?(d.to_s), :artifact => d)}
120+
121+
xml.dependencies do
122+
deps.select {|dependency| project.pom.dependency_filter.nil? ? true : project.pom.dependency_filter.call(dependency)}.each do |dependency|
123+
xml.dependency do
124+
xml.groupId dependency[:group]
125+
xml.artifactId dependency[:id]
126+
xml.version dependency[:version]
127+
xml.classifier dependency[:classifier] if dependency[:classifier] && dependency[:classifier].to_s != 'jar'
128+
xml.scope dependency[:scope] unless dependency[:scope] == 'compile'
129+
xml.optional true if dependency[:optional]
130+
unless dependency[:include_transitive]
131+
xml.exclusions do
132+
xml.exclusion do
133+
xml.groupId '*'
134+
xml.artifactId '*'
135+
end
136+
end
137+
end
138+
end
139+
end
140+
end unless deps.empty?
141+
end
142+
end
143+
end
144+
end

tasks/gwt.rake

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#
2+
# Enhance the Buildr project to compile gwt sources.
3+
# For each of the discovered gwt modules, this task will create
4+
# a synthetic gwt module that includes a single entrypoint to
5+
# compile against. It will also create a gwt classifier jar
6+
# that includes all the sources.
7+
#
8+
def gwt_enhance(project, options = {})
9+
modules_complete = !!options[:modules_complete]
10+
package_jars = options[:package_jars].nil? ? true : !!options[:package_jars]
11+
12+
extra_deps = project.iml.main_generated_resource_directories.flatten.compact.collect do |a|
13+
a.is_a?(String) ? file(a) : a
14+
end + project.iml.main_generated_source_directories.flatten.compact.collect do |a|
15+
a.is_a?(String) ? file(a) : a
16+
end
17+
18+
if project.enable_annotation_processor?
19+
extra_deps += [project.file(project._(:generated, 'processors/main/java'))]
20+
end
21+
22+
dependencies = project.compile.dependencies + extra_deps + [Buildr.artifact(:gwt_user)]
23+
24+
gwt_modules = []
25+
source_paths = project.compile.sources + project.iml.main_generated_resource_directories.flatten.compact + project.iml.main_generated_source_directories.flatten.compact
26+
source_paths.each do |base_dir|
27+
Dir["#{base_dir}/**/*.gwt.xml"].each do |filename|
28+
gwt_modules << filename.gsub("#{base_dir}/", '').gsub('.gwt.xml', '').gsub('/', '.')
29+
end
30+
end
31+
32+
unless modules_complete
33+
base_synthetic_module_dir = project._(:generated, :synthetic_gwt_module, :main, :resources)
34+
t = project.task('gwt_synthetic_module') do
35+
gwt_modules.each do |gwt_module|
36+
file = "#{base_synthetic_module_dir}/#{gwt_module.gsub('.', '/')}Test.gwt.xml"
37+
mkdir_p File.dirname(file)
38+
IO.write(file, <<CONTENT)
39+
<module>
40+
<inherits name="#{gwt_module}"/>
41+
<inherits name="com.google.gwt.user.User"/>
42+
<collapse-all-properties/>
43+
</module>
44+
CONTENT
45+
end
46+
end
47+
dir = project.file(base_synthetic_module_dir => [t.name])
48+
dependencies += [dir]
49+
end
50+
51+
if ENV['GWT'].nil? || ENV['GWT'] == project.name
52+
modules = modules_complete ? gwt_modules : gwt_modules.collect {|gwt_module| "#{gwt_module}Test"}
53+
modules.each do |m|
54+
project.gwt([m], { :java_args => %w(-Xms512M -Xmx1024M),
55+
:dependencies => dependencies,
56+
:output_key => options[:output_key] || m })
57+
end
58+
end
59+
60+
project.package(:jar).tap do |j|
61+
extra_deps.each do |dep|
62+
j.enhance([dep])
63+
j.include("#{dep}/*")
64+
end
65+
j.include(project._(:generated, 'processors/main/java/react4j')) if project.enable_annotation_processor?
66+
project.assets.paths.each do |path|
67+
j.include("#{path}/*")
68+
end
69+
j.include("#{project._(:source, :main, :java)}/*")
70+
end if package_jars
71+
72+
config = {}
73+
gwt_modules.each do |gwt_module|
74+
config[gwt_module] = false
75+
end
76+
project.iml.add_gwt_facet(config, :settings => {
77+
:compilerMaxHeapSize => '1024',
78+
:compilerParameters => '-draftCompile -localWorkers 2 -strict'
79+
}, :gwt_dev_artifact => :gwt_dev)
80+
end

0 commit comments

Comments
 (0)