-
Notifications
You must be signed in to change notification settings - Fork 72
[MASSEMBLY-832] Consider dependency optional attribute when gather de… #49
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
base: master
Are you sure you want to change the base?
Conversation
src/main/mdo/assembly-component.mdo
Outdated
<name>useOptionalDependencies</name> | ||
<version>2.1.0+</version> | ||
<type>boolean</type> | ||
<defaultValue>false</defaultValue> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the defallt here should be true to avoid changing existing behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the default to true to retain the previous behavior.
<field> | ||
<name>useOptionalDependencies</name> | ||
<version>2.1.0+</version> | ||
<type>boolean</type> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a boolean or a list? What if someone wants to include some optional dependencies and not others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They could possibly achieve this by declaring a separate dependencySet
. It doesn't make much sense to make this very specific cause in that case we could use the existing include/exclude options.
private Set<Artifact> resolveDependencyArtifacts( DependencySet dependencySet, Set<Artifact> artifacts ) throws Exception | ||
{ | ||
MavenProject project = new MavenProject(new Model()); | ||
Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no logging at all please. Use a SilentLogger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the logger as part of the rebase.
Resolve #1056 |
Thanks for the review @elharo ! I rebased the PR against master, addressed all review comments, and also added a new integration test for the new functionality. |
|
||
@Test | ||
public void testGetDependencyArtifacts_ShouldFilterOptionalArtifactsExplicitly() throws Exception { | ||
Artifact am1 = mockArtifact(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
am1 --> artifact1
am2 --> artifact2
here and elsewhere avoid abbreviations
} | ||
|
||
private static Artifact mockArtifact(int id) { | ||
Artifact a = mock(Artifact.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a --> artifact
@@ -387,6 +388,54 @@ public void testGetDependencyArtifacts_ShouldFilterOneDependencyArtifactViaInclu | |||
assertSame(am1, result.iterator().next()); | |||
} | |||
|
|||
@Test | |||
public void testGetDependencyArtifacts_ShouldNotFilterOptionalArtifactsByDefault() throws Exception { | |||
Artifact am1 = mockArtifact(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to sue mocks here. You can simply create a DefaultArtifact.
https://issues.apache.org/jira/browse/MASSEMBLY-832
Maven allows to declare dependencies as optional and this is important for various reasons (e.g., avoiding licensing problems).
This change provides a convenient way to include/exclude optional dependencies in a
dependencySet
.By default optional dependencies are excluded from the
dependencySet
. An optional dependency shouldn't be packaged, distributed, or transitively inherited unless specified explicitly so it makes sense to exclude them by default.Following this checklist to help us incorporate your contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MASSEMBLY-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MASSEMBLY-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean verify
).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under the Apache License Version 2.0, January 2004 you have to acknowledge this by using the following check-box.