mirror of https://github.com/apache/maven.git
[MNG-4326] Maven should not check snapshot repositories for dependencies in the reactor
o Added IT git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@928840 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ce852d53fc
commit
b48e355ee0
|
@ -167,6 +167,7 @@ public class IntegrationTestSuite
|
|||
suite.addTestSuite( MavenITmng4331DependencyCollectionTest.class );
|
||||
suite.addTestSuite( MavenITmng4328PrimitiveMojoParameterConfigurationTest.class );
|
||||
suite.addTestSuite( MavenITmng4327ExcludeForkingMojoFromForkedLifecycleTest.class );
|
||||
suite.addTestSuite( MavenITmng4326LocalSnapshotSuppressesRemoteCheckTest.class );
|
||||
suite.addTestSuite( MavenITmng4321CliUsesPluginMgmtConfigTest.class );
|
||||
suite.addTestSuite( MavenITmng4320AggregatorAndDependenciesTest.class );
|
||||
suite.addTestSuite( MavenITmng4319PluginExecutionGoalInterpolationTest.class );
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
package org.apache.maven.it;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.mortbay.jetty.Handler;
|
||||
import org.mortbay.jetty.Request;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.AbstractHandler;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4326">MNG-4326</a>.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4326LocalSnapshotSuppressesRemoteCheckTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
|
||||
public MavenITmng4326LocalSnapshotSuppressesRemoteCheckTest()
|
||||
{
|
||||
super( "[3.0-alpha-8,)" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that locally built/installed snapshot artifacts suppress remote update checks (as long as the local copy
|
||||
* still satifies the update policy configured for the remote repository).
|
||||
*/
|
||||
public void testit()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4326" );
|
||||
|
||||
// setup: install a local snapshot
|
||||
Verifier verifier = new Verifier( new File( testDir, "dependency" ).getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng4326" );
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.executeGoal( "validate" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
final List uris = new ArrayList();
|
||||
|
||||
Handler repoHandler = new AbstractHandler()
|
||||
{
|
||||
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
|
||||
throws IOException, ServletException
|
||||
{
|
||||
PrintWriter writer = response.getWriter();
|
||||
|
||||
String uri = request.getRequestURI();
|
||||
|
||||
if ( uri.startsWith( "/repo/org/apache/maven/its/mng4326" )
|
||||
&& !uri.endsWith( ".md5" ) && !uri.endsWith( ".sha1" ) )
|
||||
{
|
||||
uris.add( uri.substring( 34 ) );
|
||||
}
|
||||
|
||||
if ( uri.endsWith( "dep/0.1-SNAPSHOT/maven-metadata.xml" ) )
|
||||
{
|
||||
java.text.DateFormat fmt = new java.text.SimpleDateFormat( "yyyyMMddHHmmss" );
|
||||
fmt.setTimeZone( java.util.TimeZone.getTimeZone( "UTC" ) );
|
||||
String now = fmt.format( new Date( System.currentTimeMillis() + 3000 ) );
|
||||
|
||||
response.setStatus( HttpServletResponse.SC_OK );
|
||||
writer.println( "<metadata>" );
|
||||
writer.println( " <groupId>org.apache.maven.its.mng4326</groupId>" );
|
||||
writer.println( " <artifactId>dep</artifactId>" );
|
||||
writer.println( " <version>0.1-SNAPSHOT</version>" );
|
||||
writer.println( " <versioning>" );
|
||||
writer.println( " <snapshot>" );
|
||||
writer.println( " <timestamp>20100329.235556</timestamp>" );
|
||||
writer.println( " <buildNumber>1</buildNumber>" );
|
||||
writer.println( " </snapshot>" );
|
||||
writer.println( " <lastUpdated>" + now + "</lastUpdated>" );
|
||||
writer.println( " </versioning>" );
|
||||
writer.println( "</metadata>" );
|
||||
}
|
||||
else if ( uri.endsWith( ".pom" ) )
|
||||
{
|
||||
response.setStatus( HttpServletResponse.SC_OK );
|
||||
writer.println( "<project>" );
|
||||
writer.println( " <modelVersion>4.0.0</modelVersion>" );
|
||||
writer.println( " <groupId>org.apache.maven.its.mng4326</groupId>" );
|
||||
writer.println( " <artifactId>dep</artifactId>" );
|
||||
writer.println( " <version>0.1-SNAPSHOT</version>" );
|
||||
writer.println( "</project>" );
|
||||
}
|
||||
else if ( uri.endsWith( ".jar" ) )
|
||||
{
|
||||
response.setStatus( HttpServletResponse.SC_OK );
|
||||
writer.println( "empty" );
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus( HttpServletResponse.SC_NOT_FOUND );
|
||||
}
|
||||
|
||||
( (Request) request ).setHandled( true );
|
||||
}
|
||||
};
|
||||
|
||||
Server server = new Server( 0 );
|
||||
server.setHandler( repoHandler );
|
||||
server.start();
|
||||
|
||||
try
|
||||
{
|
||||
// test 1: resolve snapshot, just built local copy should suppress daily remote update check
|
||||
verifier = new Verifier( new File( testDir, "test" ).getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
Properties filterProps = verifier.newDefaultFilterProperties();
|
||||
filterProps.setProperty( "@port@", Integer.toString( server.getConnectors()[0].getLocalPort() ) );
|
||||
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
|
||||
verifier.getCliOptions().add( "--settings" );
|
||||
verifier.getCliOptions().add( "settings.xml" );
|
||||
verifier.setLogFileName( "log-daily.txt" );
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.executeGoal( "validate" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
|
||||
List cp = verifier.loadLines( "target/classpath.txt", "UTF-8" );
|
||||
assertTrue( cp.toString(), cp.contains( "dep-0.1-SNAPSHOT.jar" ) );
|
||||
|
||||
assertFalse( uris.toString(), uris.contains( "/dep/0.1-SNAPSHOT/maven-metadata.xml" ) );
|
||||
assertFalse( uris.toString(), uris.contains( "/dep/0.1-SNAPSHOT/dep-0.1-20100329.235556-1.jar" ) );
|
||||
|
||||
uris.clear();
|
||||
|
||||
// test 2: force snapshot updates, remote metadata and artifacts should be fetched
|
||||
verifier.getCliOptions().add( "-U" );
|
||||
verifier.setLogFileName( "log-force.txt" );
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.executeGoal( "validate" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
|
||||
cp = verifier.loadLines( "target/classpath.txt", "UTF-8" );
|
||||
assertTrue( cp.toString(), cp.contains( "dep-0.1-SNAPSHOT.jar" ) );
|
||||
|
||||
assertTrue( uris.toString(), uris.contains( "/dep/0.1-SNAPSHOT/maven-metadata.xml" ) );
|
||||
assertTrue( uris.toString(), uris.contains( "/dep/0.1-SNAPSHOT/dep-0.1-20100329.235556-1.jar" ) );
|
||||
}
|
||||
finally
|
||||
{
|
||||
verifier.resetStreams();
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng4326</groupId>
|
||||
<artifactId>dep</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Maven Integration Test :: MNG-4326</name>
|
||||
<description>
|
||||
Verify that locally built/installed snapshot artifacts suppress remote update checks (as long as the local copy
|
||||
still satifies the update policy configured for the remote repository).
|
||||
</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-artifact</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<mainFile>pom.xml</mainFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>set</goal>
|
||||
<goal>attach-pom</goal>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng4326</groupId>
|
||||
<artifactId>test</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Maven Integration Test :: MNG-4326</name>
|
||||
<description>
|
||||
Verify that locally built/installed snapshot artifacts suppress remote update checks (as long as the local copy
|
||||
still satifies the update policy configured for the remote repository).
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<!-- This has just been installed, so its resolution should not reach out to the remote repos -->
|
||||
<groupId>org.apache.maven.its.mng4326</groupId>
|
||||
<artifactId>dep</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-dependency-resolution</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<compileClassPath>target/classpath.txt</compileClassPath>
|
||||
<significantPathLevels>1</significantPathLevels>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<settings>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>maven-core-it-repo</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-core-it</id>
|
||||
<url>http://localhost:@port@/repo</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
<updatePolicy>daily</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>maven-core-it-repo</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
Loading…
Reference in New Issue