Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# To use this file, run:
#
# $ make CONFIGURE_FLAGS="-Dplugin.path=/path/to/your/eclipse/plugins"
#
# For example, on Debian GNU/Linux:
#
# $ make CONFIGURE_FLAGS="-Dplugin.path=/usr/lib/eclipse:/usr/share/eclipse/dropins/jdt"
#
# You can also add e.g. "-DforceContextQualifier=none" to make the jars be
# output under a stable filename.
#
# Due to https://github.com/zhourenjian/java2script/issues/7 you may need to
# run this using xvfb https://packages.debian.org/sid/xvfb
#
CONFIGURE_FLAGS +=
CORE_FLAGS += -DjavacFailOnError=true
INCUBATOR_FLAGS += -DjavacFailOnError=true -DjavacSource=1.6 -DjavacTarget=1.6

# Order is important; dependencies must go earlier.
CORE_PLUGINS = net.sf.j2s.core net.sf.j2s.ajax net.sf.j2s.ui net.sf.j2s.lib
INCUBATOR_PLUGINS = net.sf.j2s.ui.template.velocity net.sf.j2s.ui.cmdline
CORE_J2SLIB = net.sf.j2s.ajax net.sf.j2s.java.core net.sf.j2s.java.org.eclipse.swt

BUILD_WORKSPACE := $(PWD)/autobuild
ECLIPSE_AUTO = eclipse \
-configuration $(BUILD_WORKSPACE)/configuration \
-user $(BUILD_WORKSPACE) \
-data $(BUILD_WORKSPACE) \
-nosplash -clean

ECLIPSE_ANT = $(ECLIPSE_AUTO) \
-application org.eclipse.ant.core.antRunner
ECLIPSE_ANT_BUILD = $(ECLIPSE_ANT) build.update.jar
ECLIPSE_ANT_CLEAN = if [ -f build.xml ]; then \
$(ECLIPSE_ANT) clean; \
rm -rf build.xml javaCompiler...args; \
fi
ECLIPSE_J2S = $(ECLIPSE_AUTO) \
-application net.sf.j2s.ui.cmdlineApi

all: build-libs

configure:
$(ECLIPSE_ANT) -f configure.xml $(CONFIGURE_FLAGS)

build-plugins: configure
sh switch-build-command.sh sources/net.sf.j2s.ajax/.project \
-net.sf.j2s.core.java2scriptbuilder +org.eclipse.jdt.core.javabuilder
set -e; for i in $(CORE_PLUGINS:%=sources/%); do \
( cd $$i && $(ECLIPSE_ANT_BUILD) $(CORE_FLAGS); ) \
done
set -e; for i in $(INCUBATOR_PLUGINS:%=incubator/%); do \
( cd $$i && $(ECLIPSE_ANT_BUILD) $(INCUBATOR_FLAGS); ) \
done

local-install-plugins: build-plugins
$(MAKE) DESTDIR=$(BUILD_WORKSPACE) eclipsedir= install-plugins
mkdir -p $(BUILD_WORKSPACE)/features
touch $(BUILD_WORKSPACE)/artifacts.xml
$(ECLIPSE_AUTO) -initialize

# Work around https://bugs.eclipse.org/bugs/show_bug.cgi?id=465693 (actually a JDK bug)
# Otherwise the net.sf.j2s.java.core build wil segfault about half of the time.
# Annoyingly, the segfault causes java to exit 0; I was unable to figure out why.
# So we add some extra checks, testing for the absence of crash logs.
BADMETHOD1 = org/eclipse/jdt/internal/compiler/parser/TypeConverter.decodeType
WORKAROUND1 = -vmargs -XX:CompileCommand=exclude,$(BADMETHOD1)
build-libs: local-install-plugins
sh switch-build-command.sh sources/net.sf.j2s.ajax/.project \
+net.sf.j2s.core.java2scriptbuilder -org.eclipse.jdt.core.javabuilder
test ! -f *err*.log
set -e; for i in $(CORE_J2SLIB); do \
$(ECLIPSE_J2S) -cmd build -path $$PWD/sources/$$i $(WORKAROUND1); \
test ! -f *err*.log; \
done
mkdir -p sources/net.sf.j2s.lib/bin sources/net.sf.j2s.lib/j2slib
cd sources/net.sf.j2s.lib/bin && jar xf ../library.jar
cd sources/net.sf.j2s.lib && ant -f build/build.xml
cd sources/net.sf.j2s.lib && zip -r j2slib.zip j2slib

clean:
for i in $(INCUBATOR_PLUGINS:%=incubator/%); do \
( cd $$i && $(ECLIPSE_ANT_CLEAN); ) \
done
for i in $(CORE_PLUGINS:%=sources/%); do \
( cd $$i && $(ECLIPSE_ANT_CLEAN); ) \
done
rm -rf $(BUILD_WORKSPACE)/.metadata

prefix ?= /usr/local
eclipsedir ?= $(prefix)/share/eclipse
datadir ?= $(prefix)/share/java2script
pluginsdir ?= $(eclipsedir)/plugins

install-plugins:
test -z "$(DESTDIR)$(pluginsdir)" || mkdir -p "$(DESTDIR)$(pluginsdir)"
install -t "$(DESTDIR)$(pluginsdir)" \
$(join $(CORE_PLUGINS:%=sources/%/),$(CORE_PLUGINS:%=%_2.0.0.jar)) \
$(join $(INCUBATOR_PLUGINS:%=incubator/%/),$(INCUBATOR_PLUGINS:%=%_1.0.0.*.jar))

install: install-plugins
test -z "$(DESTDIR)$(datadir)" || mkdir -p "$(DESTDIR)$(datadir)"
install -t "$(DESTDIR)$(datadir)" \
sources/net.sf.j2s.lib/j2slib.zip

.PHONY: all configure build-plugins local-install-plugins build-libs clean install-plugins install
47 changes: 47 additions & 0 deletions configure.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="java2script" default="configure" basedir=".">
<!-- IMPORTANT!

This is not a normal ant build file. You need to run it via the Eclipse
AntRunner, like this Unix shell example:

$ eclipse -nosplash -clean \
-configuration $PWD/autobuild/configuration \
-user $PWD/autobuild \
-data $PWD/autobuild \
-application org.eclipse.ant.core.antRunner \
-buildfile build.xml \
-Dplugin.path=/usr/lib/eclipse:/usr/share/eclipse/dropins/jdt

Setting the -configuration, -user, and -data options are important in an
automated build process where you don't want to clobber the default locations.

For more details see http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Ftasks%2Fpde_feature_generating_antcommandline.htm
-->
<target name="configure">
<eclipse.buildScript elements="plugin@net.sf.j2s.core"
buildDirectory="sources"
pluginPath="${plugin.path}"
forceContextQualifier="${forceContextQualifier}" />
<eclipse.buildScript elements="plugin@net.sf.j2s.ajax"
buildDirectory="sources"
pluginPath="${plugin.path}"
forceContextQualifier="${forceContextQualifier}" />
<eclipse.buildScript elements="plugin@net.sf.j2s.lib"
buildDirectory="sources"
pluginPath="${plugin.path}"
forceContextQualifier="${forceContextQualifier}" />
<eclipse.buildScript elements="plugin@net.sf.j2s.ui"
buildDirectory="sources"
pluginPath="${plugin.path}"
forceContextQualifier="${forceContextQualifier}" />
<eclipse.buildScript elements="plugin@net.sf.j2s.ui.template.velocity"
buildDirectory="incubator"
pluginPath="${plugin.path}${path.separator}sources"
forceContextQualifier="${forceContextQualifier}" />
<eclipse.buildScript elements="plugin@net.sf.j2s.ui.cmdline"
buildDirectory="incubator"
pluginPath="${plugin.path}${path.separator}sources"
forceContextQualifier="${forceContextQualifier}" />
</target>
</project>
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.ajax/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<classpathentry kind="src" path="ajaxswt"/>
<classpathentry kind="src" path="ajaxrpc"/>
<classpathentry kind="src" path="ajaxpipe"/>
<classpathentry kind="var" path="JAVAX_SERVLET"/>
<classpathentry kind="lib" path="lib/javax.servlet_2.5.0.v200910301333.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.Annotation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2013 IBM Corporation and others.
* Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -57,8 +57,7 @@ public abstract class AbstractImageBuilder implements ICompilerRequestor, ICompi
protected boolean keepStoringProblemMarkers;
protected SimpleSet filesWithAnnotations = null;

//2000 is best compromise between space used and speed
public static int MAX_AT_ONCE = Integer.getInteger(JavaModelManager.MAX_COMPILED_UNITS_AT_ONCE, 2000).intValue();
public static int MAX_AT_ONCE = 2000; // best compromise between space used and speed
public final static String[] JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES = {
IMarker.MESSAGE,
IMarker.SEVERITY,
Expand Down Expand Up @@ -294,7 +293,7 @@ protected void compile(SourceFile[] units) {
}

int unitsLength = units.length;
this.compiledAllAtOnce = MAX_AT_ONCE == 0 || unitsLength <= MAX_AT_ONCE;
this.compiledAllAtOnce = unitsLength <= MAX_AT_ONCE;
if (this.compiledAllAtOnce) {
// do them all now
if (JavaBuilder.DEBUG)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2013 IBM Corporation and others.
* Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -799,7 +799,7 @@ protected void resetCollections() {
protected void updateProblemsFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
if (CharOperation.equals(sourceFile.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)) {
IResource pkgResource = sourceFile.resource.getParent();
pkgResource.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
pkgResource.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
}
IMarker[] markers = JavaBuilder.getProblemsFor(sourceFile.resource);
CategorizedProblem[] problems = result.getProblems();
Expand Down
Loading