Skip to content

MavenSession reference missing in ArchetypeGenerationRequest when running "integration-test" goal #980

@stefanseifert

Description

@stefanseifert

Affected version

3.4.1

Bug description

we have a archetype-post-generate.groovy that needs to run another maven call from within a script to do some extra work after the project was generated from the archetype. we need to make sure, that this "nested" maven call used the same maven settings XML file that the user has provided when running maven initially.

this works in the groovy script buy using a statement like this to get a references to the provides user settings file:

def mavenSettings = request.mavenSession?.request?.userSettingsFile?.absolutePath

because a reference to MavenSession is provided in

public MavenSession getMavenSession() {
return mavenSession;
}

however, when generating a maven project not via the generate goal, but via running an integration test via the integration-test goal, the maven setting in ArchetypeGenerationRequest is null, because it's not passed over here:

ArchetypeGenerationRequest request = new ArchetypeGenerationRequest()
.setArchetypeGroupId(archetypeGroupId)
.setArchetypeArtifactId(archetypeArtifactId)
.setArchetypeVersion(archetypeVersion)
.setGroupId(properties.getProperty(Constants.GROUP_ID))
.setArtifactId(properties.getProperty(Constants.ARTIFACT_ID))
.setVersion(properties.getProperty(Constants.VERSION))
.setPackage(properties.getProperty(Constants.PACKAGE))
.setRepositorySession(session.getRepositorySession())
.setOutputDirectory(basedir)
.setProperties(properties);

in my pov it doesn't make sense to provide less context properties in ITs compared to the actual run of a plugin. i will provide a PR that passed over the maven sesssion also for the IT runs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions