Skip to content

[MDEP-939] Lock down classifier in dependency:sources goal #409

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

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/it/projects/sources/test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand All @@ -16,3 +16,5 @@
# under the License.

outputFile = target/resolved.txt
# This is intentional to prove that no classifier is passed (read-only value)
classifier = foo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may require a comment that it has no influence anymore...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test can be useful ... even we have a read only property user still can override it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and there are no assertions in this test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess at least the build should not fail, but need to try...

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
package org.apache.maven.plugins.dependency.resolvers;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;

/**
Expand All @@ -36,19 +36,10 @@
threadSafe = true)
public class ResolveDependencySourcesMojo extends ResolveDependenciesMojo {

private static final String SOURCE_CLASSIFIER = "sources";
private static final String SOURCES_CLASSIFIER = "sources";

/**
* Main entry into mojo. Gets the list of dependencies and iterates through resolving the source jars.
*
* @throws MojoExecutionException with a message if an error occurs.
*/
@Override
protected void doExecute() throws MojoExecutionException {
if (this.classifier == null || this.classifier.isEmpty()) {
this.classifier = SOURCE_CLASSIFIER;
}

super.doExecute();
@Parameter(name = "classifier", defaultValue = SOURCES_CLASSIFIER, readonly = true)
public void setClassifier(String classifier) {
this.classifier = classifier;
}
}