Switch fat jar packaging to boot repackaging instead of jar shading

This commit is contained in:
BoykoAlex
2016-11-01 18:34:36 -04:00
parent 53e31991bf
commit 6df038a93a
6 changed files with 23 additions and 120 deletions

View File

@@ -21,25 +21,6 @@ const DEBUG_ARG = '-agentlib:jdwp=transport=dt_socket,server=y,address=8000,susp
// - we launch the Java project directly from the classes folder produced by Eclipse JDT compiler
// - we add DEBUG_ARG to the launch so that remote debugger can attach on port 8000
function getClasspath(context: VSCode.ExtensionContext):string {
if (DEBUG) {
try {
let projectDir = context.extensionPath;
let classpathFile = Path.resolve(projectDir, "classpath.txt");
//TODO: async read?
let classpath = FS.readFileSync(classpathFile, 'utf8');
classpath = Path.resolve(projectDir, 'target/classes') + ':' + classpath;
return classpath;
} catch (e) {
//Expected if you classpath.txt file isn't packaged. So this means we are running in packaged mode.
VSCode.window.showInformationMessage('classpath file not found, so disabling DEBUG mode '+e);
//Nasty! Be careful, this assumes 'getClasspath' is called before computing debug args.
DEBUG = false;
}
}
return Path.resolve(context.extensionPath, "out", "fat-jar.jar");
}
/** Called when extension is activated */
export function activate(context: VSCode.ExtensionContext) {
let javaExecutablePath = findJavaExecutable('java');
@@ -101,11 +82,13 @@ export function activate(context: VSCode.ExtensionContext) {
cwd: VSCode.workspace.rootPath
};
let child: ChildProcess.ChildProcess;
let classpath = getClasspath(context);
// let classpath = getClasspath(context);
let projectDir = context.extensionPath;
let fatJar = Path.resolve(projectDir, 'target/vscode-application-properties-0.0.1-SNAPSHOT.jar');
let args = [
'-Dserver.port=' + port,
'-cp', classpath,
'org.springframework.ide.vscode.application.properties.Main'
'-jar',
fatJar,
];
if (DEBUG) {
args.unshift(DEBUG_ARG);

View File

@@ -109,27 +109,13 @@
</plugin>
<!-- Configure fat jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<outputFile>${project.basedir}/out/fat-jar.jar</outputFile>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.1.RELEASE</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>

View File

@@ -21,25 +21,6 @@ const DEBUG_ARG = '-agentlib:jdwp=transport=dt_socket,server=y,address=8000,susp
// - we launch the Java project directly from the classes folder produced by Eclipse JDT compiler
// - we add DEBUG_ARG to the launch so that remote debugger can attach on port 8000
function getClasspath(context: VSCode.ExtensionContext):string {
if (DEBUG) {
try {
let projectDir = context.extensionPath;
let classpathFile = Path.resolve(projectDir, "classpath.txt");
//TODO: async read?
let classpath = FS.readFileSync(classpathFile, 'utf8');
classpath = Path.resolve(projectDir, 'target/classes') + ':' + classpath;
return classpath;
} catch (e) {
//Expected if you classpath.txt file isn't packaged. So this means we are running in packaged mode.
VSCode.window.showInformationMessage('classpath file not found, so disabling DEBUG mode '+e);
//Nasty! Be careful, this assumes 'getClasspath' is called before computing debug args.
DEBUG = false;
}
}
return Path.resolve(context.extensionPath, "out", "fat-jar.jar");
}
/** Called when extension is activated */
export function activate(context: VSCode.ExtensionContext) {
let javaExecutablePath = findJavaExecutable('java');
@@ -99,11 +80,11 @@ export function activate(context: VSCode.ExtensionContext) {
cwd: VSCode.workspace.rootPath
};
let child: ChildProcess.ChildProcess;
let classpath = getClasspath(context);
let fatJarFile = Path.resolve(context.extensionPath, 'target/vscode-application-yaml-0.0.1-SNAPSHOT.jar');
let args = [
'-Dserver.port=' + port,
'-cp', classpath,
'org.springframework.ide.vscode.application.yaml.Main'
'-jar',
fatJarFile,
];
if (DEBUG) {
args.unshift(DEBUG_ARG);

View File

@@ -121,27 +121,13 @@
</plugin>
<!-- Configure fat jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<outputFile>${project.basedir}/out/fat-jar.jar</outputFile>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.1.RELEASE</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>

View File

@@ -21,25 +21,6 @@ const DEBUG_ARG = '-agentlib:jdwp=transport=dt_socket,server=y,address=8000,susp
// - we launch the Java project directly from the classes folder produced by Eclipse JDT compiler
// - we add DEBUG_ARG to the launch so that remote debugger can attach on port 8000
function getClasspath(context: VSCode.ExtensionContext):string {
if (DEBUG) {
try {
let projectDir = context.extensionPath;
let classpathFile = Path.resolve(projectDir, "classpath.txt");
//TODO: async read?
let classpath = FS.readFileSync(classpathFile, 'utf8');
classpath = Path.resolve(projectDir, 'target/classes') + ':' + classpath;
return classpath;
} catch (e) {
//Expected if you classpath.txt file isn't packaged. So this means we are running in packaged mode.
VSCode.window.showInformationMessage('classpath file not found, so disabling DEBUG mode '+e);
//Nasty! Be careful, this assumes 'getClasspath' is called before computing debug args.
DEBUG = false;
}
}
return Path.resolve(context.extensionPath, "out", "fat-jar.jar");
}
/** Called when extension is activated */
export function activate(context: VSCode.ExtensionContext) {
VSCode.window.showInformationMessage("Activating manifet.yml extension");
@@ -100,11 +81,11 @@ export function activate(context: VSCode.ExtensionContext) {
cwd: VSCode.workspace.rootPath
};
let child: ChildProcess.ChildProcess;
let classpath = getClasspath(context);
let fatJarFile = Path.resolve(context.extensionPath, 'target/vscode-manifest-yaml-0.0.1-SNAPSHOT.jar');
let args = [
'-Dserver.port=' + port,
'-cp', classpath,
'org.springframework.ide.vscode.manifest.yaml.Main'
'-jar',
fatJarFile,
];
if (DEBUG) {
args.unshift(DEBUG_ARG);

View File

@@ -82,27 +82,13 @@
</plugin>
<!-- Configure fat jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<outputFile>${project.basedir}/out/fat-jar.jar</outputFile>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.1.RELEASE</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>