Skip to content
/ maven Public
forked from apache/maven

Commit

Permalink
Fix apache#140 by separating no-overwritten test into two basing on m…
Browse files Browse the repository at this point in the history
…aven version (apache#154)

* fix apache#140 by separating no-overwritten test into two basing on maven version

* parse maven version by ./mvnw -v

* remove redundent code

Co-authored-by: yangnuoyu <yangnuoyu@penguin>
  • Loading branch information
yangnuoyu and yangnuoyu committed Jun 2, 2020
1 parent 939c5fd commit 6b5779f
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/it/projects/no-overwrite-3.6.2-before/.flattened-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>resolve-properties</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>dep</artifactId>
<version>1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
String mavenVersion = "./mvnw -v".execute().text.split()[2]
String[] mavenVersionArray = mavenVersion.split("\\.")
int[] versionArray = new int[3]
for (int i = 0; i < 3; i++)
versionArray[i] = Integer.valueOf(mavenVersionArray[i])
boolean isValid = versionArray[0] < 3\
|| versionArray[0] == 3 && versionArray[1] < 6\
|| versionArray[0] == 3 && versionArray[1] == 6 && versionArray[2] < 3
if (isValid) {
File flattendPom = new File( basedir, '.flattened-pom.xml' )
assert flattendPom.exists()
long now = System.currentTimeMillis()
assert now - flattendPom.lastModified() > 20*1000
}

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

19 changes: 19 additions & 0 deletions src/it/projects/no-overwrite-3.6.3-later/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>resolve-properties</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
<depVersion>1.1</depVersion>
</properties>

<dependencies>
<dependency>
<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>dep</artifactId>
<version>${depVersion}</version>
</dependency>
</dependencies>

</project>
34 changes: 34 additions & 0 deletions src/it/projects/no-overwrite-3.6.3-later/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
String mavenVersion = "./mvnw -v".execute().text.split()[2]
String[] mavenVersionArray = mavenVersion.split("\\.")
int[] versionArray = new int[3]
for (int i = 0; i < 3; i++)
versionArray[i] = Integer.valueOf(mavenVersionArray[i])
boolean isValid = versionArray[0] > 3\
|| versionArray[0] == 3 && versionArray[1] > 6\
|| versionArray[0] == 3 && versionArray[1] == 6 && versionArray[2] >= 3
if (isValid) {
File flattendPom = new File( basedir, '.flattened-pom.xml' )
assert flattendPom.exists()
long now = System.currentTimeMillis()
assert now - flattendPom.lastModified() > 20*1000
}


0 comments on commit 6b5779f

Please sign in to comment.