Skip to content

Commit

Permalink
use java 1.7 #197
Browse files Browse the repository at this point in the history
Signed-off-by: olivier lamy <olamy@apache.org>
  • Loading branch information
olamy committed Aug 17, 2017
1 parent 2fd485b commit 6ea133f
Show file tree
Hide file tree
Showing 28 changed files with 134 additions and 271 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: java
jdk:
- openjdk6
- oraclejdk7
- oraclejdk8
# We don't need an install before
Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
</issueManagement>

<properties>
<mojo.java.target>1.5</mojo.java.target>
<mojo.java.target>1.7</mojo.java.target>

<mavenVersion>2.2.1</mavenVersion>
<wagonVersion>2.12</wagonVersion>
<doxiaVersion>1.7</doxiaVersion>
Expand Down Expand Up @@ -321,15 +322,15 @@
<artifactId>animal-sniffer-maven-plugin</artifactId>
<executions>
<execution>
<id>check-java15</id>
<id>check-java17</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java15</artifactId>
<artifactId>java17</artifactId>
<version>1.0</version>
</signature>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ protected void logInit()
Set<String> files = (Set<String>) getPluginContext().get( key );
if ( files == null )
{
files = new LinkedHashSet<String>();
files = new LinkedHashSet<>();
}
else
{
files = new LinkedHashSet<String>( files );
files = new LinkedHashSet<>( files );
}
if ( !files.contains( outputFileName ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ private Set<String> getVersionsInRange( Property property, PropertyVersions vers
ArtifactVersion[] artifactVersions )
{
VersionRange range;
Set<String> rangeVersions = new HashSet<String>();
Set<String> rangeVersions = new HashSet<>();
ArtifactVersion[] tmp;
if ( property.getVersion() != null )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private List<String> compareVersions( ModifiedPomXMLEventReader pom, List<Depend
Map<String, Dependency> remoteDependencies )
throws MojoExecutionException, XMLStreamException
{
List<String> updates = new ArrayList<String>();
List<String> updates = new ArrayList<>();
for ( Dependency dep : dependencies )
{
Artifact artifact = this.toArtifact( dep );
Expand Down Expand Up @@ -288,7 +288,7 @@ private List<String> updatePropertyVersions( ModifiedPomXMLEventReader pom,
Map<String, Dependency> remoteDependencies )
throws XMLStreamException
{
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
for ( Map.Entry<Property, PropertyVersions> entry : versionProperties.entrySet() )
{
Property property = entry.getKey();
Expand Down Expand Up @@ -362,12 +362,9 @@ private void writeReportFile( List<String> dependenciesUpdate, List<String> prop
reportOutputFile.getParentFile().mkdirs();
}

FileWriter fw = null;
PrintWriter pw = null;
try
try( FileWriter fw = new FileWriter( reportOutputFile ); //
PrintWriter pw = new PrintWriter( fw ) )
{
fw = new FileWriter( reportOutputFile );
pw = new PrintWriter( fw );
pw.println( "The following differences were found:" );
pw.println();
if ( dependenciesUpdate.size() == 0 )
Expand Down Expand Up @@ -395,32 +392,11 @@ private void writeReportFile( List<String> dependenciesUpdate, List<String> prop
pw.println( " " + propertyUpdate );
}
}
pw.close();
fw.close();
}
catch ( IOException e )
{
throw new MojoExecutionException( "Unable to write report file. ", e );
}
finally
{
if ( pw != null )
{
pw.close();
}
if ( fw != null )
{
try
{
fw.close();
}
catch ( IOException io )
{
// Ignore
}
}
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ public boolean canGenerateReport()
protected void doGenerateReport( Locale locale, Sink sink )
throws MavenReportException
{
Set dependencies = new TreeSet( new DependencyComparator() );
Set<Dependency> dependencies = new TreeSet( new DependencyComparator() );
dependencies.addAll( getProject().getDependencies() );

Set dependencyManagement = new TreeSet( new DependencyComparator() );
Set<Dependency> dependencyManagement = new TreeSet( new DependencyComparator() );

if ( processDependencyManagementTransitive )
{
Expand Down Expand Up @@ -178,11 +178,7 @@ else if ( "xml".equals( format ) )
}
}
}
catch ( InvalidVersionSpecificationException e )
{
throw new MavenReportException( e.getMessage(), e );
}
catch ( ArtifactMetadataRetrievalException e )
catch ( InvalidVersionSpecificationException| ArtifactMetadataRetrievalException e )
{
throw new MavenReportException( e.getMessage(), e );
}
Expand All @@ -198,17 +194,17 @@ else if ( "xml".equals( format ) )
* management dependencies.
* @since 1.0-beta-1
*/
private static Set removeDependencyManagment( Set dependencies, Set dependencyManagement )
private static Set removeDependencyManagment( Set<Dependency> dependencies, Set<Dependency> dependencyManagement )
{
Set result = new TreeSet( new DependencyComparator() );
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
Set<Dependency> result = new TreeSet( new DependencyComparator() );
for ( Iterator<Dependency> i = dependencies.iterator(); i.hasNext(); )
{
Dependency c = (Dependency) i.next();
Dependency c = i.next();
boolean matched = false;
Iterator j = dependencyManagement.iterator();
Iterator<Dependency> j = dependencyManagement.iterator();
while ( !matched && j.hasNext() )
{
Dependency t = (Dependency) j.next();
Dependency t = j.next();
if ( StringUtils.equals( t.getGroupId(), c.getGroupId() )
&& StringUtils.equals( t.getArtifactId(), c.getArtifactId() )
&& ( t.getScope() == null || StringUtils.equals( t.getScope(), c.getScope() ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public void render()
{
StringBuilder sb = new StringBuilder();
sb.append( "<DependencyUpdatesReport>" ).append( NL );
Map<Dependency, ArtifactVersions> allUpdates =
new TreeMap<Dependency, ArtifactVersions>( new DependencyComparator() );
Map<Dependency, ArtifactVersions> allUpdates = new TreeMap<>( new DependencyComparator() );
allUpdates.putAll( dependencyManagementUpdates );
allUpdates.putAll( dependencyUpdates );
sb.append( getSummaryBlock( allUpdates.values() ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public class DisplayDependencyUpdatesMojo

private static Set<Dependency> extractPluginDependenciesFromPluginsInPluginManagement( Build build )
{
Set<Dependency> result = new TreeSet<Dependency>( new DependencyComparator() );
Set<Dependency> result = new TreeSet<>( new DependencyComparator() );
if ( build.getPluginManagement() != null )
{
for ( Plugin plugin : build.getPluginManagement().getPlugins() )
Expand All @@ -171,7 +171,7 @@ private static Set<Dependency> extractPluginDependenciesFromPluginsInPluginManag

private static Set<Dependency> extractDependenciesFromPlugins( List<Plugin> plugins )
{
Set<Dependency> result = new TreeSet<Dependency>( new DependencyComparator() );
Set<Dependency> result = new TreeSet<>( new DependencyComparator() );
for ( Plugin plugin : plugins )
{
if ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() )
Expand All @@ -195,17 +195,17 @@ private static Set<Dependency> extractDependenciesFromPlugins( List<Plugin> plug
* management dependencies.
* @since 1.0-beta-1
*/
private static Set<Dependency> removeDependencyManagment( Set dependencies, Set dependencyManagement )
private static Set<Dependency> removeDependencyManagment( Set<Dependency> dependencies, Set<Dependency> dependencyManagement )
{
Set<Dependency> result = new TreeSet<Dependency>( new DependencyComparator() );
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
Set<Dependency> result = new TreeSet<>( new DependencyComparator() );
for ( Iterator<Dependency> i = dependencies.iterator(); i.hasNext(); )
{
Dependency c = (Dependency) i.next();
Dependency c = i.next();
boolean matched = false;
Iterator j = dependencyManagement.iterator();
Iterator<Dependency> j = dependencyManagement.iterator();
while ( !matched && j.hasNext() )
{
Dependency t = (Dependency) j.next();
Dependency t =j.next();
if ( StringUtils.equals( t.getGroupId(), c.getGroupId() )
&& StringUtils.equals( t.getArtifactId(), c.getArtifactId() )
&& ( t.getScope() == null || StringUtils.equals( t.getScope(), c.getScope() ) )
Expand Down Expand Up @@ -265,7 +265,7 @@ public void execute()
{
logInit();

Set<Dependency> dependencyManagement = new TreeSet<Dependency>( new DependencyComparator() );
Set<Dependency> dependencyManagement = new TreeSet<>( new DependencyComparator() );
if ( getProject().getDependencyManagement() != null )
{

Expand Down Expand Up @@ -312,22 +312,22 @@ public void execute()
}
}

Set<Dependency> dependencies = new TreeSet<Dependency>( new DependencyComparator() );
Set<Dependency> dependencies = new TreeSet<>( new DependencyComparator() );
dependencies.addAll( getProject().getDependencies() );

if ( isProcessingDependencyManagement() )
{
dependencies = removeDependencyManagment( dependencies, dependencyManagement );
}

Set<Dependency> pluginDependencies = new TreeSet<Dependency>( new DependencyComparator() );
Set<Dependency> pluginDependencies = new TreeSet<>( new DependencyComparator() );

if ( isProcessingPluginDependencies() )
{
pluginDependencies = extractDependenciesFromPlugins( getProject().getBuildPlugins() );
}

Set<Dependency> pluginDependenciesInPluginManagement = new TreeSet<Dependency>( new DependencyComparator() );
Set<Dependency> pluginDependenciesInPluginManagement = new TreeSet<>( new DependencyComparator() );
if ( isProcessPluginDependenciesInDependencyManagement() )
{
pluginDependenciesInPluginManagement =
Expand Down Expand Up @@ -394,8 +394,8 @@ private UpdateScope calculateUpdateScope()

private void logUpdates( Map<Dependency, ArtifactVersions> updates, String section )
{
List withUpdates = new ArrayList();
List usingCurrent = new ArrayList();
List<String> withUpdates = new ArrayList();
List<String> usingCurrent = new ArrayList();
Iterator i = updates.values().iterator();
while ( i.hasNext() )
{
Expand Down
Loading

0 comments on commit 6ea133f

Please sign in to comment.