import java.io.*; import java.util.*; File dir = new File( new File( basedir, "target/repo" ), "org/apache/maven/its/deploy/nmas/test/1.0-SNAPSHOT" ); String[] files = dir.list(); if ( files == null ) { throw new FileNotFoundException( "Missing directory: " + dir ); } String pom = null, jar = null; for ( String file : files ) { if ( file.matches( "test-1\\.0-[0-9]{8}\\.[0-9]{6}-([0-9]+)\\.pom" ) ) { pom = file.substring( 0, file.length() - 4 ); } if ( file.matches( "test-1\\.0-[0-9]{8}\\.[0-9]{6}-([0-9]+)-it\\.jar" ) ) { jar = file.substring( 0, file.length() - 7 ); } } if ( pom == null ) { throw new FileNotFoundException( "Missing timestamped POM" ); } if ( jar == null ) { throw new FileNotFoundException( "Missing timestamped JAR" ); } if ( !jar.equals( pom ) ) { throw new IllegalStateException( "Timestamp mismatch " + jar + " vs " + pom ); } return true;