in src/exportJarSteps/ExportJarTaskProvider.ts [307:387]
private async resolveClasspaths(outputFolderMap: Map<string, string[]>,
artifactMap: Map<string, string[]>,
testOutputFolderMap: Map<string, string[]>,
testArtifactMap: Map<string, string[]>): Promise<IClasspath[]> {
const regExp: RegExp = /\${(.*?)(:.*)?}/;
let outputElements: string[] = [];
let artifacts: string[] = [];
for (const element of this.stepMetadata.elements) {
if (element.length === 0) {
continue;
}
const matchResult: RegExpMatchArray | null = element.match(regExp);
if (matchResult === null || _.isEmpty(matchResult) || matchResult.length <= 2) {
if (extname(element) === ".jar") {
artifacts.push(this.toAbsolutePosixPath(element));
} else {
outputElements.push(this.toAbsolutePosixPath(element));
}
continue;
}
const projectName: string | undefined = matchResult[2]?.substring(1);
switch (matchResult[1]) {
case ExportJarConstants.DEPENDENCIES:
artifacts = artifacts.concat(this.getJarElementsFromClasspathMapping(matchResult, artifactMap, projectName));
break;
case ExportJarConstants.TEST_DEPENDENCIES:
artifacts = artifacts.concat(this.getJarElementsFromClasspathMapping(matchResult, testArtifactMap, projectName));
break;
case ExportJarConstants.COMPILE_OUTPUT:
outputElements = outputElements.concat(this.getJarElementsFromClasspathMapping(matchResult, outputFolderMap, projectName));
break;
case ExportJarConstants.TEST_COMPILE_OUTPUT:
outputElements = outputElements.concat(this.getJarElementsFromClasspathMapping(matchResult, testOutputFolderMap, projectName));
break;
}
}
const trie: Trie<IUriData> = new Trie<IUriData>();
const globPatterns: string[] = [];
for (const outputElement of outputElements) {
if (outputElement.length === 0) {
continue;
}
if (outputElement[0] !== "!") {
const uri: Uri = Uri.file(platform() === "win32" ? toWinPath(outputElement) : outputElement);
const uriData: IUriData = {
uri: uri.toString(),
};
trie.insert(uriData);
}
globPatterns.push(outputElement);
}
const sources: IClasspath[] = [];
for (const glob of await globby(globPatterns)) {
const tireNode: TrieNode<IUriData | undefined> | undefined = trie.find(
Uri.file(platform() === "win32" ? toWinPath(glob) : glob).fsPath, /* returnEarly = */true);
if (!tireNode?.value?.uri) {
continue;
}
let fsPath = Uri.parse(tireNode.value.uri).fsPath;
if ((await lstat(fsPath)).isFile()) {
fsPath = dirname(fsPath);
}
if (!_.isEmpty(tireNode)) {
const classpath: IClasspath = {
source: glob,
destination: relative(fsPath, glob),
isArtifact: false,
};
sources.push(classpath);
}
}
for (const artifact of await globby(artifacts)) {
const classpath: IClasspath = {
source: artifact,
destination: undefined,
isArtifact: true,
};
sources.push(classpath);
}
return sources;
}