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

feat: add support for using custom .m2 directory #3573

Merged
merged 9 commits into from
Jun 13, 2022
7 changes: 7 additions & 0 deletions packages/jsii-pacmak/bin/jsii-pacmak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ import { VERSION_DESC } from '../lib/version';
// This is expected to be a path, which should be normalized
normalize: true,
})
.option('maven-local-repository', {
type: 'string',
desc: 'Configure a custom path (relative to current working directory) to a repository when packaging a Java package.',
defaultDescription: 'A temporary directory is used.',
default: undefined,
hidden: true,
})
.option('validate-assemblies', {
type: 'boolean',
desc: 'Whether jsii assemblies should be validated. This can be expensive and is skipped by default.',
Expand Down
7 changes: 5 additions & 2 deletions packages/jsii-pacmak/lib/targets/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ export class JavaBuilder implements TargetBuilder {
logging.debug('local maven repos:', localRepos);

const profileName = 'local-jsii-modules';
const localRepository = this.options.arguments['maven-local-repository'];
const settings = xmlbuilder
.create(
{
Expand All @@ -295,8 +296,10 @@ export class JavaBuilder implements TargetBuilder {
],
// Do *not* attempt to ask the user for stuff...
interactiveMode: false,
// Use a non-default local repository to isolate from cached artifacts...
localRepository: path.resolve(where, '.m2', 'repository'),
// Use a non-default local repository (unless java-custom-cache-path arg is provided) to isolate from cached artifacts...
localRepository: localRepository
? path.resolve(localRepository)
: path.resolve(where, '.m2', 'repository'),
// Register locations of locally-sourced dependencies
profiles: {
profile: {
Expand Down