This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch refactor-test in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git. discard 3dba8c1 Bump asm to 9.0 (maven-plugin-tools-generators) discard 1b9aa5e Bump commons-lang3 to 3.8.1 discard e98d9c8 Site plugin updates, fluido 1.9, small docs update. discard 6e4f106 Bump maven-plugin-plugin to 3.6.0 discard 6542742 Sonar: Disable access to external entities in XML parsing discard 72c5313 Sonar: fix reported issues new 5634c7c Sonar: fix reported issues new 2141ad0 Sonar: Disable access to external entities in XML parsing new c6d09f9 Upgrade maven-plugin-plugin to 3.6.0 new c03f181 Site plugin updates, fluido 1.9, small docs update. new 7fbc796 Bump commons-lang3 to 3.8.1 new 78908ca Upgrade maven-enforcer-plugin to 3.0.0-M3 new 94e0f4d Upgrade maven-checkstyle-plugin to 3.1.1 new d7d2734 Bump asm to 9.0 (maven-plugin-tools-generators) This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (3dba8c1) \ N -- N -- N refs/heads/refactor-test (d7d2734) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. The 8 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) |
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch refactor-test in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git commit 5634c7c84425ca493e0509d69d932d464680f5fe Author: Sylwester Lachiewicz <[hidden email]> AuthorDate: Mon Jan 11 23:52:16 2021 +0100 Sonar: fix reported issues --- .../maven/plugins/help/AbstractEffectiveMojo.java | 25 +---- .../maven/plugins/help/AbstractHelpMojo.java | 16 +-- .../maven/plugins/help/ActiveProfilesMojo.java | 2 +- .../apache/maven/plugins/help/AllProfilesMojo.java | 6 +- .../apache/maven/plugins/help/DescribeMojo.java | 26 ++--- .../maven/plugins/help/EffectivePomMojo.java | 39 ++------ .../maven/plugins/help/EffectiveSettingsMojo.java | 19 ++-- .../apache/maven/plugins/help/EvaluateMojo.java | 110 +++++---------------- .../maven/plugins/help/ActiveProfilesMojoTest.java | 14 +-- .../maven/plugins/help/AllProfilesMojoTest.java | 18 ++-- .../maven/plugins/help/DescribeMojoTest.java | 9 +- .../maven/plugins/help/EvaluateMojoTest.java | 10 +- .../help/stubs/DefaultMavenProjectStub.java | 12 +-- 13 files changed, 86 insertions(+), 220 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java index 6575224..f1232ac 100644 --- a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java @@ -31,7 +31,6 @@ import java.util.List; import java.util.Properties; import java.util.Set; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.xml.XMLWriter; import org.codehaus.plexus.util.xml.XmlWriterUtil; @@ -66,21 +65,10 @@ public abstract class AbstractEffectiveMojo return; } - Writer out = null; - try + output.getParentFile().mkdirs(); + try ( Writer out = WriterFactory.newXmlWriter( output ) ) { - output.getParentFile().mkdirs(); - - out = WriterFactory.newXmlWriter( output ); - out.write( content ); - - out.close(); - out = null; - } - finally - { - IOUtil.close( out ); } } @@ -142,11 +130,7 @@ public abstract class AbstractEffectiveMojo return w.toString(); } - catch ( JDOMException e ) - { - return effectiveModel; - } - catch ( IOException e ) + catch ( JDOMException | IOException e ) { return effectiveModel; } @@ -163,13 +147,14 @@ public abstract class AbstractEffectiveMojo /** {@inheritDoc} */ @SuppressWarnings( { "rawtypes", "unchecked" } ) + @Override public Set<Object> keySet() { Set<Object> keynames = super.keySet(); List list = new ArrayList( keynames ); Collections.sort( list ); - return new LinkedHashSet<Object>( list ); + return new LinkedHashSet<>( list ); } } } diff --git a/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java b/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java index f8dd75c..0f079ff 100644 --- a/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java @@ -32,7 +32,6 @@ import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.WriterFactory; import org.eclipse.aether.RepositoryException; @@ -138,21 +137,10 @@ public abstract class AbstractHelpMojo return; } - Writer out = null; - try + output.getParentFile().mkdirs(); + try ( Writer out = WriterFactory.newPlatformWriter( output ) ) { - output.getParentFile().mkdirs(); - - out = WriterFactory.newPlatformWriter( output ); - out.write( content ); - - out.close(); - out = null; - } - finally - { - IOUtil.close( out ); } } diff --git a/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java b/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java index 7ac8e6b..326ee9c 100644 --- a/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java @@ -106,7 +106,7 @@ public class ActiveProfilesMojo Map<String, List<String>> activeProfileIds = project.getInjectedProfileIds(); message.append( LS ); - message.append( "Active Profiles for Project \'" ).append( project.getId() ).append( "\':" ); + message.append( "Active Profiles for Project '" ).append( project.getId() ).append( "':" ); message.append( LS ).append( LS ); if ( activeProfileIds.isEmpty() ) diff --git a/src/main/java/org/apache/maven/plugins/help/AllProfilesMojo.java b/src/main/java/org/apache/maven/plugins/help/AllProfilesMojo.java index 18c96b8..c5f6c0a 100644 --- a/src/main/java/org/apache/maven/plugins/help/AllProfilesMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/AllProfilesMojo.java @@ -76,8 +76,8 @@ public class AllProfilesMojo { descriptionBuffer.append( "Listing Profiles for Project: " ).append( project.getId() ).append( LS ); - Map<String, Profile> allProfilesByIds = new HashMap<String, Profile>(); - Map<String, Profile> activeProfilesByIds = new HashMap<String, Profile>(); + Map<String, Profile> allProfilesByIds = new HashMap<>(); + Map<String, Profile> activeProfilesByIds = new HashMap<>(); addSettingsProfiles( allProfilesByIds ); addProjectPomProfiles( project, allProfilesByIds, activeProfilesByIds ); @@ -124,7 +124,7 @@ public class AllProfilesMojo for ( Profile p : profilesByIds.values() ) { sb.append( " Profile Id: " ).append( p.getId() ); - sb.append( " (Active: " + active + " , Source: " ).append( p.getSource() ).append( ")" ); + sb.append( " (Active: " ).append( active ).append( " , Source: " ).append( p.getSource() ).append( ")" ); sb.append( LS ); } } diff --git a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java index 334ede7..9c58b02 100644 --- a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java @@ -472,7 +472,7 @@ public class DescribeMojo append( buffer, "This plugin has " + mojos.size() + " goal" + ( mojos.size() > 1 ? "s" : "" ) + ":", 0 ); buffer.append( LS ); - mojos = new ArrayList<MojoDescriptor>( mojos ); + mojos = new ArrayList<>( mojos ); PluginUtils.sortMojos( mojos ); for ( MojoDescriptor md : mojos ) @@ -610,7 +610,7 @@ public class DescribeMojo return; } - params = new ArrayList<Parameter>( params ); + params = new ArrayList<>( params ); PluginUtils.sortMojoParameters( params ); append( buffer, "Available parameters:", 1 ); @@ -820,9 +820,8 @@ public class DescribeMojo { try { - Method m = HelpMojo.class.getDeclaredMethod( "toLines", - new Class[]{ String.class, Integer.TYPE, Integer.TYPE, - Integer.TYPE } ); + Method m = HelpMojo.class.getDeclaredMethod( "toLines", String.class, Integer.TYPE, Integer.TYPE, + Integer.TYPE ); m.setAccessible( true ); @SuppressWarnings( "unchecked" ) List<String> output = (List<String>) m.invoke( HelpMojo.class, text, indent, indentSize, lineLength ); @@ -971,7 +970,7 @@ public class DescribeMojo private boolean isReportGoal( MojoDescriptor md ) { PluginDescriptor pd = md.getPluginDescriptor(); - List<URL> urls = new ArrayList<URL>(); + List<URL> urls = new ArrayList<>(); ProjectBuildingRequest pbr = new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() ); pbr.setRemoteRepositories( remoteRepositories ); pbr.setResolveDependencies( true ); @@ -983,15 +982,18 @@ public class DescribeMojo new DefaultArtifact( pd.getGroupId(), pd.getArtifactId(), "jar", pd.getVersion() ) ).getArtifact(); org.eclipse.aether.artifact.Artifact pom = resolveArtifact( new DefaultArtifact( pd.getGroupId(), pd.getArtifactId(), "pom", pd.getVersion() ) ).getArtifact(); - MavenProject project = projectBuilder.build( pom.getFile(), pbr ).getProject(); + MavenProject mavenProject = projectBuilder.build( pom.getFile(), pbr ).getProject(); urls.add( jar.getFile().toURI().toURL() ); - for ( Object artifact : project.getCompileClasspathElements() ) + for ( String artifact : mavenProject.getCompileClasspathElements() ) { - urls.add( new File( (String) artifact ).toURI().toURL() ); + urls.add( new File( artifact ).toURI().toURL() ); + } + try ( URLClassLoader classLoader = new URLClassLoader( urls.toArray( new URL[0] ), + getClass().getClassLoader() ) ) + { + return MavenReport.class.isAssignableFrom( + Class.forName( md.getImplementation(), false, classLoader ) ); } - ClassLoader classLoader = - new URLClassLoader( urls.toArray( new URL[urls.size()] ), getClass().getClassLoader() ); - return MavenReport.class.isAssignableFrom( Class.forName( md.getImplementation(), false, classLoader ) ); } catch ( Exception e ) { diff --git a/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java b/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java index eb94595..d80e7cd 100644 --- a/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java @@ -168,18 +168,11 @@ public class EffectivePomMojo int dotIndex = comment.indexOf( "." ); String commentStart = comment.substring( 0, dotIndex ); String commentEnd = comment.substring( dotIndex + 1 ); - effectivePom = effectivePom.replaceAll( "<!--", commentStart ).replaceAll( "-->", commentEnd ); + effectivePom = effectivePom.replace( "<!--", commentStart ).replace( "-->", commentEnd ); } - StringBuilder message = new StringBuilder(); - - message.append( LS ); - message.append( "Effective POMs, after inheritance, interpolation, and profiles are applied:" ); - message.append( LS ).append( LS ); - message.append( effectivePom ); - message.append( LS ); - - getLog().info( message.toString() ); + getLog().info( LS + "Effective POMs, after inheritance, interpolation, and profiles are applied:" + + LS + LS + effectivePom + LS ); } } @@ -194,8 +187,7 @@ public class EffectivePomMojo { Source source = mojoExecution.getSource(); // [MNG-5550] For Maven < 3.2.1, the source is null, instead of LIFECYCLE: only rely on comparisons with CLI - return projects.size() > 1 - && ( source == Source.CLI || source != Source.CLI && projects.get( 0 ).equals( project ) ); + return projects.size() > 1 && ( source == Source.CLI || projects.get( 0 ).equals( project ) ); } // ---------------------------------------------------------------------- @@ -240,7 +232,7 @@ public class EffectivePomMojo // This removes the XML declaration written by MavenXpp3Writer String effectivePom = prettyFormat( sWriter.toString(), null, true ); - writeComment( writer, "Effective POM for project \'" + project.getId() + "\'" ); + writeComment( writer, "Effective POM for project '" + project.getId() + "'" ); writer.writeMarkup( effectivePom ); } @@ -269,7 +261,7 @@ public class EffectivePomMojo try { Class<?> mavenXpp3WriterExClass = Class.forName( "org.apache.maven.model.io.xpp3.MavenXpp3WriterEx" ); - Object mavenXpp3WriterEx = mavenXpp3WriterExClass.newInstance(); + Object mavenXpp3WriterEx = mavenXpp3WriterExClass.getDeclaredConstructor().newInstance(); Method setStringFormatter = mavenXpp3WriterExClass.getMethod( "setStringFormatter", InputLocation.StringFormatter.class ); @@ -284,23 +276,8 @@ public class EffectivePomMojo { // MavenXpp3WriterEx not available in running Maven version } - catch ( NoSuchMethodException e ) - { - warnWriteMavenXpp3WriterEx( e ); - } - catch ( SecurityException e ) - { - warnWriteMavenXpp3WriterEx( e ); - } - catch ( InstantiationException e ) - { - warnWriteMavenXpp3WriterEx( e ); - } - catch ( IllegalAccessException e ) - { - warnWriteMavenXpp3WriterEx( e ); - } - catch ( IllegalArgumentException e ) + catch ( NoSuchMethodException | SecurityException | IllegalArgumentException | IllegalAccessException + | InstantiationException e ) { warnWriteMavenXpp3WriterEx( e ); } diff --git a/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java b/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java index 90535d0..c8bb052 100644 --- a/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java @@ -86,11 +86,14 @@ public class EffectiveSettingsMojo else { copySettings = copySettings( settings ); - hidePasswords( copySettings ); + if ( copySettings != null ) + { + hidePasswords( copySettings ); + } } StringWriter w = new StringWriter(); - String encoding = output != null ? copySettings.getModelEncoding() + String encoding = output != null && copySettings != null ? copySettings.getModelEncoding() : System.getProperty( "file.encoding" ); XMLWriter writer = new PrettyPrintXMLWriter( w, StringUtils.repeat( " ", XmlWriterUtil.DEFAULT_INDENTATION_SIZE ), @@ -117,13 +120,7 @@ public class EffectiveSettingsMojo } else { - StringBuilder message = new StringBuilder(); - - message.append( LS ).append( "Effective user-specific configuration settings:" ).append( LS ).append( LS ); - message.append( effectiveSettings ); - message.append( LS ); - - getLog().info( message.toString() ); + getLog().info( LS + "Effective user-specific configuration settings:" + LS + LS + effectiveSettings + LS ); } } @@ -177,7 +174,7 @@ public class EffectiveSettingsMojo // Not a deep copy in M2.2.1 !!! Settings clone = SettingsUtils.copySettings( settings ); - List<Server> clonedServers = new ArrayList<Server>( settings.getServers().size() ); + List<Server> clonedServers = new ArrayList<>( settings.getServers().size() ); for ( Server server : settings.getServers() ) { Server clonedServer = new Server(); @@ -195,7 +192,7 @@ public class EffectiveSettingsMojo } clone.setServers( clonedServers ); - List<Proxy> clonedProxies = new ArrayList<Proxy>( settings.getProxies().size() ); + List<Proxy> clonedProxies = new ArrayList<>( settings.getProxies().size() ); for ( Proxy proxy : settings.getProxies() ) { Proxy clonedProxy = new Proxy(); diff --git a/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java b/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java index 4710725..a18a719 100644 --- a/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java @@ -37,7 +37,6 @@ import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.settings.Settings; import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; @@ -231,11 +230,10 @@ public class EvaluateMojo /** * @return a lazy loading evaluator object. - * @throws MojoExecutionException if any * @throws MojoFailureException if any reflection exceptions occur or missing components. */ private PluginParameterExpressionEvaluator getEvaluator() - throws MojoExecutionException, MojoFailureException + throws MojoFailureException { if ( evaluator == null ) { @@ -421,7 +419,7 @@ public class EvaluateMojo if ( obj instanceof List ) { List<?> list = (List<?>) obj; - if ( list.size() > 0 ) + if ( !list.isEmpty() ) { Object elt = list.iterator().next(); @@ -456,16 +454,18 @@ public class EvaluateMojo xstream.registerConverter( new PropertiesConverter() { /** {@inheritDoc} */ - public boolean canConvert( @SuppressWarnings( "rawtypes" ) Class type ) + @Override + public boolean canConvert( Class type ) { return Properties.class == type; } /** {@inheritDoc} */ + @Override public void marshal( Object source, HierarchicalStreamWriter writer, MarshallingContext context ) { Properties properties = (Properties) source; - Map<?, ?> map = new TreeMap<Object, Object>( properties ); // sort + Map<?, ?> map = new TreeMap<>( properties ); // sort for ( Map.Entry<?, ?> entry : map.entrySet() ) { writer.startNode( entry.getKey().toString() ); @@ -486,28 +486,14 @@ public class EvaluateMojo { try { - addAlias( xstreamObject, getMavenModelJarFile(), "org.apache.maven.model" ); - addAlias( xstreamObject, getMavenSettingsJarFile(), "org.apache.maven.settings" ); + addAlias( xstreamObject, getArtifactFile( "maven-model" ), "org.apache.maven.model" ); + addAlias( xstreamObject, getArtifactFile( "maven-settings" ), "org.apache.maven.settings" ); } - catch ( MojoExecutionException e ) + catch ( MojoExecutionException | RepositoryException e ) { if ( getLog().isDebugEnabled() ) { - getLog().debug( "MojoExecutionException: " + e.getMessage(), e ); - } - } - catch ( RepositoryException e ) - { - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "RepositoryException: " + e.getMessage(), e ); - } - } - catch ( ProjectBuildingException e ) - { - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "ProjectBuildingException: " + e.getMessage(), e ); + getLog().debug( e.getMessage(), e ); } } @@ -521,17 +507,16 @@ public class EvaluateMojo */ private void addAlias( XStream xstreamObject, File jarFile, String packageFilter ) { - JarInputStream jarStream = null; - try + try ( FileInputStream fis = new FileInputStream( jarFile ); + JarInputStream jarStream = new JarInputStream( fis ) ) { - jarStream = new JarInputStream( new FileInputStream( jarFile ) ); for ( JarEntry jarEntry = jarStream.getNextJarEntry(); jarEntry != null; jarEntry = jarStream.getNextJarEntry() ) { if ( jarEntry.getName().toLowerCase( Locale.ENGLISH ).endsWith( ".class" ) ) { String name = jarEntry.getName().substring( 0, jarEntry.getName().indexOf( "." ) ); - name = name.replaceAll( "/", "\\." ); + name = name.replace( "/", "\\." ); if ( name.contains( packageFilter ) && !name.contains( "$" ) ) { @@ -554,9 +539,6 @@ public class EvaluateMojo jarStream.closeEntry(); } - - jarStream.close(); - jarStream = null; } catch ( IOException e ) { @@ -565,78 +547,32 @@ public class EvaluateMojo getLog().debug( "IOException: " + e.getMessage(), e ); } } - finally - { - IOUtil.close( jarStream ); - } } /** - * @return the <code>org.apache.maven:maven-model</code> artifact jar file in the local repository. + * @return the <code>org.apache.maven: artifactId </code> artifact jar file for this current HelpPlugin pom. * @throws MojoExecutionException if any - * @throws ProjectBuildingException if any - * @throws RepositoryException if any */ - private File getMavenModelJarFile() - throws MojoExecutionException, ProjectBuildingException, RepositoryException - { - return getArtifactFile( true ); - } - - /** - * @return the <code>org.apache.maven:maven-settings</code> artifact jar file in the local repository. - * @throws MojoExecutionException if any - * @throws ProjectBuildingException if any - * @throws RepositoryException if any - */ - private File getMavenSettingsJarFile() - throws MojoExecutionException, ProjectBuildingException, RepositoryException - { - return getArtifactFile( false ); - } - - /** - * @param isPom <code>true</code> to lookup the <code>maven-model</code> artifact jar, <code>false</code> to lookup - * the <code>maven-settings</code> artifact jar. - * @return the <code>org.apache.maven:maven-model|maven-settings</code> artifact jar file for this current - * HelpPlugin pom. - * @throws MojoExecutionException if any - */ - private File getArtifactFile( boolean isPom ) + private File getArtifactFile( String artifactId ) throws MojoExecutionException, RepositoryException { List<Dependency> dependencies = getHelpPluginPom().getDependencies(); for ( Dependency dependency : dependencies ) { - if ( !( dependency.getGroupId().equals( "org.apache.maven" ) ) ) - { - continue; - } - - if ( isPom ) - { - if ( !( dependency.getArtifactId().equals( "maven-model" ) ) ) - { - continue; - } - } - else + if ( ( "org.apache.maven".equals( dependency.getGroupId() ) ) ) { - if ( !( dependency.getArtifactId().equals( "maven-settings" ) ) ) + if ( ( artifactId.equals( dependency.getArtifactId() ) ) ) { - continue; - } - } + Artifact mavenArtifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), + "jar", dependency.getVersion() ); - Artifact mavenArtifact = new DefaultArtifact( - dependency.getGroupId(), dependency.getArtifactId(), "jar", - dependency.getVersion() ); + return resolveArtifact( mavenArtifact ).getArtifact().getFile(); + } - return resolveArtifact( mavenArtifact ).getArtifact().getFile(); + } } - throw new MojoExecutionException( "Unable to find the 'org.apache.maven:" - + ( isPom ? "maven-model" : "maven-settings" ) + "' artifact" ); + throw new MojoExecutionException( "Unable to find the 'org.apache.maven:" + artifactId + "' artifact" ); } /** diff --git a/src/test/java/org/apache/maven/plugins/help/ActiveProfilesMojoTest.java b/src/test/java/org/apache/maven/plugins/help/ActiveProfilesMojoTest.java index 9af35fd..6d70fd2 100644 --- a/src/test/java/org/apache/maven/plugins/help/ActiveProfilesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/help/ActiveProfilesMojoTest.java @@ -24,7 +24,6 @@ import static org.mockito.Mockito.when; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -93,7 +92,7 @@ public class ActiveProfilesMojoTest private Map<String, List<String>> getProfiles( List<String> externals, List<String> pom ) { - Map<String, List<String>> profiles = new HashMap<String, List<String>>(); + Map<String, List<String>> profiles = new HashMap<>(); profiles.put( "external", externals ); // from settings profiles.put( "org.apache.maven.test:test:1.0", pom ); // from POM profiles.put( "", Collections.<String>emptyList() ); // from super POM @@ -109,18 +108,13 @@ public class ActiveProfilesMojoTest } private String readFile( String path ) - throws FileNotFoundException, IOException + throws IOException { - FileInputStream fis = null; - try + try ( FileInputStream fis = new FileInputStream( + new File( getBasedir(), "target/test-classes/unit/active-profiles/" + path ) ) ) { - fis = new FileInputStream( new File( getBasedir(), "target/test-classes/unit/active-profiles/" + path ) ); return IOUtil.toString( fis ); } - finally - { - IOUtil.close( fis ); - } } } diff --git a/src/test/java/org/apache/maven/plugins/help/AllProfilesMojoTest.java b/src/test/java/org/apache/maven/plugins/help/AllProfilesMojoTest.java index fdbe98d..b7f9596 100644 --- a/src/test/java/org/apache/maven/plugins/help/AllProfilesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/help/AllProfilesMojoTest.java @@ -21,7 +21,6 @@ package org.apache.maven.plugins.help; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -146,10 +145,10 @@ public class AllProfilesMojoTest MavenProject project = new MavenProjectStub(); project.setActiveProfiles( Arrays.asList( newPomProfile( "settings-1", "settings.xml" ) ) ); - List<org.apache.maven.settings.Profile> settingsProfiles = new ArrayList<org.apache.maven.settings.Profile>(); + List<org.apache.maven.settings.Profile> settingsProfiles = new ArrayList<>(); settingsProfiles.add( newSettingsProfile( "settings-1" ) ); settingsProfiles.add( newSettingsProfile( "settings-2" ) ); - setUpMojo( mojo, Arrays.<MavenProject>asList( project ), settingsProfiles, "profiles-from-settings.txt" ); + setUpMojo( mojo, Arrays.asList( project ), settingsProfiles, "profiles-from-settings.txt" ); mojo.execute(); @@ -185,24 +184,19 @@ public class AllProfilesMojoTest } private String readFile( String path ) - throws FileNotFoundException, IOException + throws IOException { - FileInputStream fis = null; - try + try ( FileInputStream fis = new FileInputStream( + new File( getBasedir(), "target/test-classes/unit/active-profiles/" + path ) ) ) { - fis = new FileInputStream( new File( getBasedir(), "target/test-classes/unit/active-profiles/" + path ) ); return IOUtil.toString( fis ); } - finally - { - IOUtil.close( fis ); - } } private static final class InterceptingLog extends DefaultLog { - List<String> warnLogs = new ArrayList<String>(); + final List<String> warnLogs = new ArrayList<>(); public InterceptingLog( Logger logger ) { diff --git a/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java b/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java index 8cdd49a..0a255ad 100644 --- a/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java @@ -40,8 +40,6 @@ import static org.apache.commons.lang3.reflect.FieldUtils.writeDeclaredField; import static org.apache.commons.lang3.reflect.FieldUtils.writeField; import static org.apache.commons.lang3.reflect.MethodUtils.invokeMethod; import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; /** @@ -60,7 +58,6 @@ public class DescribeMojoTest { DescribeMojo describeMojo = new DescribeMojo(); invokeMethod( describeMojo, true, "toLines", "", 2, 2, 80 ); - assertTrue( true ); } catch ( Throwable e ) { @@ -136,9 +133,9 @@ public class DescribeMojoTest PluginInfo pi = (PluginInfo) invokeMethod( mojo, true, "parsePluginLookupInfo" ); - assertEquals( pi.getGroupId(), "org.test" ); - assertEquals( pi.getArtifactId(), "test" ); - assertEquals( pi.getVersion(), "1.0" ); + assertEquals( "org.test", pi.getGroupId() ); + assertEquals( "test", pi.getArtifactId() ); + assertEquals( "1.0", pi.getVersion() ); assertNull( pi.getPrefix() ); } diff --git a/src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java b/src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java index bf22790..e2e1926 100644 --- a/src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java @@ -19,7 +19,7 @@ package org.apache.maven.plugins.help; * under the License. */ -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -154,8 +154,8 @@ public class EvaluateMojoTest baos.close(); } - String stdResult = new String( baos.toByteArray() ); - assertTrue( stdResult.equals( "org.apache.maven.its.help" ) ); + String stdResult = baos.toString(); + assertEquals( "org.apache.maven.its.help", stdResult ); assertTrue( interceptingLogger.warnLogs.isEmpty() ); } @@ -174,9 +174,9 @@ public class EvaluateMojoTest { private boolean isInfoEnabled; - List<String> infoLogs = new ArrayList<String>(); + final List<String> infoLogs = new ArrayList<>(); - List<String> warnLogs = new ArrayList<String>(); + final List<String> warnLogs = new ArrayList<>(); public InterceptingLog( Logger logger ) { diff --git a/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java index ee37ae6..8841718 100644 --- a/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java @@ -19,7 +19,6 @@ package org.apache.maven.plugins.help.stubs; * under the License. */ -import java.io.File; import java.io.FileReader; import org.apache.maven.model.Model; @@ -42,13 +41,10 @@ public class DefaultMavenProjectStub try { - final FileReader reader = new FileReader(new File(getBasedir() - + "/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml")); - try { - model = - pomReader.read(reader); - } finally { - reader.close(); + try ( FileReader reader = new FileReader( + getBasedir() + "/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ) ) + { + model = pomReader.read( reader ); } setModel(model); } |
In reply to this post by slachiewicz
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch refactor-test in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git commit 2141ad02a785abd3e54feb1ba0ce5de98992cc13 Author: Sylwester Lachiewicz <[hidden email]> AuthorDate: Mon Jan 11 23:14:07 2021 +0100 Sonar: Disable access to external entities in XML parsing --- .../java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java index f1232ac..96ed683 100644 --- a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java @@ -40,6 +40,8 @@ import org.jdom2.input.SAXBuilder; import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; +import javax.xml.XMLConstants; + /** * Base class with common utilities to write effective Pom/settings. * @@ -111,7 +113,8 @@ public abstract class AbstractEffectiveMojo protected static String prettyFormat( String effectiveModel, String encoding, boolean omitDeclaration ) { SAXBuilder builder = new SAXBuilder(); - + builder.setProperty( XMLConstants.ACCESS_EXTERNAL_DTD, "" ); + builder.setProperty( XMLConstants.ACCESS_EXTERNAL_SCHEMA, "" ); try { Document effectiveDocument = builder.build( new StringReader( effectiveModel ) ); |
In reply to this post by slachiewicz
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch refactor-test in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git commit c6d09f9e82a737180e602e4886225d99a76b3238 Author: Sylwester Lachiewicz <[hidden email]> AuthorDate: Mon Jan 11 23:00:47 2021 +0100 Upgrade maven-plugin-plugin to 3.6.0 --- pom.xml | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index 0267f35..5e8aaf7 100644 --- a/pom.xml +++ b/pom.xml @@ -70,6 +70,7 @@ <properties> <javaVersion>7</javaVersion> <mavenVersion>3.1.1</mavenVersion> + <mavenPluginToolsVersion>3.6.0</mavenPluginToolsVersion> <surefire.version>2.22.2</surefire.version> <project.build.outputTimestamp>2020-04-07T21:04:00Z</project.build.outputTimestamp> </properties> @@ -107,32 +108,11 @@ <groupId>org.apache.maven.plugin-tools</groupId> <artifactId>maven-plugin-tools-generators</artifactId> <version>${mavenPluginToolsVersion}</version> - <exclusions> - <exclusion> - <groupId>org.apache.maven</groupId> - <artifactId>maven-project</artifactId> - </exclusion> - <exclusion> - <groupId>org.ow2.asm</groupId> - <artifactId>asm-commons</artifactId> - </exclusion> - <exclusion> - <groupId>org.ow2.asm</groupId> - <artifactId>asm-tree</artifactId> - </exclusion> - <exclusion> - <groupId>org.ow2.asm</groupId> - <artifactId>asm</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.maven</groupId> - <artifactId>maven-plugin-descriptor</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> <groupId>org.apache.maven.plugin-tools</groupId> <artifactId>maven-plugin-annotations</artifactId> + <version>${mavenPluginToolsVersion}</version> <scope>provided</scope> </dependency> @@ -153,12 +133,6 @@ <version>1.4</version> </dependency> - <!-- plexus --> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-component-annotations</artifactId> - <scope>provided</scope> - </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-interactivity-api</artifactId> |
In reply to this post by slachiewicz
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch refactor-test in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git commit c03f18175203507ffdf81b925a32b70fe9f109e5 Author: Sylwester Lachiewicz <[hidden email]> AuthorDate: Mon Jan 11 23:59:57 2021 +0100 Site plugin updates, fluido 1.9, small docs update. Bump m-site-p to 3.9.1 and m-project-info-plugin to 3.1.1 --- pom.xml | 11 +++++++++++ src/site/apt/index.apt.vm | 10 ++++------ src/site/site.xml | 12 ++++++++---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 5e8aaf7..2e9ba4b 100644 --- a/pom.xml +++ b/pom.xml @@ -208,6 +208,17 @@ <helpPackageName>org.apache.maven.plugins.help</helpPackageName> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <version>3.9.1</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>3.1.1</version> + </plugin> + </plugins> </pluginManagement> <plugins> diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index d3909d1..c1d9499 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -68,12 +68,10 @@ ${project.name} * Usage General instructions on how to use the Help Plugin can be found on the {{{./usage.html}usage page}}. Some more - specific use cases are described in the examples given below. Last but not least, users occasionally contribute - additional examples, tips or errata to the - {{{http://docs.codehaus.org/display/MAVENUSER/Help+Plugin}plugin's wiki page}}. + specific use cases are described in the examples given below. - In case you still have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel - free to contact the {{{./mailing-lists.html}user mailing list}}. The posts to the mailing list are archived and could + In case you still have questions regarding the plugin's usage, please feel free to contact the + {{{./mailing-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{./mailing-lists.html}mail archive}}. @@ -83,7 +81,7 @@ ${project.name} entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{./scm.html}source repository}} and will find supplementary information in the - {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. + {{{https://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples diff --git a/src/site/site.xml b/src/site/site.xml index 33f1166..d210372 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -19,9 +19,13 @@ specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/DECORATION/1.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> +<project xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 https://maven.apache.org/xsd/decoration-1.8.0.xsd"> + <skin> + <groupId>org.apache.maven.skins</groupId> + <artifactId>maven-fluido-skin</artifactId> + <version>1.9</version> + </skin> <body> <menu name="Overview"> <item name="Introduction" href="index.html"/> @@ -29,7 +33,7 @@ under the License. <item name="Usage" href="usage.html"/> <item name="FAQ" href="faq.html"/> <!-- According to https://issues.apache.org/jira/browse/MNGSITE-152 --> - <item name="License" href="http://www.apache.org/licenses/"/> + <item name="License" href="https://www.apache.org/licenses/"/> <item name="Download" href="download.html"/> </menu> <menu name="Examples"> |
In reply to this post by slachiewicz
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch refactor-test in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git commit 7fbc796cf460678e6b954d3be7056a6a1debd1fa Author: Sylwester Lachiewicz <[hidden email]> AuthorDate: Tue Jan 12 23:09:39 2021 +0100 Bump commons-lang3 to 3.8.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2e9ba4b..1efa830 100644 --- a/pom.xml +++ b/pom.xml @@ -168,7 +168,7 @@ <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> - <version>3.7</version> + <version>3.8.1</version> <!-- commons-lang3 > 3.8.1 requires at least Java 8 --> </dependency> <!-- test --> |
In reply to this post by slachiewicz
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch refactor-test in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git commit 78908caf96ea8c342c143c790793d9cb077028ee Author: Sylwester Lachiewicz <[hidden email]> AuthorDate: Tue Jan 12 23:18:31 2021 +0100 Upgrade maven-enforcer-plugin to 3.0.0-M3 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 1efa830..c0a52bb 100644 --- a/pom.xml +++ b/pom.xml @@ -202,23 +202,23 @@ <pluginManagement> <plugins> <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugin-plugin</artifactId> <configuration> <helpPackageName>org.apache.maven.plugins.help</helpPackageName> </configuration> </plugin> <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>3.9.1</version> </plugin> <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>3.1.1</version> </plugin> - + <plugin> + <artifactId>maven-enforcer-plugin</artifactId> + <version>3.0.0-M3</version> + </plugin> </plugins> </pluginManagement> <plugins> |
In reply to this post by slachiewicz
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch refactor-test in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git commit 94e0f4df9dd89894c45239a38e7a87ee18dd3d6b Author: Sylwester Lachiewicz <[hidden email]> AuthorDate: Tue Jan 12 23:23:28 2021 +0100 Upgrade maven-checkstyle-plugin to 3.1.1 --- pom.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pom.xml b/pom.xml index c0a52bb..97fbe02 100644 --- a/pom.xml +++ b/pom.xml @@ -207,6 +207,7 @@ <helpPackageName>org.apache.maven.plugins.help</helpPackageName> </configuration> </plugin> + <!-- remove with parent upgrade --> <plugin> <artifactId>maven-site-plugin</artifactId> <version>3.9.1</version> @@ -219,6 +220,22 @@ <artifactId>maven-enforcer-plugin</artifactId> <version>3.0.0-M3</version> </plugin> + <plugin> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>3.1.1</version> + <dependencies> + <dependency> + <groupId>com.puppycrawl.tools</groupId> + <artifactId>checkstyle</artifactId> + <version>8.29</version> + </dependency> + <dependency> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-shared-resources</artifactId> + <version>3</version> + </dependency> + </dependencies> + </plugin> </plugins> </pluginManagement> <plugins> |
In reply to this post by slachiewicz
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch refactor-test in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git commit d7d2734648e689ce5996f37553ac9f0b43259e4b Author: Sylwester Lachiewicz <[hidden email]> AuthorDate: Tue Jan 12 23:11:14 2021 +0100 Bump asm to 9.0 (maven-plugin-tools-generators) --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 97fbe02..5f34eeb 100644 --- a/pom.xml +++ b/pom.xml @@ -110,6 +110,16 @@ <version>${mavenPluginToolsVersion}</version> </dependency> <dependency> + <groupId>org.ow2.asm</groupId> + <artifactId>asm</artifactId> + <version>9.0</version> + </dependency> + <dependency> + <groupId>org.ow2.asm</groupId> + <artifactId>asm-commons</artifactId> + <version>9.0</version> + </dependency> + <dependency> <groupId>org.apache.maven.plugin-tools</groupId> <artifactId>maven-plugin-annotations</artifactId> <version>${mavenPluginToolsVersion}</version> |
Free forum by Nabble | Edit this page |