-
Notifications
You must be signed in to change notification settings - Fork 128
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
#201 - Reduce log level for unknown dependencies to debug to reduce l… #300
Draft
ercpe
wants to merge
12
commits into
mojohaus:master
Choose a base branch
from
COMINTO:201-reduce-log-level
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a799c77
#201 - Reduce log level for unknown dependencies to debug to reduce l…
63cd4f1
Merge branch 'master' of https://github.com/mojohaus/license-maven-pl…
wuwu2000 f05f7a2
reduce log level by parameter
wuwu2000 5d54237
fix license javaDoc
wuwu2000 ce39c03
make postbuild comparisons runnable under windows
wuwu2000 74bac01
also use unkownFileRemedy when unkown dependency in use
wuwu2000 c218bd2
respect checkstyle
wuwu2000 bdba126
respect checkstyle
wuwu2000 fd395b8
respect checkstyle
wuwu2000 138485d
enable unit test for windows
wuwu2000 51b0b49
pass ID to handleUnkownDependency to have a cleaner API
wuwu2000 9032b2d
add some integration tests to assert unkownFileRemedy
wuwu2000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/org/codehaus/mojo/license/UnkownFileRemedy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/****************************************************************************** | ||
* COMINTO GmbH | ||
* Klosterstr. 49 | ||
* 40211 Düsseldorf | ||
* Germany | ||
* | ||
* (c) Copyright 2020 by COMINTO GmbH | ||
* ALL RIGHTS RESERVED | ||
* | ||
******************************************************************************/ | ||
package org.codehaus.mojo.license; | ||
|
||
import org.apache.maven.plugin.MojoExecutionException; | ||
|
||
/** | ||
* What to do in case of a file not found in project. | ||
* | ||
* @since 2.0.1 | ||
*/ | ||
public enum UnkownFileRemedy | ||
{ | ||
/** Unkown files will be logged debug */ | ||
debug, | ||
/** Unkown files are output to the log as warnings */ | ||
warn, | ||
/** | ||
* The first encountered unkown file is logged and a {@link MojoExecutionException} is thrown | ||
*/ | ||
failFast, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ | |
import org.apache.maven.project.MavenProject; | ||
import org.apache.maven.project.MavenProjectHelper; | ||
import org.codehaus.mojo.license.LicenseMojoUtils; | ||
import org.codehaus.mojo.license.UnkownFileRemedy; | ||
import org.codehaus.mojo.license.model.LicenseMap; | ||
import org.codehaus.mojo.license.utils.FileUtil; | ||
import org.codehaus.mojo.license.utils.MojoHelper; | ||
|
@@ -450,11 +451,13 @@ public void mergeLicenses( LicenseMap licenseMap, String mainLicense, Set<String | |
/** | ||
* {@inheritDoc} | ||
*/ | ||
public SortedProperties loadUnsafeMapping( LicenseMap licenseMap, | ||
SortedMap<String, MavenProject> artifactCache, | ||
String encoding, | ||
File missingFile, | ||
String missingFileUrl ) throws IOException, MojoExecutionException | ||
public SortedProperties loadUnsafeMapping(LicenseMap licenseMap, | ||
SortedMap<String, MavenProject> artifactCache, | ||
String encoding, | ||
File missingFile, | ||
String missingFileUrl, | ||
UnkownFileRemedy unkownFileRemedy) | ||
throws IOException, MojoExecutionException | ||
{ | ||
Map<String, MavenProject> snapshots = new HashMap<>(); | ||
|
||
|
@@ -536,8 +539,7 @@ public SortedProperties loadUnsafeMapping( LicenseMap licenseMap, | |
// there is some unknown dependencies in the missing file, remove them | ||
for ( String id : unknownDependenciesId ) | ||
{ | ||
getLogger().debug( | ||
"dependency [" + id + "] does not exist in project, remove it from the missing file." ); | ||
handleUnkownDependency(unkownFileRemedy,"dependency [" + id + "] does not exist in project, remove it from the missing file."); | ||
unsafeMappings.remove( id ); | ||
} | ||
|
||
|
@@ -552,7 +554,7 @@ public SortedProperties loadUnsafeMapping( LicenseMap licenseMap, | |
MavenProject project = artifactCache.get( id ); | ||
if ( project == null ) | ||
{ | ||
LOG.warn( "dependency [{}] does not exist in project.", id ); | ||
handleUnkownDependency(unkownFileRemedy, "dependency [" + id + "] does not exist in project." ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably cleaner to hand |
||
continue; | ||
} | ||
|
||
|
@@ -594,6 +596,26 @@ public SortedProperties loadUnsafeMapping( LicenseMap licenseMap, | |
return unsafeMappings; | ||
} | ||
|
||
private void handleUnkownDependency(final UnkownFileRemedy unkownFileRemedy, final String message) | ||
throws MojoExecutionException { | ||
|
||
switch ( unkownFileRemedy ) | ||
{ | ||
case debug: | ||
LOG.debug( message ); | ||
break; | ||
case failFast: | ||
throw new MojoExecutionException(message); | ||
case warn: | ||
LOG.warn( message ); | ||
break; | ||
default: | ||
throw new IllegalStateException( "Unexpected value of " + UnkownFileRemedy.class.getName() + ": " | ||
+ unkownFileRemedy ); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Typo throughout the change Unkown -> Unknown