Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b804e58

Browse files
committed
Add a Makefile to auto-build everything in a headless environment
1 parent babf5de commit b804e58

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

Makefile

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# To use this file, run:
2+
#
3+
# $ make CONFIGURE_FLAGS="-Dplugin.path=/path/to/your/eclipse/plugins"
4+
#
5+
# For example, on Debian GNU/Linux:
6+
#
7+
# $ make CONFIGURE_FLAGS="-Dplugin.path=/usr/lib/eclipse:/usr/share/eclipse/dropins/jdt"
8+
#
9+
# You can also add e.g. "-DforceContextQualifier=none" to make the jars be
10+
# output under a stable filename.
11+
#
12+
# Due to https://github.com/zhourenjian/java2script/issues/7 you may need to
13+
# run this using xvfb https://packages.debian.org/sid/xvfb
14+
#
15+
CONFIGURE_FLAGS +=
16+
CORE_FLAGS += -DjavacFailOnError=true
17+
INCUBATOR_FLAGS += -DjavacFailOnError=true -DjavacSource=1.6 -DjavacTarget=1.6
18+
19+
# Order is important; dependencies must go earlier.
20+
CORE_PLUGINS = net.sf.j2s.core net.sf.j2s.ajax net.sf.j2s.ui net.sf.j2s.lib
21+
INCUBATOR_PLUGINS = net.sf.j2s.ui.template.velocity net.sf.j2s.ui.cmdline
22+
CORE_J2SLIB = net.sf.j2s.ajax net.sf.j2s.java.core net.sf.j2s.java.org.eclipse.swt
23+
24+
BUILD_WORKSPACE := $(PWD)/autobuild
25+
ECLIPSE_AUTO = eclipse \
26+
-configuration $(BUILD_WORKSPACE)/configuration \
27+
-user $(BUILD_WORKSPACE) \
28+
-data $(BUILD_WORKSPACE) \
29+
-nosplash -clean
30+
31+
ECLIPSE_ANT = $(ECLIPSE_AUTO) \
32+
-application org.eclipse.ant.core.antRunner
33+
ECLIPSE_ANT_BUILD = $(ECLIPSE_ANT) build.update.jar
34+
ECLIPSE_ANT_CLEAN = if [ -f build.xml ]; then \
35+
$(ECLIPSE_ANT) clean; \
36+
rm -rf build.xml javaCompiler...args; \
37+
fi
38+
ECLIPSE_J2S = $(ECLIPSE_AUTO) \
39+
-application net.sf.j2s.ui.cmdlineApi
40+
41+
all: build-libs
42+
43+
configure:
44+
$(ECLIPSE_ANT) -f configure.xml $(CONFIGURE_FLAGS)
45+
46+
build-plugins: configure
47+
set -e; for i in $(CORE_PLUGINS:%=sources/%); do \
48+
( cd $$i && $(ECLIPSE_ANT_BUILD) $(CORE_FLAGS); ) \
49+
done
50+
set -e; for i in $(INCUBATOR_PLUGINS:%=incubator/%); do \
51+
( cd $$i && $(ECLIPSE_ANT_BUILD) $(INCUBATOR_FLAGS); ) \
52+
done
53+
54+
local-install-plugins: build-plugins
55+
$(MAKE) DESTDIR=$(BUILD_WORKSPACE) eclipsedir= install-plugins
56+
mkdir -p $(BUILD_WORKSPACE)/features
57+
touch $(BUILD_WORKSPACE)/artifacts.xml
58+
$(ECLIPSE_AUTO) -initialize
59+
60+
build-libs: local-install-plugins
61+
set -e; for i in $(CORE_J2SLIB); do \
62+
$(ECLIPSE_J2S) -cmd build -path $$PWD/sources/$$i; \
63+
done
64+
mkdir -p sources/net.sf.j2s.lib/bin sources/net.sf.j2s.lib/j2slib
65+
cd sources/net.sf.j2s.lib/bin && jar xf ../library.jar
66+
cd sources/net.sf.j2s.lib && ant -f build/build.xml
67+
cd sources/net.sf.j2s.lib && zip -r j2slib.zip j2slib
68+
69+
clean:
70+
for i in $(INCUBATOR_PLUGINS:%=incubator/%); do \
71+
( cd $$i && $(ECLIPSE_ANT_CLEAN); ) \
72+
done
73+
for i in $(CORE_PLUGINS:%=sources/%); do \
74+
( cd $$i && $(ECLIPSE_ANT_CLEAN); ) \
75+
done
76+
rm -rf $(BUILD_WORKSPACE)/.metadata
77+
78+
prefix ?= /usr/local
79+
eclipsedir ?= $(prefix)/share/eclipse
80+
datadir ?= $(prefix)/share/java2script
81+
pluginsdir ?= $(eclipsedir)/plugins
82+
83+
install-plugins:
84+
test -z "$(DESTDIR)$(pluginsdir)" || mkdir -p "$(DESTDIR)$(pluginsdir)"
85+
install -t "$(DESTDIR)$(pluginsdir)" \
86+
$(join $(CORE_PLUGINS:%=sources/%/),$(CORE_PLUGINS:%=%_2.0.0.jar)) \
87+
$(join $(INCUBATOR_PLUGINS:%=incubator/%/),$(INCUBATOR_PLUGINS:%=%_1.0.0.*.jar))
88+
89+
install: install-plugins
90+
test -z "$(DESTDIR)$(datadir)" || mkdir -p "$(DESTDIR)$(datadir)"
91+
install -t "$(DESTDIR)$(datadir)" \
92+
sources/net.sf.j2s.lib/j2slib.zip
93+
94+
.PHONY: all configure build-plugins local-install-plugins build-libs clean install-plugins install

configure.xml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="java2script" default="configure" basedir=".">
3+
<!-- IMPORTANT!
4+
5+
This is not a normal ant build file. You need to run it via the Eclipse
6+
AntRunner, like this Unix shell example:
7+
8+
$ eclipse -nosplash -clean \
9+
-configuration $PWD/autobuild/configuration \
10+
-user $PWD/autobuild \
11+
-data $PWD/autobuild \
12+
-application org.eclipse.ant.core.antRunner \
13+
-buildfile build.xml \
14+
-Dplugin.path=/usr/lib/eclipse:/usr/share/eclipse/dropins/jdt
15+
16+
Setting the -configuration, -user, and -data options are important in an
17+
automated build process where you don't want to clobber the default locations.
18+
19+
For more details see http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Ftasks%2Fpde_feature_generating_antcommandline.htm
20+
-->
21+
<target name="configure">
22+
<eclipse.buildScript elements="[email protected]"
23+
buildDirectory="sources"
24+
pluginPath="${plugin.path}"
25+
forceContextQualifier="${forceContextQualifier}" />
26+
<eclipse.buildScript elements="[email protected]"
27+
buildDirectory="sources"
28+
pluginPath="${plugin.path}"
29+
forceContextQualifier="${forceContextQualifier}" />
30+
<eclipse.buildScript elements="[email protected]"
31+
buildDirectory="sources"
32+
pluginPath="${plugin.path}"
33+
forceContextQualifier="${forceContextQualifier}" />
34+
<eclipse.buildScript elements="[email protected]"
35+
buildDirectory="sources"
36+
pluginPath="${plugin.path}"
37+
forceContextQualifier="${forceContextQualifier}" />
38+
<eclipse.buildScript elements="[email protected]"
39+
buildDirectory="incubator"
40+
pluginPath="${plugin.path}${path.separator}sources"
41+
forceContextQualifier="${forceContextQualifier}" />
42+
<eclipse.buildScript elements="[email protected]"
43+
buildDirectory="incubator"
44+
pluginPath="${plugin.path}${path.separator}sources"
45+
forceContextQualifier="${forceContextQualifier}" />
46+
</target>
47+
</project>

0 commit comments

Comments
 (0)