Update build config to avoid jar hell

This commit is contained in:
Alexey Andreev 2018-11-22 14:49:30 +03:00
parent b4460b2282
commit 753755918d
20 changed files with 255 additions and 118 deletions

View File

@ -47,5 +47,11 @@
<option name="VARIABLE_ANNOTATION_WRAP" value="1" />
<option name="ENUM_CONSTANTS_WRAP" value="2" />
</codeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>

View File

@ -35,7 +35,7 @@ before_install:
- rm -rf $HOME/.m2
install:
- $MVN_CMD install -Dteavm.build.all=false -P with-idea -P with-eclipse -P with-cli -DskipTests=true -Dmaven.javadoc.skip=true -V
- $MVN_CMD install -Dteavm.build.all=false -P with-idea -P with-cli -DskipTests=true -Dmaven.javadoc.skip=true -V
- pushd tests/src/test/js
- npm config set prefix=$HOME/.node_modules
- npm install

View File

@ -24,8 +24,6 @@
</parent>
<artifactId>teavm-classlib</artifactId>
<packaging>bundle</packaging>
<name>TeaVM Java class library</name>
<description>TeaVM Java class library emulation</description>
@ -49,6 +47,7 @@
<artifactId>teavm-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.teavm</groupId>
@ -79,6 +78,7 @@
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
@ -106,17 +106,6 @@
<configLocation>../checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.teavm.classlib.*</Export-Package>
<Bundle-SymbolicName>teavm-classlib</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
@ -125,6 +114,31 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.teavm:teavm-classlib</include>
</includes>
</artifactSet>
<relocations>
<relocation>cd
<pattern>org.objectweb.asm</pattern>
<shadedPattern>org.teavm.asm</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -24,8 +24,6 @@
</parent>
<artifactId>teavm-core</artifactId>
<packaging>bundle</packaging>
<name>TeaVM core</name>
<description>TeaVM compiler and SPI</description>
@ -48,19 +46,23 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>hppc</artifactId>
<version>0.7.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@ -70,6 +72,7 @@
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
@ -90,16 +93,45 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.teavm.*</Export-Package>
<Bundle-SymbolicName>teavm-core</Bundle-SymbolicName>
</instructions>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>junit:junit</exclude>
<exclude>org:teavm:*</exclude>
<exclude>com.fasterxml.jackson.core:jackson-annotations</exclude>
</excludes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>org.teavm.asm</shadedPattern>
</relocation>
<relocation>
<pattern>org.mozilla</pattern>
<shadedPattern>org.teavm.rhino</shadedPattern>
</relocation>
<relocation>
<pattern>com.carrotsearch.hppc</pattern>
<shadedPattern>org.teavm.hppc</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>org.teavm.apachecommons</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -119,6 +119,10 @@ public class AstWriter {
nameMap.put(name, emitter);
}
public void hoist(Object node) {
hoist((AstNode) node);
}
public void hoist(AstNode node) {
node.visit(n -> {
if (n instanceof Scope) {
@ -133,6 +137,14 @@ public class AstWriter {
});
}
public void print(Object node) throws IOException {
print((AstNode) node);
}
public void print(Object node, int precedence) throws IOException {
print((AstNode) node, precedence);
}
public void print(AstNode node) throws IOException {
print(node, PRECEDENCE_COMMA);
}

View File

@ -15,15 +15,25 @@
*/
package org.teavm.backend.javascript.rendering;
import java.io.IOException;
import java.io.Reader;
import org.mozilla.javascript.CompilerEnvirons;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.Parser;
public class JSParser extends Parser {
public JSParser(Object compilerEnv, Object errorReporter) {
this((CompilerEnvirons) compilerEnv, (ErrorReporter) errorReporter);
}
public JSParser(CompilerEnvirons compilerEnv, ErrorReporter errorReporter) {
super(compilerEnv, errorReporter);
}
public JSParser(Object compilerEnv) {
this((CompilerEnvirons) compilerEnv);
}
public JSParser(CompilerEnvirons compilerEnv) {
super(compilerEnv);
}
@ -35,4 +45,8 @@ public class JSParser extends Parser {
public void exitFunction() {
--nestingOfFunction;
}
public Object parseAsObject(Reader sourceReader, String sourceURI, int lineno) throws IOException {
return parse(sourceReader, sourceURI, lineno);
}
}

View File

@ -45,6 +45,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
@ -65,6 +70,31 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.teavm:teavm-jso-impl</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.mozilla</pattern>
<shadedPattern>org.teavm.rhino</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -587,7 +587,7 @@ class JSClassProcessor {
JSParser parser = new JSParser(env, errorReporter);
AstRoot rootNode;
try {
rootNode = parser.parse(new StringReader("function(){" + script + "}"), null, 0);
rootNode = (AstRoot) parser.parseAsObject(new StringReader("function(){" + script + "}"), null, 0);
} catch (IOException e) {
throw new RuntimeException("IO Error occurred", e);
}

View File

@ -28,8 +28,6 @@
</parent>
<artifactId>teavm-metaprogramming-api</artifactId>
<packaging>bundle</packaging>
<name>TeaVM metaprogramming API</name>
<description>Declaration of interfaces and annotations for TeaVM metaprogramming</description>
@ -70,17 +68,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.teavm.metaprogramming.*</Export-Package>
<Bundle-SymbolicName>teavm-metaprogramming-api</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -28,8 +28,6 @@
<artifactId>teavm-metaprogramming-impl</artifactId>
<packaging>bundle</packaging>
<name>TeaVM metaprogramming API implementation</name>
<description>Implementation of metaprogramming API</description>
@ -45,6 +43,20 @@
<artifactId>teavm-metaprogramming-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -82,15 +94,33 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.teavm.metaprogramming.*</Export-Package>
<Bundle-SymbolicName>teavm-metaprogramming-api</Bundle-SymbolicName>
</instructions>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.teavm:teavm-metaprogramming-impl</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>org.teavm.asm</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>org.teavm.apachecommons</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -24,8 +24,6 @@
</parent>
<artifactId>teavm-platform</artifactId>
<packaging>bundle</packaging>
<name>TeaVM platform</name>
<description>A low-level classes that help to implement Java class library</description>
@ -50,17 +48,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.teavm.platform.*</Export-Package>
<Bundle-SymbolicName>teavm-platform</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>

10
pom.xml
View File

@ -208,6 +208,11 @@
<artifactId>rhino</artifactId>
<version>${rhino.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -287,11 +292,6 @@
<configLocation>../checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>

View File

@ -77,6 +77,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>hppc</artifactId>
<version>0.7.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@ -25,8 +25,6 @@
</parent>
<artifactId>teavm-chrome-rdp</artifactId>
<packaging>bundle</packaging>
<name>TeaVM debugging backend for Google Chrome RDP</name>
<description>TeaVM debugging backend for Google Chrome RDP</description>
@ -82,17 +80,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.teavm.chromerdp</Export-Package>
<Bundle-SymbolicName>teavm-chrome-rdp</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -93,7 +93,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>

View File

@ -24,7 +24,6 @@
<relativePath>../..</relativePath>
</parent>
<artifactId>teavm-tooling</artifactId>
<packaging>bundle</packaging>
<name>TeaVM tooling core</name>
<description>TeaVM API that helps to create tooling</description>
@ -40,6 +39,11 @@
<artifactId>jackson-annotations</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
@ -60,16 +64,43 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.teavm.*</Export-Package>
<Bundle-SymbolicName>teavm-tooling</Bundle-SymbolicName>
</instructions>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.teavm:teavm-tooling</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>org.teavm.asm</shadedPattern>
</relocation>
<relocation>
<pattern>org.mozilla</pattern>
<shadedPattern>org.teavm.rhino</shadedPattern>
</relocation>
<relocation>
<pattern>com.carrotsearch.hppc</pattern>
<shadedPattern>org.teavm.hppc</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>org.teavm.apachecommons</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -62,11 +62,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.teavm</groupId>
<artifactId>teavm-metaprogramming-impl</artifactId>
<version>${teavm.version}</version>
</dependency>
</dependencies>
<build>
@ -128,16 +123,6 @@
<exclude>com.jetbrains.intellij.idea:ideaIC:zip:*</exclude>
</excludes>
</atrifactSet>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>org.teavm.asm</shadedPattern>
</relocation>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>org.teavm.asm</shadedPattern>
</relocation>
</relocations>
<createDependencyReducedPom>false</createDependencyReducedPom>
<outputFile>dependencies/teavm.jar</outputFile>
</configuration>

View File

@ -74,6 +74,12 @@ import org.teavm.vm.TeaVMProgressFeedback;
import org.teavm.vm.TeaVMProgressListener;
class TeaVMBuild {
private static final String[] BLACKLISTED_CLASSES = {
"org/teavm/jso/impl/JSOPlugin.class",
"org/teavm/metaprogramming/impl/MetaprogrammingImpl.class",
"org/teavm/classlib/impl/JCLPlugin.class"
};
private final CompileContext context;
private final List<String> classPathEntries = new ArrayList<>();
private List<String> directoryClassPathEntries;
@ -83,13 +89,15 @@ class TeaVMBuild {
private final Map<File, int[]> fileLineCache = new HashMap<>();
private BuildStrategy buildStrategy;
private BuildOutputConsumer outputConsumer;
private boolean incrementaSupported;
TeaVMBuild(CompileContext context, TeaVMBuilderAssistant assistant, BuildStrategy buildStrategy,
BuildOutputConsumer outputConsumer) {
BuildOutputConsumer outputConsumer, boolean incrementalSupported) {
this.context = context;
this.assistant = assistant;
this.buildStrategy = buildStrategy;
this.outputConsumer = outputConsumer;
this.incrementaSupported = incrementalSupported;
}
boolean perform(JpsModule module, TeaVMBuildTarget target) throws IOException, BuildException {
@ -122,7 +130,7 @@ class TeaVMBuild {
buildStrategy.setTargetType(config.getTargetType());
buildStrategy.setTargetDirectory(config.getTargetDirectory());
buildStrategy.setProgressListener(createProgressListener(context));
buildStrategy.setIncremental(!isRebuild(target));
buildStrategy.setIncremental(incrementaSupported && !isRebuild(target));
Properties properties = new Properties();
for (TeaVMProperty property : config.getProperties()) {
@ -484,7 +492,7 @@ class TeaVMBuild {
JpsModuleDependency moduleDependency = (JpsModuleDependency) dependency;
File dependencyOutput = JpsJavaExtensionService.getInstance().getOutputDirectory(
moduleDependency.getModule(), false);
if (dependencyOutput != null) {
if (dependencyOutput != null && !isBlacklistedDependency(dependencyOutput)) {
classPathEntries.add(dependencyOutput.getPath());
}
for (JpsModuleSourceRoot sourceRoot : moduleDependency.getModule().getSourceRoots()) {
@ -512,6 +520,15 @@ class TeaVMBuild {
}
}
private static boolean isBlacklistedDependency(File dependency) {
for (String entry : BLACKLISTED_CLASSES) {
if (new File(dependency, entry).exists()) {
return true;
}
}
return false;
}
private File getFileFromUrl(String url) {
if (url.startsWith("file://")) {
return new File(url.substring("file://".length()));

View File

@ -77,7 +77,7 @@ public class TeaVMBuilder extends TargetBuilder<BuildRootDescriptor, TeaVMBuildT
BuildStrategy buildStrategy = buildService != null
? new RemoteBuildStrategy(buildService)
: createInProcessBuilder();
TeaVMBuild build = new TeaVMBuild(context, assistant, buildStrategy, outputConsumer);
TeaVMBuild build = new TeaVMBuild(context, assistant, buildStrategy, outputConsumer, buildService != null);
build.perform(target.getModule(), target);
} catch (BuildException e) {

View File

@ -29,10 +29,10 @@ curl --ftp-create-dirs -T .idea-repository.xml \
#
# Upload Eclipse plugin
#
cd tools/eclipse/updatesite/target/repository
find . -type f -exec curl \
--ftp-create-dirs \
-u $TEAVM_FTP_LOGIN:$TEAVM_FTP_PASSWORD \
-T {} \
ftp://$TEAVM_FTP_HOST/httpdocs/eclipse/update-site/$BASE_VERSION-dev/{} \;
cd ../../../../..
#cd tools/eclipse/updatesite/target/repository
# find . -type f -exec curl \
# --ftp-create-dirs \
# -u $TEAVM_FTP_LOGIN:$TEAVM_FTP_PASSWORD \
# -T {} \
# ftp://$TEAVM_FTP_HOST/httpdocs/eclipse/update-site/$BASE_VERSION-dev/{} \;
#cd ../../../../..