This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch maven-jar-plugin-4.x
in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git
The following commit(s) were added to refs/heads/maven-jar-plugin-4.x by this
push:
new a8ded19 Format Groovy IT scripts
a8ded19 is described below
commit a8ded19eeaf3f3581256465a05c0608ebd355346
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Wed Nov 25 20:56:03 2026 +0000
Format Groovy IT scripts
Formatting only: the CONVERSION-phase AST of every file is unchanged. See
https://github.com/apache/maven-invoker-plugin/issues/811.
---
src/it/MJAR-162/verify.groovy | 40 +++---
src/it/MJAR-183/verify.groovy | 40 +++---
src/it/MJAR-199-change-classifier/verify.groovy | 49 +++----
src/it/MJAR-199/verify.groovy | 49 +++----
src/it/MJAR-228/verify.groovy | 61 ++++-----
.../MJAR-238-modular-jar-main-class/verify.groovy | 70 +++++-----
.../verify.groovy | 64 +++++----
.../verify.groovy | 40 +++---
.../verify.groovy | 50 ++++---
.../MJAR-292-detect-mjar-no-versions/verify.groovy | 6 +-
src/it/MJAR-292-detect-mjar/verify.groovy | 6 +-
src/it/MJAR-292-disable-detect-mjar/verify.groovy | 6 +-
src/it/MJAR-30-excludes/verify.groovy | 83 ++++++------
src/it/MJAR-30-fullcontent/verify.groovy | 85 ++++++------
src/it/MJAR-30-include/verify.groovy | 83 ++++++------
src/it/MJAR-510/verify.groovy | 34 +++--
.../verify.groovy | 24 ++--
src/it/MJAR-557-detect-mjar/verify.groovy | 2 +-
.../verify.groovy | 26 ++--
src/it/MJAR-60/verify.groovy | 76 +++++------
src/it/MJAR-70-no-recreation/verify.groovy | 36 +++--
src/it/MJAR-70-recreation/verify.groovy | 69 +++++-----
src/it/MJAR-80-exclude/verify.groovy | 95 ++++++-------
src/it/MJAR-80-fullcontent/verify.groovy | 95 ++++++-------
src/it/MJAR-80-include/verify.groovy | 93 ++++++-------
src/it/MJAR-82/verify.groovy | 74 +++++------
src/it/MNG-8137-warn-pom-packaging/verify.groovy | 2 +-
src/it/directory-entries-mr/verify.groovy | 2 +-
src/it/directory-entries/verify.groovy | 11 +-
src/it/manifest-content/verify.groovy | 124 ++++++++---------
src/it/manifest-created-by/verify.groovy | 2 +-
src/it/mjar-138/verify.groovy | 4 +-
src/it/mjar-139/verify.groovy | 40 +++---
src/it/mjar-71-01/verify.groovy | 72 +++++-----
src/it/mjar-71-02/verify.groovy | 72 +++++-----
src/it/mjar-90/verify.groovy | 47 +++----
.../verify.groovy | 24 ++--
src/it/multimodule-multirelease/verify.groovy | 21 ++-
src/it/multimodule/verify.groovy | 21 ++-
src/it/project-004/verify.groovy | 148 ++++++++++-----------
src/it/records-jar-validate/verify.groovy | 53 ++++----
src/it/test-jar-attach/verify.groovy | 2 +-
42 files changed, 908 insertions(+), 1093 deletions(-)
diff --git a/src/it/MJAR-162/verify.groovy b/src/it/MJAR-162/verify.groovy
index d4f0f82..4e78536 100644
--- a/src/it/MJAR-162/verify.groovy
+++ b/src/it/MJAR-162/verify.groovy
@@ -18,33 +18,29 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-162-1.0-tests.jar" );
- if ( artifact.exists() )
- {
- System.err.println( "test artifact should not exist." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-162-1.0-tests.jar")
+ if (artifact.exists()) {
+ System.err.println("test artifact should not exist.")
+ return false
}
- return true;
+ return true
}
-catch( Throwable e )
-{
- e.printStackTrace();
- return false;
+catch(Throwable e) {
+ e.printStackTrace()
+ return false
}
-return false;
+return false
diff --git a/src/it/MJAR-183/verify.groovy b/src/it/MJAR-183/verify.groovy
index a024918..9800a50 100644
--- a/src/it/MJAR-183/verify.groovy
+++ b/src/it/MJAR-183/verify.groovy
@@ -18,34 +18,30 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-183-1.0-SNAPSHOT.jar" );
- if ( !artifact.exists() )
- {
- System.err.println( "default artifact should exist." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-183-1.0-SNAPSHOT.jar")
+ if (!artifact.exists()) {
+ System.err.println("default artifact should exist.")
+ return false
}
- return true;
+ return true
}
-catch( Throwable e )
-{
- e.printStackTrace();
- return false;
+catch(Throwable e) {
+ e.printStackTrace()
+ return false
}
-return false;
+return false
diff --git a/src/it/MJAR-199-change-classifier/verify.groovy
b/src/it/MJAR-199-change-classifier/verify.groovy
index 5864f37..82e1f7d 100644
--- a/src/it/MJAR-199-change-classifier/verify.groovy
+++ b/src/it/MJAR-199-change-classifier/verify.groovy
@@ -18,40 +18,35 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-199-1.0-SNAPSHOT.jar" );
- if ( !artifact.exists() )
- {
- System.err.println( "default artifact should exist." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-199-1.0-SNAPSHOT.jar")
+ if (!artifact.exists()) {
+ System.err.println("default artifact should exist.")
+ return false
}
- artifact = new File( target,
"maven-jar-plugin-test-mjar-199-1.0-SNAPSHOT-xyz.jar" );
- if ( !artifact.exists() )
- {
- System.err.println( "test artifact should exist with classifier from
pom file." );
- return false;
+ artifact = new File(target,
"maven-jar-plugin-test-mjar-199-1.0-SNAPSHOT-xyz.jar")
+ if (!artifact.exists()) {
+ System.err.println("test artifact should exist with classifier from
pom file.")
+ return false
}
- return true;
+ return true
}
-catch( Throwable e )
-{
- e.printStackTrace();
- return false;
+catch(Throwable e) {
+ e.printStackTrace()
+ return false
}
-return false;
+return false
diff --git a/src/it/MJAR-199/verify.groovy b/src/it/MJAR-199/verify.groovy
index c3aba8b..6b7b7f9 100644
--- a/src/it/MJAR-199/verify.groovy
+++ b/src/it/MJAR-199/verify.groovy
@@ -18,40 +18,35 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-199-1.0-SNAPSHOT.jar" );
- if ( !artifact.exists() )
- {
- System.err.println( "default artifact should exist." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-199-1.0-SNAPSHOT.jar")
+ if (!artifact.exists()) {
+ System.err.println("default artifact should exist.")
+ return false
}
- artifact = new File( target,
"maven-jar-plugin-test-mjar-199-1.0-SNAPSHOT-tests.jar" );
- if ( !artifact.exists() )
- {
- System.err.println( "test artifact should exist." );
- return false;
+ artifact = new File(target,
"maven-jar-plugin-test-mjar-199-1.0-SNAPSHOT-tests.jar")
+ if (!artifact.exists()) {
+ System.err.println("test artifact should exist.")
+ return false
}
- return true;
+ return true
}
-catch( Throwable e )
-{
- e.printStackTrace();
- return false;
+catch(Throwable e) {
+ e.printStackTrace()
+ return false
}
-return false;
+return false
diff --git a/src/it/MJAR-228/verify.groovy b/src/it/MJAR-228/verify.groovy
index fc63447..989e7a2 100644
--- a/src/it/MJAR-228/verify.groovy
+++ b/src/it/MJAR-228/verify.groovy
@@ -18,50 +18,43 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target, "mjar228-1.0-SNAPSHOT.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target, "mjar228-1.0-SNAPSHOT.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- JarFile jar = new JarFile( artifact );
+ JarFile jar = new JarFile(artifact)
- Attributes manifest = jar.getManifest().getMainAttributes();
+ Attributes manifest = jar.getManifest().getMainAttributes()
- if ( !"myproject.HelloWorld".equals( manifest.get(
Attributes.Name.MAIN_CLASS ) ) )
- {
- System.err.println( Attributes.Name.MAIN_CLASS.toString() + " not
equals myproject.HelloWorld" );
- return false;
+ if
(!"myproject.HelloWorld".equals(manifest.get(Attributes.Name.MAIN_CLASS))) {
+ System.err.println(Attributes.Name.MAIN_CLASS.toString() + " not
equals myproject.HelloWorld")
+ return false
}
- if ( !"lib/junit-4.13.2.jar lib/hamcrest-core-1.3.jar".equals(
manifest.get( Attributes.Name.CLASS_PATH ) ) )
- {
- System.err.println( Attributes.Name.CLASS_PATH.toString() +
- " equals '" + manifest.get( Attributes.Name.CLASS_PATH ) + "' " +
- " but should be 'lib/junit-4.13.2.jar lib/hamcrest-core-1.3.jar'" );
- return false;
+ if (!"lib/junit-4.13.2.jar
lib/hamcrest-core-1.3.jar".equals(manifest.get(Attributes.Name.CLASS_PATH))) {
+ System.err.println(Attributes.Name.CLASS_PATH.toString() +
+ " equals '" + manifest.get(Attributes.Name.CLASS_PATH) + "' " +
+ " but should be 'lib/junit-4.13.2.jar
lib/hamcrest-core-1.3.jar'")
+ return false
}
-
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-238-modular-jar-main-class/verify.groovy
b/src/it/MJAR-238-modular-jar-main-class/verify.groovy
index 7774fe2..27f3adc 100644
--- a/src/it/MJAR-238-modular-jar-main-class/verify.groovy
+++ b/src/it/MJAR-238-modular-jar-main-class/verify.groovy
@@ -17,59 +17,51 @@
* under the License.
*/
-import java.io.*;
-import java.lang.module.*;
-import java.util.jar.*;
+import java.io.*
+import java.lang.module.*
+import java.util.jar.*
-boolean result = true;
-JarFile jar;
+boolean result = true
+JarFile jar
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"mjar-238-modular-jar-main-class-1.0-SNAPSHOT.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target,
"mjar-238-modular-jar-main-class-1.0-SNAPSHOT.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- jar = new JarFile( artifact );
+ jar = new JarFile(artifact)
- Attributes manifest = jar.getManifest().getMainAttributes();
+ Attributes manifest = jar.getManifest().getMainAttributes()
- if ( !"myproject.HelloWorld".equals( manifest.get(
Attributes.Name.MAIN_CLASS ) ) )
- {
- System.err.println( "Manifest main class attribute not equals
myproject.HelloWorld" );
- return false;
+ if
(!"myproject.HelloWorld".equals(manifest.get(Attributes.Name.MAIN_CLASS))) {
+ System.err.println("Manifest main class attribute not equals
myproject.HelloWorld")
+ return false
}
- InputStream moduleDescriptorInputStream = jar.getInputStream(
jar.getEntry( "module-info.class" ) );
- ModuleDescriptor moduleDescriptor = ModuleDescriptor.read(
moduleDescriptorInputStream );
+ InputStream moduleDescriptorInputStream =
jar.getInputStream(jar.getEntry("module-info.class"))
+ ModuleDescriptor moduleDescriptor =
ModuleDescriptor.read(moduleDescriptorInputStream)
- if ( !"myproject.HelloWorld".equals( moduleDescriptor.mainClass().orElse(
null ) ) )
- {
- System.err.println( "Module descriptor main class not equals
myproject.HelloWorld" );
- return false;
+ if
(!"myproject.HelloWorld".equals(moduleDescriptor.mainClass().orElse(null))) {
+ System.err.println("Module descriptor main class not equals
myproject.HelloWorld")
+ return false
}
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-finally
-{
- if ( jar != null )
- {
- jar.close();
+finally {
+ if (jar != null) {
+ jar.close()
}
}
-return result;
+return result
diff --git a/src/it/MJAR-260-invalid-automatic-module-name/verify.groovy
b/src/it/MJAR-260-invalid-automatic-module-name/verify.groovy
index 52ed5ae..713abb2 100644
--- a/src/it/MJAR-260-invalid-automatic-module-name/verify.groovy
+++ b/src/it/MJAR-260-invalid-automatic-module-name/verify.groovy
@@ -18,48 +18,44 @@
* under the License.
*/
-import java.io.*;
-import java.nio.file.*;
-import java.util.*;
-import java.util.jar.*;
-
-boolean result = true;
-
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+import java.io.*
+import java.nio.file.*
+import java.util.*
+import java.util.jar.*
+
+boolean result = true
+
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"mjar260-invalid-automatic-module-name-1.0-SNAPSHOT.jar" );
- if ( artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is created or a directory." );
- return false;
+ File artifact = new File(target,
"mjar260-invalid-automatic-module-name-1.0-SNAPSHOT.jar")
+ if (artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is created or a directory.")
+ return false
}
- String log = new
String(Files.readAllBytes(basedir.toPath().resolve("build.log")), "UTF-8");
+ String log = new
String(Files.readAllBytes(basedir.toPath().resolve("build.log")), "UTF-8")
String[] snippets = [
- "BUILD FAILURE",
- "[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-jar-plugin",
- "Invalid automatic module name: \"in-valid.name.with.new.keyword\"."
- ];
+ "BUILD FAILURE",
+ "[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-jar-plugin",
+ "Invalid automatic module name: \"in-valid.name.with.new.keyword\"."
+ ]
for (String snippet : snippets) {
- if (!log.contains(snippet)) {
- System.err.println("XXX| Snippet `" + snippet + "` not found");
- result = false;
- continue;
- }
+ if (!log.contains(snippet)) {
+ System.err.println("XXX| Snippet `" + snippet + "` not found")
+ result = false
+ continue
+ }
}
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-260-valid-automatic-module-name/verify.groovy
b/src/it/MJAR-260-valid-automatic-module-name/verify.groovy
index 0618e58..155c086 100644
--- a/src/it/MJAR-260-valid-automatic-module-name/verify.groovy
+++ b/src/it/MJAR-260-valid-automatic-module-name/verify.groovy
@@ -18,34 +18,28 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"mjar260-valid-automatic-module-name-1.0-SNAPSHOT.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target,
"mjar260-valid-automatic-module-name-1.0-SNAPSHOT.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
-
-
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-275-reproducible-module-info/verify.groovy
b/src/it/MJAR-275-reproducible-module-info/verify.groovy
index f6bce52..7c0de2e 100644
--- a/src/it/MJAR-275-reproducible-module-info/verify.groovy
+++ b/src/it/MJAR-275-reproducible-module-info/verify.groovy
@@ -17,49 +17,47 @@
* under the License.
*/
-import java.io.*;
-import java.lang.module.*;
-import java.nio.file.attribute.FileTime;
-import java.time.Instant;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.lang.module.*
+import java.nio.file.attribute.FileTime
+import java.time.Instant
+import java.util.*
+import java.util.jar.*
-File target = new File( basedir, "target" )
+File target = new File(basedir, "target")
assert target.exists()
assert target.isDirectory()
-File artifact = new File( target,
"mjar-275-reproducible-multi-release-modular-jar-1.0-SNAPSHOT.jar" );
+File artifact = new File(target,
"mjar-275-reproducible-multi-release-modular-jar-1.0-SNAPSHOT.jar")
assert artifact.exists()
assert artifact.isFile()
-JarFile jar = new JarFile( artifact );
+JarFile jar = new JarFile(artifact)
-Attributes manifest = jar.getManifest().getMainAttributes();
+Attributes manifest = jar.getManifest().getMainAttributes()
-assert "myproject.HelloWorld".equals( manifest.get( Attributes.Name.MAIN_CLASS
) )
+assert "myproject.HelloWorld".equals(manifest.get(Attributes.Name.MAIN_CLASS))
-InputStream moduleDescriptorInputStream = jar.getInputStream( jar.getEntry(
"META-INF/versions/9/module-info.class" ) );
-ModuleDescriptor moduleDescriptor = ModuleDescriptor.read(
moduleDescriptorInputStream );
+InputStream moduleDescriptorInputStream =
jar.getInputStream(jar.getEntry("META-INF/versions/9/module-info.class"))
+ModuleDescriptor moduleDescriptor =
ModuleDescriptor.read(moduleDescriptorInputStream)
-assert "myproject.HelloWorld".equals( moduleDescriptor.mainClass().orElse(
null ) )
+assert "myproject.HelloWorld".equals(moduleDescriptor.mainClass().orElse(null))
// Normalize to UTC
-long normalizeUTC( String timestamp )
-{
- long millis = Instant.parse( timestamp ).toEpochMilli();
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis( millis );
- return millis - ( cal.get( Calendar.ZONE_OFFSET ) + cal.get(
Calendar.DST_OFFSET ) );
+long normalizeUTC(String timestamp) {
+ long millis = Instant.parse(timestamp).toEpochMilli()
+ Calendar cal = Calendar.getInstance()
+ cal.setTimeInMillis(millis)
+ return millis - (cal.get(Calendar.ZONE_OFFSET) +
cal.get(Calendar.DST_OFFSET))
}
// All entries should have the same timestamp
-FileTime expectedTimestamp = FileTime.fromMillis( normalizeUTC(
"2022-06-26T13:25:58Z" ) );
-Enumeration<JarEntry> entries = jar.entries();
-while ( entries.hasMoreElements() )
-{
- assert expectedTimestamp.equals(
entries.nextElement().getLastModifiedTime() )
+FileTime expectedTimestamp =
FileTime.fromMillis(normalizeUTC("2022-06-26T13:25:58Z"))
+Enumeration<JarEntry> entries = jar.entries()
+while (entries.hasMoreElements()) {
+ assert
expectedTimestamp.equals(entries.nextElement().getLastModifiedTime())
}
-jar.close();
+jar.close()
diff --git a/src/it/MJAR-292-detect-mjar-no-versions/verify.groovy
b/src/it/MJAR-292-detect-mjar-no-versions/verify.groovy
index 8578151..b34e7fe 100644
--- a/src/it/MJAR-292-detect-mjar-no-versions/verify.groovy
+++ b/src/it/MJAR-292-detect-mjar-no-versions/verify.groovy
@@ -17,10 +17,10 @@
* under the License.
*/
-import java.util.jar.*;
+import java.util.jar.*
def mrjar = new JarFile(new
File(basedir,'target/mjar-292-detect-multi-release-jar-1.0-SNAPSHOT.jar'))
def manifest = mrjar.manifest.mainAttributes
-assert manifest.getValue( Attributes.Name.MAIN_CLASS ) ==
"myproject.HelloWorld"
-assert manifest.getValue( Attributes.Name.MULTI_RELEASE ) == null
+assert manifest.getValue(Attributes.Name.MAIN_CLASS) == "myproject.HelloWorld"
+assert manifest.getValue(Attributes.Name.MULTI_RELEASE) == null
diff --git a/src/it/MJAR-292-detect-mjar/verify.groovy
b/src/it/MJAR-292-detect-mjar/verify.groovy
index a06ef63..2164e0a 100644
--- a/src/it/MJAR-292-detect-mjar/verify.groovy
+++ b/src/it/MJAR-292-detect-mjar/verify.groovy
@@ -17,10 +17,10 @@
* under the License.
*/
-import java.util.jar.*;
+import java.util.jar.*
def mrjar = new JarFile(new
File(basedir,'target/mjar-292-detect-multi-release-jar-1.0-SNAPSHOT.jar'))
def manifest = mrjar.manifest.mainAttributes
-assert manifest.getValue( Attributes.Name.MAIN_CLASS ) ==
"myproject.HelloWorld"
-assert manifest.getValue( Attributes.Name.MULTI_RELEASE ) == "true"
+assert manifest.getValue(Attributes.Name.MAIN_CLASS) == "myproject.HelloWorld"
+assert manifest.getValue(Attributes.Name.MULTI_RELEASE) == "true"
diff --git a/src/it/MJAR-292-disable-detect-mjar/verify.groovy
b/src/it/MJAR-292-disable-detect-mjar/verify.groovy
index 8578151..b34e7fe 100644
--- a/src/it/MJAR-292-disable-detect-mjar/verify.groovy
+++ b/src/it/MJAR-292-disable-detect-mjar/verify.groovy
@@ -17,10 +17,10 @@
* under the License.
*/
-import java.util.jar.*;
+import java.util.jar.*
def mrjar = new JarFile(new
File(basedir,'target/mjar-292-detect-multi-release-jar-1.0-SNAPSHOT.jar'))
def manifest = mrjar.manifest.mainAttributes
-assert manifest.getValue( Attributes.Name.MAIN_CLASS ) ==
"myproject.HelloWorld"
-assert manifest.getValue( Attributes.Name.MULTI_RELEASE ) == null
+assert manifest.getValue(Attributes.Name.MAIN_CLASS) == "myproject.HelloWorld"
+assert manifest.getValue(Attributes.Name.MULTI_RELEASE) == null
diff --git a/src/it/MJAR-30-excludes/verify.groovy
b/src/it/MJAR-30-excludes/verify.groovy
index dafd74f..e9c5d89 100644
--- a/src/it/MJAR-30-excludes/verify.groovy
+++ b/src/it/MJAR-30-excludes/verify.groovy
@@ -18,66 +18,59 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-30-03-99.0.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-30-03-99.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- String[] artifactNames = [ "default-configuration.properties",
"META-INF/MANIFEST.MF",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-03/pom.properties",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-03/pom.xml"
];
+ String[] artifactNames = [
+ "default-configuration.properties",
+ "META-INF/MANIFEST.MF",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-03/pom.properties",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-03/pom.xml"
+ ]
- Set contents = new HashSet();
+ Set contents = new HashSet()
- JarFile jar = new JarFile( artifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ JarFile jar = new JarFile(artifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- contents.add( entry.getName() );
+ contents.add(entry.getName())
}
}
- if ( artifactNames.length != contents.size() )
- {
- System.err.println( "jar content size is different from the expected
content size" );
- return false;
+ if (artifactNames.length != contents.size()) {
+ System.err.println("jar content size is different from the expected
content size")
+ return false
}
- for ( int i = 0; i < artifactNames.length; i++ )
- {
- String artifactName = artifactNames[i];
- if ( !contents.contains( artifactName ) )
- {
- System.err.println( "Artifact[" + artifactName + "] not found
in jar archive" );
- return false;
+ for (int i = 0; i <artifactNames.length; i++) {
+ String artifactName = artifactNames[i]
+ if (!contents.contains(artifactName)) {
+ System.err.println("Artifact[" + artifactName + "] not found in
jar archive")
+ return false
}
}
-
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-30-fullcontent/verify.groovy
b/src/it/MJAR-30-fullcontent/verify.groovy
index 89ad38d..0cd9103 100644
--- a/src/it/MJAR-30-fullcontent/verify.groovy
+++ b/src/it/MJAR-30-fullcontent/verify.groovy
@@ -18,67 +18,60 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-30-01-99.0.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-30-01-99.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- String[] artifactNames = [ "default-configuration.properties",
- "foo/project001/App.class", "META-INF/MANIFEST.MF",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-01/pom.properties",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-01/pom.xml"
];
+ String[] artifactNames = [
+ "default-configuration.properties",
+ "foo/project001/App.class",
+ "META-INF/MANIFEST.MF",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-01/pom.properties",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-01/pom.xml"
+ ]
- Set contents = new HashSet();
+ Set contents = new HashSet()
- JarFile jar = new JarFile( artifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ JarFile jar = new JarFile(artifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- contents.add( entry.getName() );
+ contents.add(entry.getName())
}
}
- if ( artifactNames.length != contents.size() )
- {
- System.err.println( "jar content size is different from the expected
content size" );
- return false;
+ if (artifactNames.length != contents.size()) {
+ System.err.println("jar content size is different from the expected
content size")
+ return false
}
- for ( int i = 0; i < artifactNames.length; i++ )
- {
- String artifactName = artifactNames[i];
- if ( !contents.contains( artifactName ) )
- {
- System.err.println( "Artifact[" + artifactName + "] not found
in jar archive" );
- return false;
+ for (int i = 0; i <artifactNames.length; i++) {
+ String artifactName = artifactNames[i]
+ if (!contents.contains(artifactName)) {
+ System.err.println("Artifact[" + artifactName + "] not found in
jar archive")
+ return false
}
}
-
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-30-include/verify.groovy
b/src/it/MJAR-30-include/verify.groovy
index 1b0b838..c95d93a 100644
--- a/src/it/MJAR-30-include/verify.groovy
+++ b/src/it/MJAR-30-include/verify.groovy
@@ -18,66 +18,59 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-30-02-99.0.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-30-02-99.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- String[] artifactNames = [ "service/TestInterface.class",
"META-INF/MANIFEST.MF",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-02/pom.properties",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-02/pom.xml"
];
+ String[] artifactNames = [
+ "service/TestInterface.class",
+ "META-INF/MANIFEST.MF",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-02/pom.properties",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-30-02/pom.xml"
+ ]
- Set contents = new HashSet();
+ Set contents = new HashSet()
- JarFile jar = new JarFile( artifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ JarFile jar = new JarFile(artifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- contents.add( entry.getName() );
+ contents.add(entry.getName())
}
}
- if ( artifactNames.length != contents.size() )
- {
- System.err.println( "jar content size is different from the expected
content size" );
- return false;
+ if (artifactNames.length != contents.size()) {
+ System.err.println("jar content size is different from the expected
content size")
+ return false
}
- for ( int i = 0; i < artifactNames.length; i++ )
- {
- String artifactName = artifactNames[i];
- if ( !contents.contains( artifactName ) )
- {
- System.err.println( "Artifact[" + artifactName + "] not found
in jar archive" );
- return false;
+ for (int i = 0; i <artifactNames.length; i++) {
+ String artifactName = artifactNames[i]
+ if (!contents.contains(artifactName)) {
+ System.err.println("Artifact[" + artifactName + "] not found in
jar archive")
+ return false
}
}
-
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-510/verify.groovy b/src/it/MJAR-510/verify.groovy
index b6b63e2..58b9341 100644
--- a/src/it/MJAR-510/verify.groovy
+++ b/src/it/MJAR-510/verify.groovy
@@ -18,28 +18,24 @@
* under the License.
*/
-import java.io.*;
+import java.io.*
-try
-{
- File target = new File( basedir, "target" );
- File artifact = new File( target, "maven-jar-plugin-test-mjar-510-1.0.jar"
);
- if ( !artifact.exists() )
- {
- System.err.println( "main artifact is missing." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ File artifact = new File(target, "maven-jar-plugin-test-mjar-510-1.0.jar")
+ if (!artifact.exists()) {
+ System.err.println("main artifact is missing.")
+ return false
}
- File junitArtifact = new File( target,
"maven-jar-plugin-test-mjar-510-1.0-junit.jar" );
- if ( junitArtifact.exists() )
- {
- System.err.println( "junit classifier jar should not exist when
includes match no files." );
- return false;
+ File junitArtifact = new File(target,
"maven-jar-plugin-test-mjar-510-1.0-junit.jar")
+ if (junitArtifact.exists()) {
+ System.err.println("junit classifier jar should not exist when
includes match no files.")
+ return false
}
- return true;
+ return true
}
-catch( Throwable e )
-{
- e.printStackTrace();
+catch(Throwable e) {
+ e.printStackTrace()
}
-return false;
+return false
diff --git a/src/it/MJAR-539-build-environment-entries/verify.groovy
b/src/it/MJAR-539-build-environment-entries/verify.groovy
index 9b0af48..a529520 100644
--- a/src/it/MJAR-539-build-environment-entries/verify.groovy
+++ b/src/it/MJAR-539-build-environment-entries/verify.groovy
@@ -17,24 +17,24 @@
* under the License.
*/
-import java.util.jar.*;
+import java.util.jar.*
-File target = new File( basedir, "target" );
+File target = new File(basedir, "target")
assert target.exists()
assert target.isDirectory()
-File artifact = new File( target,
"mjar-539-build-environment-entries-1.0-SNAPSHOT.jar" );
+File artifact = new File(target,
"mjar-539-build-environment-entries-1.0-SNAPSHOT.jar")
assert artifact.exists()
assert artifact.isFile()
-JarFile jar = new JarFile( artifact );
-Attributes manifest = jar.getManifest().getMainAttributes();
+JarFile jar = new JarFile(artifact)
+Attributes manifest = jar.getManifest().getMainAttributes()
-assert "myproject.HelloWorld".equals( manifest.get( Attributes.Name.MAIN_CLASS
) )
-assert manifest.getValue( "Build-Jdk-Spec" ) == null
-assert manifest.getValue( "Build-Tool" ) == null
-assert manifest.getValue( "Build-Jdk" ) == null
-assert manifest.getValue( "Build-Os" ) == null
-assert manifest.getValue( "Build-Tool-Jdk-Spec" ) == null
+assert "myproject.HelloWorld".equals(manifest.get(Attributes.Name.MAIN_CLASS))
+assert manifest.getValue("Build-Jdk-Spec") == null
+assert manifest.getValue("Build-Tool") == null
+assert manifest.getValue("Build-Jdk") == null
+assert manifest.getValue("Build-Os") == null
+assert manifest.getValue("Build-Tool-Jdk-Spec") == null
-jar.close();
+jar.close()
diff --git a/src/it/MJAR-557-detect-mjar/verify.groovy
b/src/it/MJAR-557-detect-mjar/verify.groovy
index 596c7d9..b1292f8 100644
--- a/src/it/MJAR-557-detect-mjar/verify.groovy
+++ b/src/it/MJAR-557-detect-mjar/verify.groovy
@@ -26,5 +26,5 @@ assert jarFile.isFile()
new JarFile(jarFile).withCloseable { mrjar ->
def manifest = mrjar.manifest.mainAttributes
assert manifest.getValue(Attributes.Name.MULTI_RELEASE) == "true",
- "Expected Multi-Release: true but got: " +
manifest.getValue(Attributes.Name.MULTI_RELEASE)
+ "Expected Multi-Release: true but got: " +
manifest.getValue(Attributes.Name.MULTI_RELEASE)
}
diff --git a/src/it/MJAR-596-sanitize-automatic-module-name/verify.groovy
b/src/it/MJAR-596-sanitize-automatic-module-name/verify.groovy
index bd76e1a..3339a5e 100644
--- a/src/it/MJAR-596-sanitize-automatic-module-name/verify.groovy
+++ b/src/it/MJAR-596-sanitize-automatic-module-name/verify.groovy
@@ -17,7 +17,7 @@
* under the License.
*/
-import java.util.jar.*;
+import java.util.jar.*
/*
* MJAR-596: An invalid Automatic-Module-Name read from a MANIFEST.MF file
(not from POM
@@ -32,19 +32,19 @@ import java.util.jar.*;
*/
// 1. Build must succeed: target directory and artifact must exist.
-File artifact = new File( basedir,
"target/mjar596-integration-test-1.0-SNAPSHOT.jar" );
-assert artifact.isFile() : "artifact JAR is missing: " + artifact;
+File artifact = new File(basedir,
"target/mjar596-integration-test-1.0-SNAPSHOT.jar")
+assert artifact.isFile() : "artifact JAR is missing: " + artifact
// 2. The manifest inside the JAR must carry the sanitized name.
-String expected = "org.apache.maven.plugins.mjar596.integration.test";
-JarFile jar = new JarFile( artifact );
-String moduleName = jar.getManifest().getMainAttributes().getValue(
"Automatic-Module-Name" );
-jar.close();
-assert expected == moduleName : "Expected Automatic-Module-Name \"" + expected
+ "\" but got: " + moduleName;
+String expected = "org.apache.maven.plugins.mjar596.integration.test"
+JarFile jar = new JarFile( artifact )
+String moduleName = jar.getManifest().getMainAttributes().getValue(
"Automatic-Module-Name" )
+jar.close()
+assert expected == moduleName : "Expected Automatic-Module-Name \"" + expected
+ "\" but got: " + moduleName
// 3. A warning about the sanitization must appear in the build log.
-String log = new File( basedir, "build.log" ).getText( "UTF-8" );
-assert log.contains( "BUILD SUCCESS" )
: "BUILD SUCCESS not found in build.log";
-assert log.contains( "[WARNING]" )
: "[WARNING] not found in build.log";
-assert log.contains( "org.apache.maven.plugins.mjar596-integration-test" ) :
"original name not found in build.log";
-assert log.contains( expected )
: "sanitized name not found in build.log";
+String log = new File( basedir, "build.log" ).getText( "UTF-8" )
+assert log.contains( "BUILD SUCCESS" )
: "BUILD SUCCESS not found in build.log"
+assert log.contains( "[WARNING]" )
: "[WARNING] not found in build.log"
+assert log.contains( "org.apache.maven.plugins.mjar596-integration-test" ) :
"original name not found in build.log"
+assert log.contains( expected )
: "sanitized name not found in build.log"
diff --git a/src/it/MJAR-60/verify.groovy b/src/it/MJAR-60/verify.groovy
index 76f19fe..46dc5b0 100644
--- a/src/it/MJAR-60/verify.groovy
+++ b/src/it/MJAR-60/verify.groovy
@@ -18,59 +18,49 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import org.apache.commons.io.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
+import org.apache.commons.io.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target, "MJAR-60-1.0-SNAPSHOT.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target, "MJAR-60-1.0-SNAPSHOT.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- JarFile jar = new JarFile( artifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ JarFile jar = new JarFile(artifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- if ( entry.getName().equals( "META-INF/MANIFEST.MF" ) )
- {
- String manifest = IOUtils.toString( jar.getInputStream ( entry
) );
- int index = manifest.indexOf( "Class-Path: config/" );
- if ( index <= 0 )
- {
- System.err.println( "MANIFEST doesn't contain:
Class-Path: config/" );
- return false;
- }
- return true;
+ if (entry.getName().equals("META-INF/MANIFEST.MF")) {
+ String manifest = IOUtils.toString(jar.getInputStream(entry))
+ int index = manifest.indexOf("Class-Path: config/")
+ if (index <= 0) {
+ System.err.println("MANIFEST doesn't contain: Class-Path:
config/")
+ return false
+ }
+ return true
}
}
}
- System.err.println( "MANIFEST.MF not found" );
- return false;
-
-
+ System.err.println("MANIFEST.MF not found")
+ return false
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-70-no-recreation/verify.groovy
b/src/it/MJAR-70-no-recreation/verify.groovy
index 61f4177..fe3cad1 100644
--- a/src/it/MJAR-70-no-recreation/verify.groovy
+++ b/src/it/MJAR-70-no-recreation/verify.groovy
@@ -18,34 +18,30 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
+import java.io.*
+import java.util.*
-File target = new File( basedir, "target" );
-if ( !target.isDirectory() )
-{
- throw new IOException( "target file is missing or not a directory: " +
target );
+File target = new File(basedir, "target")
+if (!target.isDirectory()) {
+ throw new IOException("target file is missing or not a directory: " +
target)
}
-File jarFile = new File( target, "MJAR-70-no-recreation-1.0-SNAPSHOT.jar" );
-if ( !jarFile.isFile() )
-{
- throw new IOException( "artifact file is missing or a directory: " +
jarFile );
+File jarFile = new File(target, "MJAR-70-no-recreation-1.0-SNAPSHOT.jar")
+if (!jarFile.isFile()) {
+ throw new IOException("artifact file is missing or a directory: " +
jarFile)
}
-File refFile = new File( target, "reference.jar" );
-if ( !refFile.isFile() )
-{
- throw new IOException( "reference file is missing or a directory: " +
refFile );
+File refFile = new File(target, "reference.jar")
+if (!refFile.isFile()) {
+ throw new IOException("reference file is missing or a directory: " +
refFile)
}
-long referenceTimestamp = refFile.lastModified();
+long referenceTimestamp = refFile.lastModified()
-long actualTimestamp = jarFile.lastModified();
+long actualTimestamp = jarFile.lastModified()
-if ( referenceTimestamp != actualTimestamp)
-{
- throw new Exception( "Timestamps don't match, JAR was recreated although
contents has not changed" );
+if (referenceTimestamp != actualTimestamp) {
+ throw new Exception("Timestamps don't match, JAR was recreated although
contents has not changed")
}
-return true;
+return true
diff --git a/src/it/MJAR-70-recreation/verify.groovy
b/src/it/MJAR-70-recreation/verify.groovy
index f9cead6..37a2105 100644
--- a/src/it/MJAR-70-recreation/verify.groovy
+++ b/src/it/MJAR-70-recreation/verify.groovy
@@ -18,48 +18,45 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-File target = new File( basedir, "target" );
-if ( !target.isDirectory() )
-{
- throw new IOException( "target file is missing or not a directory: " +
target );
+File target = new File(basedir, "target")
+if (!target.isDirectory()) {
+ throw new IOException("target file is missing or not a directory: " +
target)
}
-File jarFile = new File( target, "MJAR-70-recreation-1.0-SNAPSHOT.jar" );
-if ( !jarFile.isFile() )
-{
- throw new IOException( "artifact file is missing or a directory: " +
jarFile );
+File jarFile = new File(target, "MJAR-70-recreation-1.0-SNAPSHOT.jar")
+if (!jarFile.isFile()) {
+ throw new IOException("artifact file is missing or a directory: " +
jarFile)
}
-File refFile = new File( target, "reference.jar" );
-if ( !refFile.isFile() )
-{
- throw new IOException( "reference file is missing or a directory: " +
refFile );
+File refFile = new File(target, "reference.jar")
+if (!refFile.isFile()) {
+ throw new IOException("reference file is missing or a directory: " +
refFile)
}
// Read the build log to verify that the JAR plugin actually executed
-File buildLog = new File( basedir, "build.log" );
-String buildLogContent = "";
-if ( buildLog.exists() ) {
- BufferedReader reader = new BufferedReader( new FileReader( buildLog ) );
- StringBuilder sb = new StringBuilder();
- String line;
- while ( ( line = reader.readLine() ) != null ) {
- sb.append( line ).append( "\n" );
+File buildLog = new File(basedir, "build.log")
+String buildLogContent = ""
+if (buildLog.exists()) {
+ BufferedReader reader = new BufferedReader(new FileReader(buildLog))
+ StringBuilder sb = new StringBuilder()
+ String line
+ while ((line = reader.readLine()) != null) {
+ sb.append(line).append("\n")
}
- reader.close();
- buildLogContent = sb.toString();
+ reader.close()
+ buildLogContent = sb.toString()
}
// Count how many times the JAR plugin executed
-int jarPluginExecutions = 0;
-String[] lines = buildLogContent.split( "\n" );
-for ( String line : lines ) {
- if ( line.contains( "Building JAR:" ) && line.contains(
"MJAR-70-recreation-1.0-SNAPSHOT.jar" ) ) {
- jarPluginExecutions++;
+int jarPluginExecutions = 0
+String[] lines = buildLogContent.split("\n")
+for (String line : lines) {
+ if (line.contains("Building JAR:") &&
line.contains("MJAR-70-recreation-1.0-SNAPSHOT.jar")) {
+ jarPluginExecutions++
}
}
@@ -67,19 +64,19 @@ for ( String line : lines ) {
// With forceCreation=true, the JAR should be built twice:
// 1. During the first package phase
// 2. During the second package phase (even though nothing changed)
-if ( jarPluginExecutions < 2 ) {
- throw new Exception( "Expected at least 2 JAR plugin executions with
forceCreation=true, but found: " + jarPluginExecutions );
+if (jarPluginExecutions < 2) {
+ throw new Exception("Expected at least 2 JAR plugin executions with
forceCreation=true, but found: " + jarPluginExecutions)
}
// Also check file timestamps as additional verification
-long referenceTimestamp = refFile.lastModified();
-long actualTimestamp = jarFile.lastModified();
+long referenceTimestamp = refFile.lastModified()
+long actualTimestamp = jarFile.lastModified()
// With forceCreation=true, the second build should create a new JAR file
// even if the content is identical, so the timestamp should be different
-if ( referenceTimestamp >= actualTimestamp ) {
+if (referenceTimestamp >= actualTimestamp) {
// This might fail with reproducible builds, so let's make it a warning
instead of an error
}
-return true;
+return true
diff --git a/src/it/MJAR-80-exclude/verify.groovy
b/src/it/MJAR-80-exclude/verify.groovy
index 8d72e1b..61dc47f 100644
--- a/src/it/MJAR-80-exclude/verify.groovy
+++ b/src/it/MJAR-80-exclude/verify.groovy
@@ -18,74 +18,67 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-80-03-99.0.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-80-03-99.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- File testArtifact = new File( target,
"maven-jar-plugin-test-mjar-80-03-99.0-tests.jar" );
- if ( !testArtifact.exists() || testArtifact.isDirectory() )
- {
- System.err.println( "testArtifact file is missing or a directory." );
- return false;
+ File testArtifact = new File(target,
"maven-jar-plugin-test-mjar-80-03-99.0-tests.jar")
+ if (!testArtifact.exists() || testArtifact.isDirectory()) {
+ System.err.println("testArtifact file is missing or a directory.")
+ return false
}
- String[] artifactNames = [ "test-default-configuration.properties",
- "foo/project003/AppTest.class",
"foo/project003/AppIntegrationTest.class", "META-INF/MANIFEST.MF",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-03/pom.properties",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-03/pom.xml"
];
+ String[] artifactNames = [
+ "test-default-configuration.properties",
+ "foo/project003/AppTest.class",
+ "foo/project003/AppIntegrationTest.class",
+ "META-INF/MANIFEST.MF",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-03/pom.properties",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-03/pom.xml"
+ ]
- Set contents = new HashSet();
+ Set contents = new HashSet()
- JarFile jar = new JarFile( testArtifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ JarFile jar = new JarFile(testArtifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- contents.add( entry.getName() );
+ contents.add(entry.getName())
}
}
- if ( artifactNames.length != contents.size() )
- {
- System.err.println( "jar content size is different from the expected
content size" );
- return false;
+ if (artifactNames.length != contents.size()) {
+ System.err.println("jar content size is different from the expected
content size")
+ return false
}
- for ( int i = 0; i < artifactNames.length; i++ )
- {
- String artifactName = artifactNames[i];
- if ( !contents.contains( artifactName ) )
- {
- System.err.println( "Artifact[" + artifactName + "] not found
in jar archive" );
- return false;
+ for (int i = 0; i <artifactNames.length; i++) {
+ String artifactName = artifactNames[i]
+ if (!contents.contains(artifactName)) {
+ System.err.println("Artifact[" + artifactName + "] not found in
jar archive")
+ return false
}
}
-
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-80-fullcontent/verify.groovy
b/src/it/MJAR-80-fullcontent/verify.groovy
index 47523b5..1f1d99f 100644
--- a/src/it/MJAR-80-fullcontent/verify.groovy
+++ b/src/it/MJAR-80-fullcontent/verify.groovy
@@ -18,74 +18,67 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-80-01-99.0.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-80-01-99.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- File testArtifact = new File( target,
"maven-jar-plugin-test-mjar-80-01-99.0-tests.jar" );
- if ( !testArtifact.exists() || testArtifact.isDirectory() )
- {
- System.err.println( "testArtifact file is missing or a directory." );
- return false;
+ File testArtifact = new File(target,
"maven-jar-plugin-test-mjar-80-01-99.0-tests.jar")
+ if (!testArtifact.exists() || testArtifact.isDirectory()) {
+ System.err.println("testArtifact file is missing or a directory.")
+ return false
}
- String[] artifactNames = [ "test-default-configuration.properties",
- "foo/project003/AppTest.class",
"foo/project003/AppIntegrationTest.class", "META-INF/MANIFEST.MF",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-01/pom.properties",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-01/pom.xml"
];
+ String[] artifactNames = [
+ "test-default-configuration.properties",
+ "foo/project003/AppTest.class",
+ "foo/project003/AppIntegrationTest.class",
+ "META-INF/MANIFEST.MF",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-01/pom.properties",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-01/pom.xml"
+ ]
- Set contents = new HashSet();
+ Set contents = new HashSet()
- JarFile jar = new JarFile( testArtifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ JarFile jar = new JarFile(testArtifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- contents.add( entry.getName() );
+ contents.add(entry.getName())
}
}
- if ( artifactNames.length != contents.size() )
- {
- System.err.println( "jar content size is different from the expected
content size" );
- return false;
+ if (artifactNames.length != contents.size()) {
+ System.err.println("jar content size is different from the expected
content size")
+ return false
}
- for ( int i = 0; i < artifactNames.length; i++ )
- {
- String artifactName = artifactNames[i];
- if ( !contents.contains( artifactName ) )
- {
- System.err.println( "Artifact[" + artifactName + "] not found
in jar archive" );
- return false;
+ for (int i = 0; i <artifactNames.length; i++) {
+ String artifactName = artifactNames[i]
+ if (!contents.contains(artifactName)) {
+ System.err.println("Artifact[" + artifactName + "] not found in
jar archive")
+ return false
}
}
-
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-80-include/verify.groovy
b/src/it/MJAR-80-include/verify.groovy
index 09294a5..9a04c01 100644
--- a/src/it/MJAR-80-include/verify.groovy
+++ b/src/it/MJAR-80-include/verify.groovy
@@ -18,74 +18,65 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-80-02-99.0.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-80-02-99.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- File testArtifact = new File( target,
"maven-jar-plugin-test-mjar-80-02-99.0-tests.jar" );
- if ( !testArtifact.exists() || testArtifact.isDirectory() )
- {
- System.err.println( "testArtifact file is missing or a directory." );
- return false;
+ File testArtifact = new File(target,
"maven-jar-plugin-test-mjar-80-02-99.0-tests.jar")
+ if (!testArtifact.exists() || testArtifact.isDirectory()) {
+ System.err.println("testArtifact file is missing or a directory.")
+ return false
}
- String[] artifactNames = [ "foo/project003/AppIntegrationTest.class",
- "META-INF/MANIFEST.MF",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-02/pom.properties",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-02/pom.xml"
];
+ String[] artifactNames = [
+ "foo/project003/AppIntegrationTest.class",
+ "META-INF/MANIFEST.MF",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-02/pom.properties",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-mjar-80-02/pom.xml"
+ ]
- Set contents = new HashSet();
+ Set contents = new HashSet()
- JarFile jar = new JarFile( testArtifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ JarFile jar = new JarFile(testArtifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- contents.add( entry.getName() );
+ contents.add(entry.getName())
}
}
- if ( artifactNames.length != contents.size() )
- {
- System.err.println( "jar content size is different from the expected
content size" );
- return false;
+ if (artifactNames.length != contents.size()) {
+ System.err.println("jar content size is different from the expected
content size")
+ return false
}
- for ( int i = 0; i < artifactNames.length; i++ )
- {
- String artifactName = artifactNames[i];
- if ( !contents.contains( artifactName ) )
- {
- System.err.println( "Artifact[" + artifactName + "] not found
in jar archive" );
- return false;
+ for (int i = 0; i <artifactNames.length; i++) {
+ String artifactName = artifactNames[i]
+ if (!contents.contains(artifactName)) {
+ System.err.println("Artifact[" + artifactName + "] not found in
jar archive")
+ return false
}
}
-
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MJAR-82/verify.groovy b/src/it/MJAR-82/verify.groovy
index 6a4e2ca..e0032d5 100644
--- a/src/it/MJAR-82/verify.groovy
+++ b/src/it/MJAR-82/verify.groovy
@@ -18,55 +18,49 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import org.codehaus.plexus.util.cli.*;
-import org.codehaus.plexus.util.FileUtils;
+import java.io.*
+import java.util.*
+import java.util.jar.*
+import org.codehaus.plexus.util.cli.*
+import org.codehaus.plexus.util.FileUtils
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target, "MJAR-82-1.0-SNAPSHOT.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target, "MJAR-82-1.0-SNAPSHOT.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- String localRepoPath =
basedir.getParentFile().getParentFile().getParentFile().getPath() +
"/target/local-repo";
- FileUtils.copyFile( artifact, new File( localRepoPath,
"MJAR-82-1.0-SNAPSHOT.jar" ) );
- Commandline commandline = new Commandline();
- commandline.setExecutable( "java" );
- commandline.setWorkingDirectory( localRepoPath );
- commandline.createArg().setLine( "-jar MJAR-82-1.0-SNAPSHOT.jar" );
- CommandLineUtils.StringStreamConsumer consumer = new
CommandLineUtils.StringStreamConsumer();
- int res = CommandLineUtils.executeCommandLine( commandline, consumer,
consumer );
- String output = consumer.getOutput();
- if ( res != 0 )
- {
- System.err.println( "commandline execution return code != 0 " + res );
- return false;
+ String localRepoPath =
basedir.getParentFile().getParentFile().getParentFile().getPath() +
"/target/local-repo"
+ FileUtils.copyFile(artifact, new File(localRepoPath,
"MJAR-82-1.0-SNAPSHOT.jar"))
+ Commandline commandline = new Commandline()
+ commandline.setExecutable("java")
+ commandline.setWorkingDirectory(localRepoPath)
+ commandline.createArg().setLine("-jar MJAR-82-1.0-SNAPSHOT.jar")
+ CommandLineUtils.StringStreamConsumer consumer = new
CommandLineUtils.StringStreamConsumer()
+ int res = CommandLineUtils.executeCommandLine(commandline, consumer,
consumer)
+ String output = consumer.getOutput()
+ if (res != 0) {
+ System.err.println("commandline execution return code != 0 " + res)
+ return false
}
- if ( output.indexOf("great it works") < 0 )
- {
- System.err.println( "output not contains great it works" );
- return false;
+ if (output.indexOf("great it works") < 0) {
+ System.err.println("output not contains great it works")
+ return false
}
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/MNG-8137-warn-pom-packaging/verify.groovy
b/src/it/MNG-8137-warn-pom-packaging/verify.groovy
index 9ee0043..dcbb925 100644
--- a/src/it/MNG-8137-warn-pom-packaging/verify.groovy
+++ b/src/it/MNG-8137-warn-pom-packaging/verify.groovy
@@ -17,7 +17,7 @@
* under the License.
*/
-import java.nio.file.*;
+import java.nio.file.*
// No JAR should be created.
File jar = new File(basedir, "target/maven-jar-plugin-test-mng-8137-1.0.jar")
diff --git a/src/it/directory-entries-mr/verify.groovy
b/src/it/directory-entries-mr/verify.groovy
index e1aec4e..3b5db39 100644
--- a/src/it/directory-entries-mr/verify.groovy
+++ b/src/it/directory-entries-mr/verify.groovy
@@ -27,7 +27,7 @@ JarFile jar = new JarFile(artifact)
try {
// Sanity: this must really be a multi-release JAR.
assert jar.manifest.mainAttributes.getValue(Attributes.Name.MULTI_RELEASE)
== "true" :
- "Expected Multi-Release: true in the manifest"
+ "Expected Multi-Release: true in the manifest"
// Regression guard for maven-jar-plugin #508, extended to non-modular
multi-release JARs.
// if the JAR is built by enumerating individual files, the intermediate
directory entries
diff --git a/src/it/directory-entries/verify.groovy
b/src/it/directory-entries/verify.groovy
index ccab2aa..ea3be65 100644
--- a/src/it/directory-entries/verify.groovy
+++ b/src/it/directory-entries/verify.groovy
@@ -29,11 +29,7 @@ try {
// can not be specified (if they were, they would be traversed), which
breaks consumers
// relying on JAR directory traversal (e.g. Spring Boot @ComponentScan).
// Assert that the directory entries are present.
- def requiredDirectoryEntries = [
- "com/",
- "com/acme/",
- "com/acme/sub/"
- ]
+ def requiredDirectoryEntries = ["com/", "com/acme/", "com/acme/sub/"]
for (String name : requiredDirectoryEntries) {
def entry = jar.getEntry(name)
assert entry != null : "Missing directory entry: " + name
@@ -41,10 +37,7 @@ try {
}
// The class files must of course still be present.
- def requiredFileEntries = [
- "com/acme/App.class",
- "com/acme/sub/Helper.class"
- ]
+ def requiredFileEntries = ["com/acme/App.class",
"com/acme/sub/Helper.class"]
for (String name : requiredFileEntries) {
def entry = jar.getEntry(name)
assert entry != null : "Missing class entry: " + name
diff --git a/src/it/manifest-content/verify.groovy
b/src/it/manifest-content/verify.groovy
index 284149f..bc83427 100644
--- a/src/it/manifest-content/verify.groovy
+++ b/src/it/manifest-content/verify.groovy
@@ -18,101 +18,87 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.zip.*;
-
-boolean result = true;
-
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+import java.io.*
+import java.util.*
+import java.util.jar.*
+import java.util.zip.*
+
+boolean result = true
+
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target, "manifest-content-1.0-SNAPSHOT.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target, "manifest-content-1.0-SNAPSHOT.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- ZipFile zip = new ZipFile( artifact );
- Enumeration resultingEntries = zip.entries();
- if ( !"META-INF/".equals( resultingEntries.nextElement().getName() ) )
- {
- System.err.println( "META-INF/ must be first zip entry" );
- return false;
+ ZipFile zip = new ZipFile(artifact)
+ Enumeration resultingEntries = zip.entries()
+ if (!"META-INF/".equals(resultingEntries.nextElement().getName())) {
+ System.err.println("META-INF/ must be first zip entry")
+ return false
}
- if ( !"META-INF/MANIFEST.MF".equals(
resultingEntries.nextElement().getName() ) )
- {
- System.err.println( "META-INF/MANIFEST.MF must be second zip entry" );
- return false;
+ if
(!"META-INF/MANIFEST.MF".equals(resultingEntries.nextElement().getName())) {
+ System.err.println("META-INF/MANIFEST.MF must be second zip entry")
+ return false
}
- zip.close();
+ zip.close()
- JarFile jar = new JarFile( artifact );
+ JarFile jar = new JarFile(artifact)
- Attributes manifest = jar.getManifest().getMainAttributes();
+ Attributes manifest = jar.getManifest().getMainAttributes()
- if ( !"manifest-content-it".equals( manifest.get(
Attributes.Name.SPECIFICATION_TITLE ) ) )
- {
- System.err.println( Attributes.Name.SPECIFICATION_TITLE.toString() + "
not equals manifest-content-it" );
- return false;
+ if
(!"manifest-content-it".equals(manifest.get(Attributes.Name.SPECIFICATION_TITLE)))
{
+ System.err.println(Attributes.Name.SPECIFICATION_TITLE.toString() + "
not equals manifest-content-it")
+ return false
}
//
https://docs.oracle.com/javase/6/docs/technotes/guides/versioning/spec/versioning2.html
// Based on the above this must be "1.0" and NOT "1.0-SNAPSHOT"
- if ( !"1.0".equals( manifest.get( Attributes.Name.SPECIFICATION_VERSION )
) )
- {
- System.err.println( Attributes.Name.SPECIFICATION_VERSION.toString() +
" not equals 1.0" );
- return false;
+ if (!"1.0".equals(manifest.get(Attributes.Name.SPECIFICATION_VERSION))) {
+ System.err.println(Attributes.Name.SPECIFICATION_VERSION.toString() +
" not equals 1.0")
+ return false
}
- if ( !"jar plugin it".equals( manifest.get(
Attributes.Name.SPECIFICATION_VENDOR ) ) )
- {
- System.err.println( Attributes.Name.SPECIFICATION_VENDOR.toString() +
" not equals jar plugin it" );
- return false;
+ if (!"jar plugin
it".equals(manifest.get(Attributes.Name.SPECIFICATION_VENDOR))) {
+ System.err.println(Attributes.Name.SPECIFICATION_VENDOR.toString() + "
not equals jar plugin it")
+ return false
}
- if ( !"manifest-content-it".equals( manifest.get(
Attributes.Name.IMPLEMENTATION_TITLE ) ) )
- {
- System.err.println( Attributes.Name.IMPLEMENTATION_TITLE.toString() +
" not equals manifest-content-it" );
- return false;
+ if
(!"manifest-content-it".equals(manifest.get(Attributes.Name.IMPLEMENTATION_TITLE)))
{
+ System.err.println(Attributes.Name.IMPLEMENTATION_TITLE.toString() + "
not equals manifest-content-it")
+ return false
}
- if ( !"1.0-SNAPSHOT".equals( manifest.get(
Attributes.Name.IMPLEMENTATION_VERSION ) ) )
- {
- System.err.println( Attributes.Name.SPECIFICATION_VERSION.toString() +
" not equals 1.0-SNAPSHOT" );
- return false;
+ if
(!"1.0-SNAPSHOT".equals(manifest.get(Attributes.Name.IMPLEMENTATION_VERSION))) {
+ System.err.println(Attributes.Name.SPECIFICATION_VERSION.toString() +
" not equals 1.0-SNAPSHOT")
+ return false
}
- if ( !"jar plugin it".equals( manifest.get(
Attributes.Name.IMPLEMENTATION_VENDOR ) ) )
- {
- System.err.println( Attributes.Name.IMPLEMENTATION_VENDOR.toString() +
" not equals jar plugin it" );
- return false;
+ if (!"jar plugin
it".equals(manifest.get(Attributes.Name.IMPLEMENTATION_VENDOR))) {
+ System.err.println(Attributes.Name.IMPLEMENTATION_VENDOR.toString() +
" not equals jar plugin it")
+ return false
}
- if ( !"myproject.HelloWorld".equals( manifest.get(
Attributes.Name.MAIN_CLASS ) ) )
- {
- System.err.println( Attributes.Name.MAIN_CLASS.toString() + " not
equals myproject.HelloWorld" );
- return false;
+ if
(!"myproject.HelloWorld".equals(manifest.get(Attributes.Name.MAIN_CLASS))) {
+ System.err.println(Attributes.Name.MAIN_CLASS.toString() + " not
equals myproject.HelloWorld")
+ return false
}
- if ( !"11".equals( manifest.getValue( "Java-Version" ) ) )
- {
- System.err.println( "Java-Version not equals 11" );
- return false;
+ if (!"11".equals(manifest.getValue("Java-Version"))) {
+ System.err.println("Java-Version not equals 11")
+ return false
}
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/manifest-created-by/verify.groovy
b/src/it/manifest-created-by/verify.groovy
index f13f6b4..474a64b 100644
--- a/src/it/manifest-created-by/verify.groovy
+++ b/src/it/manifest-created-by/verify.groovy
@@ -17,7 +17,7 @@
* under the License.
*/
-import java.util.jar.*;
+import java.util.jar.*
/*
* The project sets addDefaultEntries=false, so Maven archiver writes no
Created-By. Without the fix the
diff --git a/src/it/mjar-138/verify.groovy b/src/it/mjar-138/verify.groovy
index 5c3bda2..54964c9 100644
--- a/src/it/mjar-138/verify.groovy
+++ b/src/it/mjar-138/verify.groovy
@@ -22,9 +22,9 @@
// resolve it as a reactor artifact and compile its test sources against it.
// 1. The model test-jar must have been produced despite -DskipTests.
-File testJar = new File(basedir, "model/target/model-1.0-SNAPSHOT-tests.jar");
+File testJar = new File(basedir, "model/target/model-1.0-SNAPSHOT-tests.jar")
assert testJar.isFile(), "MJAR-138: model test-jar is missing: " + testJar
// 2. The client's test classes must have compiled (they depend on
TestComponent from the test-jar).
-File clientTestClasses = new File(basedir,
"client/target/test-classes/org/apache/maven/its/mjar138/ClientTest.class");
+File clientTestClasses = new File(basedir,
"client/target/test-classes/org/apache/maven/its/mjar138/ClientTest.class")
assert clientTestClasses.isFile(), "MJAR-138: client test classes not compiled
(test-jar was not available in reactor): " + clientTestClasses
diff --git a/src/it/mjar-139/verify.groovy b/src/it/mjar-139/verify.groovy
index 8d5555b..b2681f4 100644
--- a/src/it/mjar-139/verify.groovy
+++ b/src/it/mjar-139/verify.groovy
@@ -18,33 +18,29 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target,
"maven-jar-plugin-test-mjar-139-1.0-tests.jar" );
- if ( artifact.exists() )
- {
- System.err.println( "test artifact should not exist." );
- return false;
+ File artifact = new File(target,
"maven-jar-plugin-test-mjar-139-1.0-tests.jar")
+ if (artifact.exists()) {
+ System.err.println("test artifact should not exist.")
+ return false
}
- return true;
+ return true
}
-catch( Throwable e )
-{
- e.printStackTrace();
- return false;
+catch(Throwable e) {
+ e.printStackTrace()
+ return false
}
-return false;
+return false
diff --git a/src/it/mjar-71-01/verify.groovy b/src/it/mjar-71-01/verify.groovy
index 60faf65..80cd78b 100644
--- a/src/it/mjar-71-01/verify.groovy
+++ b/src/it/mjar-71-01/verify.groovy
@@ -18,57 +18,49 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import org.apache.commons.io.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
+import org.apache.commons.io.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target, "mjar-71-1.0.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file " + file + " is missing or a
directory." );
- return false;
+ File artifact = new File(target, "mjar-71-1.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file " + file + " is missing or a
directory.")
+ return false
}
- JarFile jar = new JarFile( artifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ JarFile jar = new JarFile(artifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- if ( entry.getName().equals( "META-INF/MANIFEST.MF" ) )
- {
- String manifest = IOUtils.toString( jar.getInputStream ( entry
) );
- int index = manifest.indexOf( "Archiver-Version:
foobar-1.23456" );
- if ( index <= 0 )
- {
- System.err.println( "MANIFEST doesn't contain:
'Archiver-Version: foobar-1.23456'" );
- return false;
+ if (entry.getName().equals("META-INF/MANIFEST.MF")) {
+ String manifest = IOUtils.toString(jar.getInputStream(entry))
+ int index = manifest.indexOf("Archiver-Version:
foobar-1.23456")
+ if (index <= 0) {
+ System.err.println("MANIFEST doesn't contain:
'Archiver-Version: foobar-1.23456'")
+ return false
}
- return true;
+ return true
}
}
}
- System.err.println( "MANIFEST.MF not found" );
- return false;
+ System.err.println("MANIFEST.MF not found")
+ return false
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/mjar-71-02/verify.groovy b/src/it/mjar-71-02/verify.groovy
index ffddfcb..1498f73 100644
--- a/src/it/mjar-71-02/verify.groovy
+++ b/src/it/mjar-71-02/verify.groovy
@@ -18,57 +18,49 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import org.apache.commons.io.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
+import org.apache.commons.io.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target, "mjar-71-02-1.0.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file " + file + " is missing or a
directory." );
- return false;
+ File artifact = new File(target, "mjar-71-02-1.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file " + file + " is missing or a
directory.")
+ return false
}
- JarFile jar = new JarFile( artifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ JarFile jar = new JarFile(artifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- if ( entry.getName().equals ( "META-INF/MANIFEST.MF" ) )
- {
- String manifest = IOUtils.toString( jar.getInputStream ( entry
) );
- int index = manifest.indexOf( "Archiver-Version:
foobar-1.23456" );
- if ( index <= 0 )
- {
- System.err.println( "MANIFEST doesn't contain:
'Archiver-Version: foobar-1.23456'" );
- return false;
+ if (entry.getName().equals("META-INF/MANIFEST.MF")) {
+ String manifest = IOUtils.toString(jar.getInputStream(entry))
+ int index = manifest.indexOf("Archiver-Version:
foobar-1.23456")
+ if (index <= 0) {
+ System.err.println("MANIFEST doesn't contain:
'Archiver-Version: foobar-1.23456'")
+ return false
}
- return true;
+ return true
}
}
}
- System.err.println( "MANIFEST.MF not found" );
- return false;
+ System.err.println("MANIFEST.MF not found")
+ return false
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/mjar-90/verify.groovy b/src/it/mjar-90/verify.groovy
index 7560e22..5221725 100644
--- a/src/it/mjar-90/verify.groovy
+++ b/src/it/mjar-90/verify.groovy
@@ -18,39 +18,34 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-boolean result = true;
+boolean result = true
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
}
- File artifact = new File( target, "maven-jar-plugin-test-mjar-90-99.0.jar"
);
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "artifact file is missing or a directory." );
- return false;
+ File artifact = new File(target, "maven-jar-plugin-test-mjar-90-99.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("artifact file is missing or a directory.")
+ return false
}
- File testArtifact = new File( target,
"maven-jar-plugin-test-mjar-90-99.0-tests.jar" );
- if ( testArtifact.exists() )
- {
- System.err.println( "testArtifact file has been created with
maven.Test.skip=true." );
- return false;
+ File testArtifact = new File(target,
"maven-jar-plugin-test-mjar-90-99.0-tests.jar")
+ if (testArtifact.exists()) {
+ System.err.println("testArtifact file has been created with
maven.Test.skip=true.")
+ return false
}
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/multimodule-multirelease-with-excludes/verify.groovy
b/src/it/multimodule-multirelease-with-excludes/verify.groovy
index 210693a..6c800ac 100644
--- a/src/it/multimodule-multirelease-with-excludes/verify.groovy
+++ b/src/it/multimodule-multirelease-with-excludes/verify.groovy
@@ -17,23 +17,23 @@
* under the License.
*/
-import java.util.jar.*;
+import java.util.jar.*
/*
* Multi-module (therefore two JAR files), multi-release with at least one
file excluded.
* Asserts the exact set of file entries per JAR: every file in the JAR is
listed below.
*/
-File target = new File(basedir, "target");
+File target = new File(basedir, "target")
// Module foo.bar: base classes, the Java 16 override, the manifest and the
Maven descriptor.
-Set<String> content = new HashSet<>();
-content.add("module-info.class") // this is a modular
JAR
-content.add("foo/") // directory entry
-content.add("foo/MainFile.class") // base class, also
the declared Main-Class
-content.add("foo/OtherFile.class") // base class
+Set<String> content = new HashSet<>()
+content.add("module-info.class") // this is a modular JAR
+content.add("foo/") // directory entry
+content.add("foo/MainFile.class") // base class, also the declared Main-Class
+content.add("foo/OtherFile.class") // base class
content.add("META-INF/")
content.add("META-INF/versions/16/foo/")
-content.add("META-INF/versions/16/foo/OtherFile.class") // multi-release
override for Java 16
+content.add("META-INF/versions/16/foo/OtherFile.class") // multi-release
override for Java 16
content.add("META-INF/MANIFEST.MF")
content.add("META-INF/maven/")
content.add("META-INF/maven/org.apache.maven.plugins/")
@@ -64,12 +64,10 @@ verify(new File(target, "foo.bar.more-1.0-SNAPSHOT.jar"),
content, null)
* Asserts the JAR's file entries are exactly the given set,
* and that the JAR is flagged Multi-Release with the expected Main-Class.
*/
-void verify(File artifact, Set<String> content, String mainClass)
-{
+void verify(File artifact, Set<String> content, String mainClass) {
JarFile jar = new JarFile(artifact)
Enumeration jarEntries = jar.entries()
- while (jarEntries.hasMoreElements())
- {
+ while (jarEntries.hasMoreElements()) {
JarEntry entry = (JarEntry) jarEntries.nextElement()
String name = entry.getName()
assert content.remove(name) : "Missing entry: " + name
@@ -80,5 +78,5 @@ void verify(File artifact, Set<String> content, String
mainClass)
assert Objects.equals("true",
attributes.get(Attributes.Name.MULTI_RELEASE))
assert Objects.equals(mainClass,
attributes.get(Attributes.Name.MAIN_CLASS))
- jar.close();
+ jar.close()
}
diff --git a/src/it/multimodule-multirelease/verify.groovy
b/src/it/multimodule-multirelease/verify.groovy
index d62d91f..928713f 100644
--- a/src/it/multimodule-multirelease/verify.groovy
+++ b/src/it/multimodule-multirelease/verify.groovy
@@ -17,13 +17,13 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-File target = new File(basedir, "target");
+File target = new File(basedir, "target")
-Set<String> content = new HashSet<>();
+Set<String> content = new HashSet<>()
content.add("module-info.class")
content.add("foo/MainFile.class")
content.add("foo/OtherFile.class")
@@ -44,15 +44,12 @@
content.add("META-INF/maven/org.apache.maven.plugins/multirelease-with-modules/p
content.add("META-INF/maven/org.apache.maven.plugins/multirelease-with-modules/pom.properties")
verify(new File(target, "foo.bar.more-1.0-SNAPSHOT.jar"), content, null)
-void verify(File artifact, Set<String> content, String mainClass)
-{
+void verify(File artifact, Set<String> content, String mainClass) {
JarFile jar = new JarFile(artifact)
Enumeration jarEntries = jar.entries()
- while (jarEntries.hasMoreElements())
- {
+ while (jarEntries.hasMoreElements()) {
JarEntry entry = (JarEntry) jarEntries.nextElement()
- if (!entry.isDirectory())
- {
+ if (!entry.isDirectory()) {
String name = entry.getName()
assert content.remove(name) : "Missing entry: " + name
}
@@ -63,5 +60,5 @@ void verify(File artifact, Set<String> content, String
mainClass)
assert Objects.equals("true",
attributes.get(Attributes.Name.MULTI_RELEASE))
assert Objects.equals(mainClass,
attributes.get(Attributes.Name.MAIN_CLASS))
- jar.close();
+ jar.close()
}
diff --git a/src/it/multimodule/verify.groovy b/src/it/multimodule/verify.groovy
index df8756d..ea9f6c0 100644
--- a/src/it/multimodule/verify.groovy
+++ b/src/it/multimodule/verify.groovy
@@ -17,13 +17,13 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.*
+import java.util.jar.*
-File target = new File(basedir, "target");
+File target = new File(basedir, "target")
-Set<String> content = new HashSet<>();
+Set<String> content = new HashSet<>()
content.add("module-info.class")
content.add("foo/MainFile.class")
content.add("META-INF/MANIFEST.MF")
@@ -39,15 +39,12 @@
content.add("META-INF/maven/org.apache.maven.plugins/multi-module/pom.xml")
content.add("META-INF/maven/org.apache.maven.plugins/multi-module/pom.properties")
verify(new File(target, "foo.bar.more-1.0-SNAPSHOT.jar"), content, null)
-void verify(File artifact, Set<String> content, String mainClass)
-{
+void verify(File artifact, Set<String> content, String mainClass) {
JarFile jar = new JarFile(artifact)
Enumeration jarEntries = jar.entries()
- while (jarEntries.hasMoreElements())
- {
+ while (jarEntries.hasMoreElements()) {
JarEntry entry = (JarEntry) jarEntries.nextElement()
- if (!entry.isDirectory())
- {
+ if (!entry.isDirectory()) {
String name = entry.getName()
assert content.remove(name) : "Missing entry: " + name
}
@@ -58,5 +55,5 @@ void verify(File artifact, Set<String> content, String
mainClass)
assert attributes.get(Attributes.Name.MULTI_RELEASE) == null
assert Objects.equals(mainClass,
attributes.get(Attributes.Name.MAIN_CLASS))
- jar.close();
+ jar.close()
}
diff --git a/src/it/project-004/verify.groovy b/src/it/project-004/verify.groovy
index 6989c03..bba0609 100644
--- a/src/it/project-004/verify.groovy
+++ b/src/it/project-004/verify.groovy
@@ -18,109 +18,101 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-
-boolean result = true;
-
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or not a directory." );
- return false;
- }
+import java.io.*
+import java.util.*
+import java.util.jar.*
- File artifact = new File( target,
"maven-jar-plugin-test-project-004-99.0.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "target file is missing or a directory." );
- return false;
- }
+boolean result = true
- String[] artifactNames = [ "service/TestInterface.class",
- "service/impl/TestImplementation.class", "TestCompile1.class",
"notIncluded.xml", "META-INF/MANIFEST.MF",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-project-004/pom.properties",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-project-004/pom.xml"
];
+try {
+ File target = new File(basedir, "target")
+ if (!target.exists() || !target.isDirectory()) {
+ System.err.println("target file is missing or not a directory.")
+ return false
+ }
- Set contents = new HashSet();
+ File artifact = new File(target,
"maven-jar-plugin-test-project-004-99.0.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("target file is missing or a directory.")
+ return false
+ }
- JarFile jar = new JarFile( artifact );
- Enumeration jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ String[] artifactNames = [
+ "service/TestInterface.class",
+ "service/impl/TestImplementation.class",
+ "TestCompile1.class",
+ "notIncluded.xml",
+ "META-INF/MANIFEST.MF",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-project-004/pom.properties",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-project-004/pom.xml"
+ ]
+
+ Set contents = new HashSet()
+
+ JarFile jar = new JarFile(artifact)
+ Enumeration jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- contents.add( entry.getName() );
+ contents.add(entry.getName())
}
}
- if ( artifactNames.length != contents.size() )
- {
- System.err.println( "jar content size is different from the expected
content size" );
- return false;
+ if (artifactNames.length != contents.size()) {
+ System.err.println("jar content size is different from the expected
content size")
+ return false
}
- for ( int i = 0; i < artifactNames.length; i++ )
- {
- String artifactName = artifactNames[i];
- if ( !contents.contains( artifactName ) )
- {
- System.err.println( "Artifact[" + artifactName + "] not found
in jar archive" );
- return false;
+ for (int i = 0; i <artifactNames.length; i++) {
+ String artifactName = artifactNames[i]
+ if (!contents.contains(artifactName)) {
+ System.err.println("Artifact[" + artifactName + "] not found in
jar archive")
+ return false
}
}
// second jar
- artifact = new File( target,
"maven-jar-plugin-test-project-004-99.0-service.jar" );
- if ( !artifact.exists() || artifact.isDirectory() )
- {
- System.err.println( "target file is missing or a directory." );
- return false;
+ artifact = new File(target,
"maven-jar-plugin-test-project-004-99.0-service.jar")
+ if (!artifact.exists() || artifact.isDirectory()) {
+ System.err.println("target file is missing or a directory.")
+ return false
}
- artifactNames = [ "service/TestInterface.class",
- "META-INF/MANIFEST.MF",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-project-004/pom.properties",
-
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-project-004/pom.xml"
];
+ artifactNames = [
+ "service/TestInterface.class",
+ "META-INF/MANIFEST.MF",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-project-004/pom.properties",
+
"META-INF/maven/org.apache.maven.plugins/maven-jar-plugin-test-project-004/pom.xml"
+ ]
- contents = new HashSet();
+ contents = new HashSet()
- jar = new JarFile( artifact );
- jarEntries = jar.entries();
- while ( jarEntries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) jarEntries.nextElement();
- if ( !entry.isDirectory() )
- {
+ jar = new JarFile(artifact)
+ jarEntries = jar.entries()
+ while (jarEntries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement()
+ if (!entry.isDirectory()) {
// Only compare files
- contents.add( entry.getName() );
+ contents.add(entry.getName())
}
}
- if ( artifactNames.length != contents.size() )
- {
- System.err.println( "jar content size is different from the expected
content size" );
- return false;
+ if (artifactNames.length != contents.size()) {
+ System.err.println("jar content size is different from the expected
content size")
+ return false
}
- for ( int i = 0; i < artifactNames.length; i++ )
- {
- String artifactName = artifactNames[i];
- if ( !contents.contains( artifactName ) )
- {
- System.err.println( "Artifact[" + artifactName + "] not found
in jar archive" );
- return false;
+ for (int i = 0; i <artifactNames.length; i++) {
+ String artifactName = artifactNames[i]
+ if (!contents.contains(artifactName)) {
+ System.err.println("Artifact[" + artifactName + "] not found in
jar archive")
+ return false
}
}
}
-catch( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch(Throwable e) {
+ e.printStackTrace()
+ result = false
}
-return result;
+return result
diff --git a/src/it/records-jar-validate/verify.groovy
b/src/it/records-jar-validate/verify.groovy
index 99e8d88..baaad08 100644
--- a/src/it/records-jar-validate/verify.groovy
+++ b/src/it/records-jar-validate/verify.groovy
@@ -17,44 +17,37 @@
* under the License.
*/
-import java.io.*;
-import java.util.jar.*;
+import java.io.*
+import java.util.jar.*
-boolean result = true;
-JarFile jar = null;
+boolean result = true
+JarFile jar = null
-try
-{
- File artifact = new File( basedir,
"target/records-jar-validate-1.0-SNAPSHOT.jar" );
- if ( !artifact.isFile() )
- {
- System.err.println( "Expected JAR is missing: " + artifact );
- return false;
+try {
+ File artifact = new File(basedir,
"target/records-jar-validate-1.0-SNAPSHOT.jar")
+ if (!artifact.isFile()) {
+ System.err.println("Expected JAR is missing: " + artifact)
+ return false
}
- jar = new JarFile( artifact );
- if ( jar.getEntry( "it/records/Point.class" ) == null )
- {
- System.err.println( "JAR does not contain the record class
it/records/Point.class" );
- return false;
+ jar = new JarFile(artifact)
+ if (jar.getEntry("it/records/Point.class") == null) {
+ System.err.println("JAR does not contain the record class
it/records/Point.class")
+ return false
}
- if ( jar.getEntry( "module-info.class" ) == null )
- {
- System.err.println( "JAR does not contain module-info.class" );
- return false;
+ if (jar.getEntry("module-info.class") == null) {
+ System.err.println("JAR does not contain module-info.class")
+ return false
}
}
-catch ( Throwable e )
-{
- e.printStackTrace();
- result = false;
+catch (Throwable e) {
+ e.printStackTrace()
+ result = false
}
-finally
-{
- if ( jar != null )
- {
- jar.close();
+finally {
+ if (jar != null) {
+ jar.close()
}
}
-return result;
+return result
diff --git a/src/it/test-jar-attach/verify.groovy
b/src/it/test-jar-attach/verify.groovy
index efb6df4..bb06c9a 100644
--- a/src/it/test-jar-attach/verify.groovy
+++ b/src/it/test-jar-attach/verify.groovy
@@ -17,7 +17,7 @@
* under the License.
*/
-def localRepo =
basedir.getParentFile().getParentFile().getParentFile().getPath() +
"/target/local-repo";
+def localRepo =
basedir.getParentFile().getParentFile().getParentFile().getPath() +
"/target/local-repo"
def artifact = new File(localRepo,
"org/apache/maven/plugins/test-jar-attach/1.0-SNAPSHOT/test-jar-attach-1.0-SNAPSHOT-tests.jar")
assert !artifact.exists()