| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| import java.io.*; |
| import java.util.*; |
| import java.util.regex.*; |
| |
| import org.codehaus.plexus.util.*; |
| import org.codehaus.plexus.util.xml.*; |
| |
| try |
| { |
| File itRepoDir = new File( basedir, "target/it-repo" ); |
| System.out.println( "Checking for existence of: " + itRepoDir ); |
| if ( !itRepoDir.isDirectory() ) |
| { |
| System.out.println( "FAILED!" ); |
| return false; |
| } |
| |
| String[] files = { |
| "junit/junit/4.13.1/junit-4.13.1.pom", |
| "junit/junit/4.13.1/junit-4.13.1.jar", |
| "junit/junit/maven-metadata-local.xml", |
| "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.pom", |
| "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.jar", |
| "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/maven-metadata-local.xml", |
| "org/apache/maven/its/minvoker-70/maven-metadata-local.xml", |
| "org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-SNAPSHOT.pom", |
| "org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata-local.xml", |
| "org/apache/maven/its/parent-b/maven-metadata-local.xml", |
| "org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-SNAPSHOT.pom", |
| "org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata-local.xml", |
| "org/apache/maven/its/parent-a/maven-metadata-local.xml", |
| "org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-SNAPSHOT.pom", |
| "org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata-local.xml", |
| "org/apache/maven/its/pom/maven-metadata-local.xml", |
| "org/apache/maven/its/dep/1.0/dep-1.0.pom", |
| "org/apache/maven/its/dep/1.0/dep-1.0-tests.jar", |
| "org/apache/maven/its/dep/2.0/dep-2.0.pom", |
| "org/apache/maven/its/dep/2.0/dep-2.0.jar", |
| "org/apache/maven/its/dep/maven-metadata-local.xml", |
| }; |
| for ( String file : files ) |
| { |
| File stagedFile = new File( itRepoDir, file ); |
| System.out.println( "Checking for existence of: " + stagedFile ); |
| if ( !stagedFile.isFile() ) |
| { |
| throw new IllegalStateException( "Missing: " + stagedFile ); |
| } |
| } |
| |
| Reader reader = ReaderFactory.newXmlReader( new File( itRepoDir, "org/apache/maven/its/dep/maven-metadata-local.xml" ) ); |
| Xpp3Dom dom = Xpp3DomBuilder.build( reader ); |
| IOUtil.close( reader ); |
| |
| if ( dom.getChild( "versioning" ).getChild( "versions" ).getChildCount() != 2 ) |
| { |
| throw new IllegalStateException( "Invalid version number count in metadata" ); |
| } |
| |
| List versions = new ArrayList(); |
| versions.add( dom.getChild( "versioning" ).getChild( "versions" ).getChild( 0 ).getValue() ); |
| versions.add( dom.getChild( "versioning" ).getChild( "versions" ).getChild( 1 ).getValue() ); |
| Collections.sort( versions ); |
| if ( !versions.equals( Arrays.asList( new String[] { "1.0", "2.0" } ) ) ) |
| { |
| throw new IllegalStateException( "Invalid version numbers in metadata: " + versions ); |
| } |
| } |
| catch( Throwable t ) |
| { |
| t.printStackTrace(); |
| return false; |
| } |
| |
| return true; |