Skip to content

Commit

Permalink
upgrade to last mojo parent and remove restrictions on java 1.5
Browse files Browse the repository at this point in the history
Signed-off-by: olivier lamy <olamy@apache.org>
  • Loading branch information
olamy committed Mar 26, 2020
1 parent 12bafd3 commit 1671028
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
13 changes: 10 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mojo-parent</artifactId>
<version>40</version>
<version>50</version>
</parent>
<artifactId>flatten-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
Expand All @@ -37,8 +37,6 @@
</prerequisites>
<properties>
<mavenVersion>3.2.5</mavenVersion>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
</properties>
<developers>
<developer>
Expand Down Expand Up @@ -177,6 +175,15 @@
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.2.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
22 changes: 4 additions & 18 deletions src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,19 +492,16 @@ protected void writePom( Model pom, File pomFile, String headerComment )
protected void writeStringToFile( String data, File file, String encoding )
throws MojoExecutionException
{

OutputStream outStream = null;
try
try (OutputStream outStream = new FileOutputStream( file ))
{
byte[] binaryData = data.getBytes( encoding );

if ( file.isFile() && file.canRead() && file.length() == binaryData.length )
{
InputStream inputStream = null;
try

try (InputStream inputStream = new FileInputStream( file ))
{
byte[] buffer = new byte[ binaryData.length ];
inputStream = new FileInputStream( file );
inputStream.read( buffer );
if ( Arrays.equals( buffer, binaryData ) ) {
return;
Expand All @@ -513,26 +510,15 @@ protected void writeStringToFile( String data, File file, String encoding )
catch ( IOException e )
{
// ignore those exceptions, we will overwrite the file
}
finally
{
IOUtil.close( inputStream );
getLog().debug( "Issue reading file: " + file.getPath(), e );
}
}

outStream = new FileOutputStream( file );
outStream.write( binaryData );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Failed to write to " + file, e );
}
finally
{
// resource-handling not perfectly solved but we do not want to require java 1.7
// and this is not a server application.
IOUtil.close( outStream );
}
}

/**
Expand Down

0 comments on commit 1671028

Please sign in to comment.