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

versions:use-dep-version does not support "import" scoped poms #308

Closed
Max-Veron opened this issue Sep 19, 2018 · 7 comments
Closed

versions:use-dep-version does not support "import" scoped poms #308

Max-Veron opened this issue Sep 19, 2018 · 7 comments
Labels

Comments

@Max-Veron
Copy link

Apache Maven 3.5.2
versions-maven-plugin 2.7

When using versions:use-dep-version the version of import scoped poms in the dependency management is not changed.
E.g.:

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.example.demo</groupId>
                <artifactId>aggregator</artifactId>
                <version>0.1.2-SNAPSHOT</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
</dependencyManagement>
@Max-Veron
Copy link
Author

A similar issue was already created for versions:use-latest-versions (see: #25)

A similar fix (using the raw model) could be applied:
UseDepVersionMojo:

    @SuppressWarnings( "unchecked" )
    @Override
    protected void update( ModifiedPomXMLEventReader pom )
        throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException
    {

        if ( depVersion == null || depVersion.equals( "" ) )
        {
            throw new IllegalArgumentException( "depVersion must be supplied with use-specific-version, and cannot be blank." );
        }

        if ( !forceVersion && !hasIncludes() )
        {
            throw new IllegalArgumentException( "The use-specific-version goal is intended to be used with a single artifact. Please specify a value for the 'includes' parameter, or use -DforceVersion=true to override this check." );
        }

        try
        {
            if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() )
            {
                DependencyManagement dependencyManagement = PomHelper.getRawModel( getProject() ).getDependencyManagement();
                if ( dependencyManagement != null )
                {
                    useDepVersion( pom, dependencyManagement.getDependencies() );
                }
            }

            if ( getProject().getDependencies() != null && isProcessingDependencies() )
            {
                useDepVersion( pom, getProject().getDependencies() );
            }
        }
        catch ( ArtifactMetadataRetrievalException e )
        {
            throw new MojoExecutionException( e.getMessage(), e );
        } catch (IOException e)
        {
            throw new MojoExecutionException( e.getMessage(), e );
        }
    }

@olamy
Copy link
Member

olamy commented Sep 21, 2018

maybe you have a bit of time for a pull request with an integration test?

Max-Veron pushed a commit to Max-Veron/versions-maven-plugin that referenced this issue Sep 25, 2018
 o Use raw model to update versions in dependency management.
@Max-Veron
Copy link
Author

Done:
#309

@dlafreniere
Copy link

I was having issues with this bug as well, thanks for the awsome fix @Max-Veron !
👍
@olamy any chance of getting this merged?

@JThoennes
Copy link

The same applies to UseNextSnapshotsMojo and most probably other places in the code.

@JThoennes
Copy link

@khmarbaise This is the issues I was referring to, should be extended with all applicable places in the codes. @jannic has an initial patch for the UseNextSnapshotsMojo and is willing to provide a complete one with Unit Tests if there is any chance that this gets into master in reasonable time.

@khmarbaise
Copy link
Member

The first step is to provide the patch ...than I can take a look...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants