Fix Clojure dependencies (#8249)

This commit is contained in:
Frank Leon Rose
2025-11-27 11:29:43 -05:00
committed by GitHub
parent 65bac91c37
commit e35662fbb5
2 changed files with 16 additions and 5 deletions

View File

@@ -35,14 +35,15 @@ import {ClojureParser} from './argument-parsers.js';
import {JavaCompiler} from './java.js';
export class ClojureCompiler extends JavaCompiler {
public compilerWrapperPath: string;
compilerWrapperPath: string;
defaultDeps: string;
configDir: string;
javaHome: string;
static override get key() {
return 'clojure';
}
javaHome: string;
constructor(compilerInfo: PreliminaryCompilerInfo, env: CompilationEnvironment) {
super(compilerInfo, env);
// Use invalid Clojure filename to avoid clashing with name determined by namespace
@@ -52,6 +53,13 @@ export class ClojureCompiler extends JavaCompiler {
this.compilerProps('compilerWrapper', '') ||
utils.resolvePathFromAppRoot('etc', 'scripts', 'clojure_wrapper.clj');
this.compiler.supportsClojureMacroExpView = true;
this.configDir =
this.compilerProps<string>(`compiler.${this.compiler.id}.config_dir`) ||
path.resolve(path.dirname(this.compiler.exe), '../.config');
const repoDir =
this.compilerProps<string>(`compiler.${this.compiler.id}.repo_dir`) ||
path.resolve(path.dirname(this.compiler.exe), '../.m2/repository');
this.defaultDeps = `{:mvn/local-repo "${repoDir}"}`;
}
override getDefaultExecOptions() {
@@ -59,6 +67,7 @@ export class ClojureCompiler extends JavaCompiler {
if (this.javaHome) {
execOptions.env.JAVA_HOME = this.javaHome;
}
execOptions.env.CLJ_CONFIG = this.configDir;
return execOptions;
}
@@ -93,7 +102,7 @@ export class ClojureCompiler extends JavaCompiler {
compiler: string,
execOptions: ExecutionOptionsWithEnv,
): Promise<string[]> {
const pathOption = ['-Spath'];
const pathOption = ['-Sdeps', this.defaultDeps, '-Spath'];
const output = await this.exec(compiler, pathOption, execOptions);
const cp = dirPath + ':' + output.stdout.trim();
return ['-Scp', cp];
@@ -121,6 +130,8 @@ export class ClojureCompiler extends JavaCompiler {
const classpathArgument = await this.getClojureClasspathArgument(execOptions.customCwd, compiler, execOptions);
const wrapperInvokeArgument = ['-M', this.compilerWrapperPath];
const clojureOptions = _.compact([
'-Sdeps',
this.defaultDeps,
...classpathArgument,
...wrapperInvokeArgument,
...userOptions,

View File

@@ -35,7 +35,7 @@ const languages = {
};
const info = {
exe: null,
exe: '/opt/clojure/test-version/bin/clojure',
remote: true,
lang: languages.clojure.id,
} as unknown as CompilerInfo;