mirror of https://github.com/apache/maven.git
add core it test for regression found in appassembler with download timestamped SNAPSHOT
see http://mail-archives.apache.org/mod_mbox/maven-dev/201112.mbox/%3cCAPCjjnHjsQED0tzUztwWtQcSpYVN_k0-0Xq2B7QxTN5arZ-xzA@mail.gmail.com%3e git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@1210403 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f65930b4a5
commit
3662a2e3ff
|
@ -0,0 +1,123 @@
|
|||
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.util.FileUtils;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.mortbay.jetty.Handler;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.DefaultHandler;
|
||||
import org.mortbay.jetty.handler.HandlerList;
|
||||
import org.mortbay.jetty.handler.ResourceHandler;
|
||||
import org.mortbay.resource.FileResource;
|
||||
import org.mortbay.resource.Resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenIT0146InstallerSnapshotNaming
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
|
||||
private Server server;
|
||||
|
||||
private int port;
|
||||
|
||||
|
||||
private final File testDir;
|
||||
|
||||
public MavenIT0146InstallerSnapshotNaming()
|
||||
throws IOException
|
||||
{
|
||||
super( "(2.0.2,)" );
|
||||
testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0146" );
|
||||
}
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
ResourceHandler resourceHandler = new ResourceHandler();
|
||||
resourceHandler.setResourceBase( new File( testDir, "repo" ).getAbsolutePath() );
|
||||
// org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/maven-metadata.xml
|
||||
HandlerList handlers = new HandlerList();
|
||||
handlers.setHandlers( new Handler[]{ resourceHandler, new DefaultHandler() } );
|
||||
|
||||
server = new Server( 0 );
|
||||
server.setHandler( handlers );
|
||||
server.start();
|
||||
|
||||
port = server.getConnectors()[0].getLocalPort();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
|
||||
if ( server != null )
|
||||
{
|
||||
server.stop();
|
||||
server = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void testitRemoteDownloadTimestampedName()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
|
||||
Properties properties = verifier.newDefaultFilterProperties();
|
||||
properties.setProperty( "@host@", InetAddress.getLocalHost().getCanonicalHostName() );
|
||||
properties.setProperty( "@port@", Integer.toString( port ) );
|
||||
|
||||
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", properties );
|
||||
|
||||
|
||||
verifier.getCliOptions().add( "--settings" );
|
||||
verifier.getCliOptions().add( "settings.xml" );
|
||||
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.it0146" );
|
||||
|
||||
verifier.getCliOptions().add( "-X" );
|
||||
|
||||
verifier.deleteDirectory( "target" );
|
||||
|
||||
verifier.executeGoal( "validate" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
verifier.assertFilePresent( "target/appassembler/repo/dep-0.1-20110726.105319-1.jar" );
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<?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.it0146</groupId>
|
||||
<artifactId>test</artifactId>
|
||||
<version>0.1</version>
|
||||
|
||||
<name>Maven Integration Test :: it-0146</name>
|
||||
<description>
|
||||
Verify that download remote snapshot are correctly installed locally via Installer with timestamped name.
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its.it0146</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-artifact</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>install-artifacts</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
Binary file not shown.
|
@ -0,0 +1,36 @@
|
|||
<?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.it0146</groupId>
|
||||
<artifactId>dep</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>maven-core-it</id>
|
||||
<url>file:///${basedir}/repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.apache.maven.its.it0146</groupId>
|
||||
<artifactId>dep</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<versioning>
|
||||
<snapshot>
|
||||
<timestamp>20110726.105319</timestamp>
|
||||
<buildNumber>1</buildNumber>
|
||||
</snapshot>
|
||||
<lastUpdated>20110726105319</lastUpdated>
|
||||
<snapshotVersions>
|
||||
<snapshotVersion>
|
||||
<extension>jar</extension>
|
||||
<value>0.1-20110726.105319-1</value>
|
||||
<updated>20110726105319</updated>
|
||||
</snapshotVersion>
|
||||
<snapshotVersion>
|
||||
<extension>pom</extension>
|
||||
<value>0.1-20110726.105319-1</value>
|
||||
<updated>20110726105319</updated>
|
||||
</snapshotVersion>
|
||||
</snapshotVersions>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,45 @@
|
|||
<?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://@host@:@port@/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>maven-core-it-repo</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
|
@ -0,0 +1,165 @@
|
|||
package org.apache.maven.plugin.coreit;
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
||||
import org.apache.maven.artifact.installer.ArtifactInstaller;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
* @goal install-artifacts
|
||||
* @requiresDependencyResolution runtime
|
||||
* @phase package
|
||||
*/
|
||||
public class InstallArtifactsMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* @readonly
|
||||
* @parameter expression="${project.runtimeArtifacts}"
|
||||
*/
|
||||
private List artifacts;
|
||||
|
||||
/**
|
||||
* @component
|
||||
*/
|
||||
private ArtifactInstaller artifactInstaller;
|
||||
|
||||
/**
|
||||
* @component
|
||||
*/
|
||||
private ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||
|
||||
/**
|
||||
* The directory that will be used to assemble the artifacts in
|
||||
* and place the bin scripts.
|
||||
*
|
||||
* @required
|
||||
* @parameter expression="${assembleDirectory}" default-value="${project.build.directory}/appassembler"
|
||||
*/
|
||||
private File assembleDirectory;
|
||||
|
||||
/**
|
||||
* Path (relative to assembleDirectory) of the desired output repository.
|
||||
*
|
||||
* @parameter default-value="repo"
|
||||
*/
|
||||
private String repositoryName;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
|
||||
ArtifactRepositoryLayout artifactRepositoryLayout = new FlatRepositoryLayout();
|
||||
|
||||
// The repo where the jar files will be installed
|
||||
ArtifactRepository artifactRepository =
|
||||
artifactRepositoryFactory.createDeploymentArtifactRepository( "appassembler", "file://"
|
||||
+ assembleDirectory.getAbsolutePath() + "/" + repositoryName, artifactRepositoryLayout, false );
|
||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
|
||||
installArtifact( artifactRepository, artifact );
|
||||
}
|
||||
}
|
||||
|
||||
private void installArtifact( ArtifactRepository artifactRepository, Artifact artifact )
|
||||
throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
artifact.isSnapshot();
|
||||
|
||||
if ( artifact.getFile() != null )
|
||||
{
|
||||
artifactInstaller.install( artifact.getFile(), artifact, artifactRepository );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactInstallationException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Failed to copy artifact.", e );
|
||||
}
|
||||
}
|
||||
|
||||
public static class FlatRepositoryLayout
|
||||
implements ArtifactRepositoryLayout
|
||||
{
|
||||
private static final char ARTIFACT_SEPARATOR = '-';
|
||||
|
||||
private static final char GROUP_SEPARATOR = '.';
|
||||
|
||||
public String pathOf( Artifact artifact )
|
||||
{
|
||||
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
||||
|
||||
StringBuffer path = new StringBuffer();
|
||||
|
||||
path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() );
|
||||
|
||||
if ( artifact.hasClassifier() )
|
||||
{
|
||||
path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() );
|
||||
}
|
||||
|
||||
if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
|
||||
{
|
||||
path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() );
|
||||
}
|
||||
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
|
||||
{
|
||||
return pathOfRepositoryMetadata( metadata.getLocalFilename( repository ) );
|
||||
}
|
||||
|
||||
private String pathOfRepositoryMetadata( String filename )
|
||||
{
|
||||
StringBuffer path = new StringBuffer();
|
||||
|
||||
path.append( filename );
|
||||
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
|
||||
{
|
||||
return pathOfRepositoryMetadata( metadata.getRemoteFilename() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue