Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Specify wrapper version (or latest) #138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions maven-wrapper-plugin/src/it/projects/default/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ assert new File(basedir,'.mvn/wrapper/maven-wrapper.properties').exists()

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains('[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:')
assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")
assert log.contains("\nApache Maven $mavenVersion ")
// check "mvnw -v" output
assert log.contains('Apache Maven ')
assert !log.contains("[INFO] Apache Maven $mavenVersion")

Properties props = new Properties()
new File(basedir,'.mvn/wrapper/maven-wrapper.properties').withInputStream {
props.load(it)
}
assert props.wrapperVersion.equals(wrapperCurrentVersion)
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")
15 changes: 14 additions & 1 deletion maven-wrapper-plugin/src/it/projects/extension/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@
* specific language governing permissions and limitations
* under the License.
*/

assert new File(basedir,'mvnw').exists()
assert new File(basedir,'mvnw.cmd').exists()
assert !(new File(basedir,'mvnwDebug').exists())
assert !(new File(basedir,'mvnwDebug.cmd').exists())
assert new File(basedir,'.mvn/wrapper/maven-wrapper.properties').exists()

Properties props = new Properties()
new File(basedir,'.mvn/wrapper/maven-wrapper.properties').withInputStream {
props.load(it)
}
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")
assert !log.contains("Apache Maven")
14 changes: 14 additions & 0 deletions maven-wrapper-plugin/src/it/projects/includeDebug/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,17 @@ assert new File(basedir,'mvnw').exists()
assert new File(basedir,'mvnw.cmd').exists()
assert new File(basedir,'mvnwDebug').exists()
assert new File(basedir,'mvnwDebug.cmd').exists()

Properties props = new Properties()
new File(basedir,'.mvn/wrapper/maven-wrapper.properties').withInputStream {
props.load(it)
}
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")
assert log.contains("Apache Maven $mavenVersion")
assert !log.contains("[INFO] Apache Maven $mavenVersion")
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def props = new Properties()
propertiesFile.withInputStream {
props.load( it )
}

def (_, mavenVersion1, mavenVersion2) = (props.distributionUrl =~ /\/org\/apache\/maven\/apache-maven\/(.+)\/apache-maven-(.+)-bin.zip/)[0]

assert mavenVersion1 == mavenVersion2
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")

log = new File( basedir, 'build.log' ).text
// check "mvn wrapper:wrapper" output
assert log.contains( '[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:' )
assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")
// check "mvnw -v" output
assert log.contains( 'Apache Maven ' + mavenVersion1 )
assert log.contains("Apache Maven $mavenVersion")
assert !log.contains("[INFO] Apache Maven ")
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def props = new Properties()
propertiesFile.withInputStream {
props.load( it )
}

def (_, mavenVersion1, mavenVersion2) = (props.distributionUrl =~ /\/org\/apache\/maven\/apache-maven\/(.+)\/apache-maven-(.+)-bin.zip/)[0]

assert mavenVersion1 == mavenVersion2
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")

log = new File( basedir, 'build.log' ).text
// check "mvn wrapper:wrapper" output
assert log.contains( '[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:' )
assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")
// check "mvnw -v" output
assert log.contains( 'Apache Maven ' + mavenVersion1 )
assert log.contains("Apache Maven $mavenVersion")
assert !log.contains("[INFO] Apache Maven ")
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/

assert new File(basedir,'mvnw').exists()
assert new File(basedir,'mvnw.cmd').exists()
assert !(new File(basedir,'mvnwDebug').exists())
Expand All @@ -30,11 +30,13 @@ Properties props = new Properties()
propertiesFile.withInputStream {
props.load(it)
}
assert props.wrapperVersion.equals(wrapperCurrentVersion)
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl.endsWith('/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip')

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains('[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:')
assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")
// check "mvnw -v" output
assert log.contains('Apache Maven 3.6.3')
assert !log.contains("[INFO] Apache Maven ")
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,20 @@ assert !(new File(basedir,'mvnwDebug.cmd').exists())

properties = new File(basedir,'.mvn/wrapper/maven-wrapper.properties')
assert properties.exists()
assert properties.text.contains('distributionSha256Sum=7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb')
def props = new Properties()
properties.withInputStream {
props.load( it )
}
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl.endsWith("/org/apache/maven/wrapper/maven-wrapper/${props.wrapperVersion}/maven-wrapper-${props.wrapperVersion}.jar")
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")
assert props.distributionSha256Sum == '7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb'
assert props.wrapperSha256Sum == null

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains('Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised.')

assert log.contains("[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:$wrapperCurrentVersion\n[INFO] Configuring .mvn/wrapper/maven-wrapper.properties to use Maven $mavenVersion and download from ")
// check "mvnw -v" output
assert log.contains('Apache Maven ')
assert log.contains("[INFO] Apache Maven Wrapper ${props.wrapperVersion}\n[INFO] Installing Maven distribution ")
assert !log.contains("Apache Maven $mavenVersion")
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ assert !(new File(basedir,'mvnwDebug.cmd').exists())

properties = new File(basedir,'.mvn/wrapper/maven-wrapper.properties')
assert properties.exists()
assert properties.text.contains('distributionSha256Sum=7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb')
def props = new Properties()
properties.withInputStream {
props.load( it )
}
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")
assert props.distributionSha256Sum == '7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb'
assert props.wrapperSha256Sum == null

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains('Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised.')
assert !log.contains('shasum:')
assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")

// check "mvnw -v" output
assert !log.contains('Apache Maven ')
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ assert !(new File(basedir,'mvnwDebug.cmd').exists())

properties = new File(basedir,'.mvn/wrapper/maven-wrapper.properties')
assert properties.exists()
assert properties.text.contains('wrapperSha256Sum=7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb')
def props = new Properties()
properties.withInputStream {
props.load( it )
}
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl.endsWith("/org/apache/maven/wrapper/maven-wrapper/${props.wrapperVersion}/maven-wrapper-${props.wrapperVersion}.jar")
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")
assert props.distributionSha256Sum == null
assert props.wrapperSha256Sum == '7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb'

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains('Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.')
assert !log.contains('shasum:')
assert log.contains("[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:$wrapperCurrentVersion")

// check "mvnw -v" output
assert !log.contains('Apache Maven ')
7 changes: 5 additions & 2 deletions maven-wrapper-plugin/src/it/projects/test_mvnd/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ propertiesFile.withInputStream {
props.load(it)
}

assert props.distributionUrl.equals('https://archive.apache.org/dist/maven/mvnd/0.9.0/maven-mvnd-0.9.0-bin.zip')
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl == 'https://archive.apache.org/dist/maven/mvnd/0.9.0/maven-mvnd-0.9.0-bin.zip'

log = new File(basedir, 'build.log').text

// check "mvn wrapper:wrapper" output
// works only on 'only-script' type
assert log.contains('[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:')
assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")

// check "mvnw --status" output
assert log.contains("Status")
assert log.contains("RSS")
assert log.contains("Java home")
assert !log.contains("Apache Maven")
11 changes: 7 additions & 4 deletions maven-wrapper-plugin/src/it/projects/type_bin/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ assert new File(basedir,'.mvn/wrapper/maven-wrapper.jar').exists()

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains('[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:')
// check "mvnw -v" output
assert log.contains('Apache Maven ')
assert log.contains("[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:$wrapperCurrentVersion\n[INFO] Configuring .mvn/wrapper/maven-wrapper.properties to use Maven $mavenVersion and download from ")

Properties props = new Properties()
new File(basedir,'.mvn/wrapper/maven-wrapper.properties').withInputStream {
props.load(it)
}
assert props.wrapperVersion.equals(wrapperCurrentVersion)
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl.endsWith("/org/apache/maven/wrapper/maven-wrapper/${props.wrapperVersion}/maven-wrapper-${props.wrapperVersion}.jar")
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")

// check "mvnw -v" output
assert log.contains("[INFO] Apache Maven Wrapper ${props.wrapperVersion}\nApache Maven $mavenVersion")
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
log = new File(basedir, 'build.log').text
boolean isWindows = System.getProperty('os.name', 'unknown').startsWith('Windows')

assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")
assert !log.contains("Apache Maven")
if (isWindows) {
// on Windows: just the fact it failed is enough
assert log.contains('Exception calling "DownloadFile"')
Expand All @@ -29,3 +31,13 @@ if (isWindows) {
// cover all methods: point is, there is no Maven version 0.0.0
assert log.contains('wget: Failed to fetch') || log.contains('curl: Failed to fetch') || log.contains('- Error downloading:')
}

properties = new File(basedir,'.mvn/wrapper/maven-wrapper.properties')
assert properties.exists()
def props = new Properties()
properties.withInputStream {
props.load( it )
}
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/0.0.0/apache-maven-0.0.0-bin.zip")
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ assert new File(basedir,'mvnw.cmd').exists()
assert !(new File(basedir,'mvnwDebug').exists())
assert !(new File(basedir,'mvnwDebug.cmd').exists())

wrapperProperties = new File(basedir,'.mvn/wrapper/maven-wrapper.properties')
assert wrapperProperties.exists()
assert !wrapperProperties.text.contains('wrapperUrl')

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains('[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:')
assert log.contains("[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:$wrapperCurrentVersion")

// check "mvnw -v" output
assert log.contains("Couldn't find ")
assert log.contains(", downloading and installing it ...")
assert log.contains("Apache Maven $mavenVersion")
assert !log.contains("[INFO] Apache Maven ")

Properties props = new Properties()
new File(basedir,'.mvn/wrapper/maven-wrapper.properties').withInputStream {
props.load(it)
}
assert props.wrapperVersion.equals(wrapperCurrentVersion)
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl == null
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")
23 changes: 13 additions & 10 deletions maven-wrapper-plugin/src/it/projects/type_script/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,24 @@ assert new File(basedir,'mvnw.cmd').exists()
assert !(new File(basedir,'mvnwDebug').exists())
assert !(new File(basedir,'mvnwDebug.cmd').exists())

wrapperProperties = new File(basedir,'.mvn/wrapper/maven-wrapper.properties')
assert wrapperProperties.exists()
assert wrapperProperties.text.contains('wrapperUrl')
properties = new File(basedir,'.mvn/wrapper/maven-wrapper.properties')
assert properties.exists()
def props = new Properties()
properties.withInputStream {
props.load( it )
}
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl.endsWith("/org/apache/maven/wrapper/maven-wrapper/${props.wrapperVersion}/maven-wrapper-${props.wrapperVersion}.jar")
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains('[INFO] Unpacked script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:script:')
assert log.contains("[INFO] Unpacked script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:script:${props.wrapperVersion}\n[INFO] Configuring .mvn/wrapper/maven-wrapper.properties to use Maven $mavenVersion and download from ")
assert log.contains("\nApache Maven $mavenVersion ")

// check "mvnw -v" output
assert log.contains("Couldn't find ")
assert log.contains(", downloading it ...")
assert log.contains("[INFO] Apache Maven Wrapper ${props.wrapperVersion}\n[INFO] Installing Maven distribution ")
assert !log.contains("[INFO] Apache Maven $mavenVersion")
assert new File(basedir,'.mvn/wrapper/maven-wrapper.jar').exists()

Properties props = new Properties()
new File(basedir,'.mvn/wrapper/maven-wrapper.properties').withInputStream {
props.load(it)
}
assert props.wrapperVersion.equals(wrapperCurrentVersion)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ assert new File(basedir,'.mvn/wrapper/MavenWrapperDownloader.java').exists()

log = new File(basedir, 'build.log').text
// check "mvn wrapper:wrapper" output
assert log.contains('[INFO] Unpacked source type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:source:')
assert log.contains("[INFO] Unpacked source type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:source:$wrapperCurrentVersion\n[INFO] Configuring .mvn/wrapper/maven-wrapper.properties to use Maven $mavenVersion and download from ")

// check "mvnw -v" output
assert log.contains("Couldn't find ")
Expand All @@ -38,4 +38,8 @@ Properties props = new Properties()
new File(basedir,'.mvn/wrapper/maven-wrapper.properties').withInputStream {
props.load(it)
}
assert props.wrapperVersion.equals(wrapperCurrentVersion)
assert props.wrapperVersion == wrapperCurrentVersion
assert props.wrapperUrl.endsWith("/org/apache/maven/wrapper/maven-wrapper/${props.wrapperVersion}/maven-wrapper-${props.wrapperVersion}.jar")
assert props.distributionUrl.endsWith("/org/apache/maven/apache-maven/$mavenVersion/apache-maven-$mavenVersion-bin.zip")

assert log.contains("[INFO] Apache Maven Wrapper ${props.wrapperVersion}\nApache Maven $mavenVersion")
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ assert !new File( basedir, '.mvn/wrapper' ).exists()

def buildLog = new File( basedir, "build.log").text;

assert buildLog.matches('(?ms).*artifact: org.apache.maven.wrapper:maven-wrapper-distribution:zip:unknown-type:.* not resolved.*')
assert buildLog.contains("artifact: org.apache.maven.wrapper:maven-wrapper-distribution:zip:unknown-type:$wrapperCurrentVersion not resolved")
assert !buildLog.contains("Apache Maven")
Loading