Skip to content

Commit

Permalink
fix apache#136 use https in pom file as it is now done in maven 3.6.3…
Browse files Browse the repository at this point in the history
… and so update travis etc bump parent pom so we can now use 1.7 (apache#137)

* fix apache#136 use https in pom file as it is now done in maven 3.6.3 and so update travis etc... bump parent pom so we can now use 1.7

Signed-off-by: olivier lamy <olamy@apache.org>

* switch to openjdk 8 and 11

Signed-off-by: olivier lamy <olamy@apache.org>
  • Loading branch information
olamy committed Mar 27, 2020
1 parent 1671028 commit 49e81a9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
@@ -1 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -6,10 +6,11 @@ language: java
dist: trusty

jdk:
- oraclejdk8
- openjdk8
- openjdk11

env:
- MAVEN_VERSION=3.5.4
- MAVEN_VERSION=3.6.3

install:
- "mvn -N io.takari:maven:wrapper -Dmaven=${MAVEN_VERSION} -Dhttps.protocols=TLSv1.2"
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -235,6 +235,7 @@
</goals>
<projectsDirectory>src/it/projects</projectsDirectory>
<postBuildHookScript>verify</postBuildHookScript>
<preBuildHookScript>setup</preBuildHookScript>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/no-overwrite/.flattened-pom.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.mojo.flatten.its</groupId>
Expand Down
3 changes: 2 additions & 1 deletion src/it/projects/no-overwrite/verify.groovy
Expand Up @@ -19,5 +19,6 @@

File flattendPom = new File( basedir, '.flattened-pom.xml' )
assert flattendPom.exists()
assert System.currentTimeMillis() - flattendPom.lastModified() > 30*1000
long now = System.currentTimeMillis()
assert now - flattendPom.lastModified() > 20*1000

25 changes: 20 additions & 5 deletions src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java
Expand Up @@ -492,27 +492,42 @@ protected void writePom( Model pom, File pomFile, String headerComment )
protected void writeStringToFile( String data, File file, String encoding )
throws MojoExecutionException
{
try (OutputStream outStream = new FileOutputStream( file ))

byte[] binaryData;

try
{
byte[] binaryData = data.getBytes( encoding );
binaryData = data.getBytes( encoding );

if ( file.isFile() && file.canRead() && file.length() == binaryData.length )
{

try (InputStream inputStream = new FileInputStream( file ))
{
byte[] buffer = new byte[ binaryData.length ];
byte[] buffer = new byte[binaryData.length];
inputStream.read( buffer );
if ( Arrays.equals( buffer, binaryData ) ) {
if ( Arrays.equals( buffer, binaryData ) )
{
getLog().debug( "Arrays.equals( buffer, binaryData ) " );
return;
}
getLog().debug( "Not Arrays.equals( buffer, binaryData ) " );
}
catch ( IOException e )
{
// ignore those exceptions, we will overwrite the file
getLog().debug( "Issue reading file: " + file.getPath(), e );
}
}
else
{
getLog().debug( "file: " + file + ",file.length(): " + file.length() + ", binaryData.length: " + binaryData.length );
}
} catch ( IOException e )
{
throw new MojoExecutionException( "cannot read String as bytes" , e );
}
try (OutputStream outStream = new FileOutputStream( file ))
{
outStream.write( binaryData );
}
catch ( IOException e )
Expand Down

0 comments on commit 49e81a9

Please sign in to comment.