We've started using an AWS CodeArtifact Maven repository. Before connecting, developers must run a command ("aws") to acquire a temporary access token. How can I configure Maven to acquire and use this token automatically, without requiring running a script, configuring an IDE or changing the simple command line "mvn install"?
Maybe there's a trick I'm overlooking.
The token must be "interpolated" in the element <server>/<password> in settings.xml. This file will pre-process either an environment variable ({$env.token}) or a Java system property ({$token}). It will not process a project property.
- The repository password cannot be specified within the POM file.
- The settings.xml file cannot use project properties.
- The exec-maven-plugin cannot set an environment variable in the parent process (Windows). It can write to a file.
- The properties-maven-plugin cannot set a dynamic system property (e.g., from a file or script output).
- The surefire plugin binds to the test phase and forks a JVM.
- The Windows setx command does not affect the running process.
UPDATE: Maven downloads repository metadata before the first phase, so no plugin will solve the problem.