Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using fat jar and copy the dependencies into the lib folder #595

Merged
merged 2 commits into from
Jan 29, 2019
Merged
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
4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ gulp.task('build-plugin', (done) => {
cp.execSync(`${mvnw()} clean package`, { cwd: serverDir, stdio: [0, 1, 2] });
gulp.src(path.join(serverDir, 'com.microsoft.java.test.plugin/target/*.jar'))
.pipe(gulp.dest('./server'));
gulp.src(path.join(serverDir, 'com.microsoft.java.test.runner/target/*-jar-with-dependencies.jar'))
gulp.src(path.join(serverDir, 'com.microsoft.java.test.runner/target/*.jar'))
.pipe(gulp.dest('./server'));
gulp.src(path.join(serverDir, 'com.microsoft.java.test.runner/target/lib/*.jar'))
.pipe(gulp.dest('./server/lib'));
done();
});

Expand Down
90 changes: 82 additions & 8 deletions java-extension/com.microsoft.java.test.plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,49 @@
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.15</version>
<executions>
<!-- Ensures that both integration-test and verify
goals of the Failsafe Maven plugin are executed. -->
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- Sets the VM argument line used when
integration tests are run. -->
<argLine>${failsafeArgLine}</argLine>
<!-- Skips integration tests if the value
of skip.integration.tests property is true -->
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<?m2e execute onConfiguration?>
<id>get-libs</id>
<goals>
<goal>copy</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<skip>false</skip>
<outputDirectory>${basedir}/lib/</outputDirectory>
<!-- baseVersion is to avoid SNAPSHOT dependencies
being copied with ever daily changing timestamp -->
<useBaseVersion>true</useBaseVersion>
<artifactItems>
<artifactItem>
<groupId>com.google.code.gson</groupId>
Expand All @@ -35,6 +65,50 @@
</artifactItems>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>photon</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/photon</url>
</repository>
<repository>
<id>oss.sonatype.org</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>LSP4J</id>
<layout>p2</layout>
<url>http://download.eclipse.org/lsp4j/updates/releases/0.5.0/</url>
</repository>
<repository>
<id>JDT.LS</id>
<layout>p2</layout>
<url>http://download.eclipse.org/jdtls/snapshots/repository/latest/</url>
</repository>
<repository>
<id>JBOLL.TOOLS</id>
<layout>p2</layout>
<url>http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-apt/1.5.0-2018-05-16_00-46-30-H11</url>
</repository>
</repositories>
</project>
42 changes: 28 additions & 14 deletions java-extension/com.microsoft.java.test.runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,42 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.microsoft.java.test.runner.Launcher</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>make-assembly</id>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.microsoft.java.test.runner.Launcher</mainClass>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down
79 changes: 0 additions & 79 deletions java-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,86 +47,7 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.15</version>
<executions>
<!-- Ensures that both integration-test and verify
goals of the Failsafe Maven plugin are executed. -->
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- Sets the VM argument line used when
integration tests are run. -->
<argLine>${failsafeArgLine}</argLine>
<!-- Skips integration tests if the value
of skip.integration.tests property is true -->
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<?m2e execute onConfiguration?>
<id>get-libs</id>
<goals>
<goal>copy</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<skip>false</skip>
<outputDirectory>${basedir}/lib/</outputDirectory>
<!-- baseVersion is to avoid SNAPSHOT dependencies
being copied with ever daily changing timestamp -->
<useBaseVersion>true</useBaseVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<repositories>
<repository>
<id>photon</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/photon</url>
</repository>
<repository>
<id>oss.sonatype.org</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>LSP4J</id>
<layout>p2</layout>
<url>http://download.eclipse.org/lsp4j/updates/releases/0.5.0/</url>
</repository>
<repository>
<id>JDT.LS</id>
<layout>p2</layout>
<url>http://download.eclipse.org/jdtls/snapshots/repository/latest/</url>
</repository>
<repository>
<id>JBOLL.TOOLS</id>
<layout>p2</layout>
<url>http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-apt/1.5.0-2018-05-16_00-46-30-H11</url>
</repository>
</repositories>
</project>
19 changes: 13 additions & 6 deletions src/runners/baseRunner/BaseRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ export abstract class BaseRunner implements ITestRunner {
}

public async setup(tests: ITestItem[], isDebug: boolean = false, config?: IExecutionConfig): Promise<void> {
const runnerJarFilePath: string = await this.getRunnerJarFilePath();
this.port = isDebug ? await getPort() : undefined;
this.tests = tests;
this.isDebug = isDebug;
const testPaths: string[] = tests.map((item: ITestItem) => Uri.parse(item.uri).fsPath);
const classpaths: string[] = [...await resolveRuntimeClassPath(testPaths), runnerJarFilePath];
const classpaths: string[] = [...await resolveRuntimeClassPath(testPaths), await this.getRunnerJarFilePath(), await this.getRunnerLibPath()];
this.storagePathForCurrentSession = path.join(this.storagePath || os.tmpdir(), new Date().getTime().toString());
this.classpath = await classpathUtils.getClassPathString(classpaths, this.storagePathForCurrentSession);
this.config = config;
Expand Down Expand Up @@ -188,10 +187,18 @@ export abstract class BaseRunner implements ITestRunner {
protected abstract getRunnerCommandParams(): string[];

private async getRunnerJarFilePath(): Promise<string> {
const runnerPath: string = path.join(this.runnerDir, 'com.microsoft.java.test.runner-jar-with-dependencies.jar');
if (await fse.pathExists(runnerPath)) {
return runnerPath;
return this.getPath('com.microsoft.java.test.runner.jar');
}

private async getRunnerLibPath(): Promise<string> {
return this.getPath('lib');
}

private async getPath(subPath: string): Promise<string> {
const fullPath: string = path.join(this.runnerDir, subPath);
if (await fse.pathExists(fullPath)) {
return fullPath;
}
throw new Error('Failed to find runner jar file.');
throw new Error(`Failed to find path: ${fullPath}`);
}
}