Skip to content

Commit

Permalink
Prepare #294 Simplify MavenProjectDependenciesConfigurator
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Feb 26, 2019
1 parent 933905e commit 9ded9f3
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Proxy;
import org.codehaus.mojo.license.api.ArtifactFilters;
import org.codehaus.mojo.license.api.MavenProjectDependenciesConfigurator;
import org.codehaus.mojo.license.api.ResolvedProjectDependencies;
import org.codehaus.mojo.license.download.Cache;
Expand All @@ -43,7 +44,6 @@
import org.codehaus.mojo.license.download.LicenseDownloader.LicenseDownloadResult;
import org.codehaus.mojo.license.download.LicenseMatchers;
import org.codehaus.mojo.license.utils.FileUtil;
import org.codehaus.mojo.license.utils.MojoHelper;

import java.io.File;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -579,6 +579,8 @@ public abstract class AbstractDownloadLicensesMojo

private int downloadErrorCount = 0;

private ArtifactFilters artifactFilters;

protected abstract boolean isSkip();

protected MavenProject getProject()
Expand Down Expand Up @@ -773,92 +775,15 @@ public boolean isExcludeTransitiveDependencies()
}

/** {@inheritDoc} */
public boolean isIncludeOptional()
{
return includeOptional;
}

/**
* {@inheritDoc}
*/
public List<String> getExcludedScopes()
{
return MojoHelper.getParams( excludedScopes );
}

public void setExcludedScopes( String excludedScopes )
{
this.excludedScopes = excludedScopes;
}

/**
* {@inheritDoc}
*/
public List<String> getIncludedScopes()
{
return MojoHelper.getParams( includedScopes );
}

/**
* {@inheritDoc}
*/
public List<String> getExcludedTypes()
{
return MojoHelper.getParams( excludedTypes );
}

/**
* {@inheritDoc}
*/
public List<String> getIncludedTypes()
{
return MojoHelper.getParams( includedTypes );
}

// not used at the moment

/**
* {@inheritDoc}
*/
public String getIncludedArtifacts()
{
return includedArtifacts;
}

// not used at the moment

/**
* {@inheritDoc}
*/
public String getIncludedGroups()
{
return includedGroups;
}

// not used at the moment

/**
* {@inheritDoc}
*/
public String getExcludedGroups()
{
return excludedGroups;
}

// not used at the moment

/**
* {@inheritDoc}
*/
public String getExcludedArtifacts()
{
return excludedArtifacts;
}

/** {@inheritDoc} */
public String getArtifactFiltersUrl()
public ArtifactFilters getArtifactFilters()
{
return artifactFiltersUrl;
if ( artifactFilters == null )
{
artifactFilters = ArtifactFilters.of( includedGroups, excludedGroups, includedArtifacts, excludedArtifacts,
includedScopes, excludedScopes, includedTypes, excludedTypes,
includeOptional, artifactFiltersUrl , getEncoding() );
}
return artifactFilters;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.mojo.license.api.ArtifactFilters;
import org.codehaus.mojo.license.api.DefaultThirdPartyDetails;
import org.codehaus.mojo.license.api.DefaultThirdPartyHelper;
import org.codehaus.mojo.license.api.DependenciesTool;
Expand Down Expand Up @@ -372,6 +373,8 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport
@Parameter( property = "license.artifactFiltersUrl" )
private String artifactFiltersUrl;

private ArtifactFilters artifactFilters;

// ----------------------------------------------------------------------
// Protected Abstract Methods
// ----------------------------------------------------------------------
Expand Down Expand Up @@ -514,70 +517,6 @@ public String getName( Locale locale )
// MavenProjectDependenciesConfigurator Implementation
// ----------------------------------------------------------------------

/**
* {@inheritDoc}
*/
public List<String> getExcludedScopes()
{
return MojoHelper.getParams( excludedScopes );
}

/**
* {@inheritDoc}
*/
public List<String> getIncludedScopes()
{
return MojoHelper.getParams( includedScopes );
}

/**
* {@inheritDoc}
*/
public List<String> getExcludedTypes()
{
return MojoHelper.getParams( excludedTypes );
}

/**
* {@inheritDoc}
*/
public List<String> getIncludedTypes()
{
return MojoHelper.getParams( includedTypes );
}

/**
* {@inheritDoc}
*/
public String getExcludedGroups()
{
return excludedGroups;
}

/**
* {@inheritDoc}
*/
public String getIncludedGroups()
{
return includedGroups;
}

/**
* {@inheritDoc}
*/
public String getExcludedArtifacts()
{
return excludedArtifacts;
}

/**
* {@inheritDoc}
*/
public String getIncludedArtifacts()
{
return includedArtifacts;
}

/**
* {@inheritDoc}
*/
Expand All @@ -595,9 +534,15 @@ public boolean isExcludeTransitiveDependencies()
}

/** {@inheritDoc} */
public boolean isIncludeOptional()
public ArtifactFilters getArtifactFilters()
{
return includeOptional;
if ( artifactFilters == null )
{
artifactFilters = ArtifactFilters.of( includedGroups, excludedGroups, includedArtifacts, excludedArtifacts,
includedScopes, excludedScopes, includedTypes, excludedTypes,
includeOptional, artifactFiltersUrl , getEncoding() );
}
return artifactFilters;
}

/**
Expand Down
84 changes: 11 additions & 73 deletions src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.codehaus.mojo.license.api.ArtifactFilters;
import org.codehaus.mojo.license.api.DependenciesToolException;
import org.codehaus.mojo.license.api.MavenProjectDependenciesConfigurator;
import org.codehaus.mojo.license.api.ResolvedProjectDependencies;
import org.codehaus.mojo.license.api.ThirdPartyToolException;
import org.codehaus.mojo.license.model.LicenseMap;
import org.codehaus.mojo.license.utils.FileUtil;
import org.codehaus.mojo.license.utils.MojoHelper;
import org.codehaus.mojo.license.utils.SortedProperties;

// CHECKSTYLE_OFF: LineLength
Expand Down Expand Up @@ -117,6 +117,8 @@ public class AddThirdPartyMojo extends AbstractAddThirdPartyMojo implements Mave
*/
private ResolvedProjectDependencies dependencyArtifacts;

private ArtifactFilters artifactFilters;

// ----------------------------------------------------------------------
// AbstractLicenseMojo Implementaton
// ----------------------------------------------------------------------
Expand Down Expand Up @@ -297,76 +299,6 @@ protected SortedProperties createUnsafeMapping()
// MavenProjectDependenciesConfigurator Implementaton
// ----------------------------------------------------------------------

/**
* {@inheritDoc}
*/
public String getExcludedGroups()
{
return excludedGroups;
}

/**
* {@inheritDoc}
*/
public String getIncludedGroups()
{
return includedGroups;
}

/**
* {@inheritDoc}
*/
public List<String> getExcludedScopes()
{
return MojoHelper.getParams( excludedScopes );
}

/**
* {@inheritDoc}
*/
public List<String> getIncludedScopes()
{
return MojoHelper.getParams( includedScopes );
}

/**
* {@inheritDoc}
*/
public List<String> getExcludedTypes()
{
return MojoHelper.getParams( excludedTypes );
}

/**
* {@inheritDoc}
*/
public List<String> getIncludedTypes()
{
return MojoHelper.getParams( includedTypes );
}

/**
* {@inheritDoc}
*/
public String getExcludedArtifacts()
{
return excludedArtifacts;
}

/**
* {@inheritDoc}
*/
public String getIncludedArtifacts()
{
return includedArtifacts;
}

/** {@inheritDoc} */
public String getArtifactFiltersUrl()
{
return artifactFiltersUrl;
}

/**
* {@inheritDoc}
*/
Expand All @@ -384,9 +316,15 @@ public boolean isExcludeTransitiveDependencies()
}

/** {@inheritDoc} */
public boolean isIncludeOptional()
public ArtifactFilters getArtifactFilters()
{
return includeOptional;
if ( artifactFilters == null )
{
artifactFilters = ArtifactFilters.of( includedGroups, excludedGroups, includedArtifacts, excludedArtifacts,
includedScopes, excludedScopes, includedTypes, excludedTypes,
includeOptional, artifactFiltersUrl , getEncoding() );
}
return artifactFilters;
}

// ----------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 9ded9f3

Please sign in to comment.