Author: olamy Date: Mon Dec 5 10:36:32 2011 New Revision: 1210403 URL: http://svn.apache.org/viewvc?rev=1210403&view=rev Log: 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-...@mail.gmail.com%3e
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java (with props) maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/pom.xml (with props) maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.jar maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.pom (with props) maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/maven-metadata.xml (with props) maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/settings-template.xml (with props) maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java (with props) Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java?rev=1210403&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java (added) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java Mon Dec 5 10:36:32 2011 @@ -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" ); + + } + +} Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/pom.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/pom.xml?rev=1210403&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/pom.xml (added) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/pom.xml Mon Dec 5 10:36:32 2011 @@ -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> Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.jar URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.jar?rev=1210403&view=auto ============================================================================== Files maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.jar (added) and maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.jar Mon Dec 5 10:36:32 2011 differ Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.pom URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.pom?rev=1210403&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.pom (added) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.pom Mon Dec 5 10:36:32 2011 @@ -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> Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.pom ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/dep-0.1-20110726.105319-1.pom ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/maven-metadata.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/maven-metadata.xml?rev=1210403&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/maven-metadata.xml (added) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/maven-metadata.xml Mon Dec 5 10:36:32 2011 @@ -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> \ No newline at end of file Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/maven-metadata.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/repo/org/apache/maven/its/it0146/dep/0.1-SNAPSHOT/maven-metadata.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/settings-template.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/settings-template.xml?rev=1210403&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/settings-template.xml (added) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/settings-template.xml Mon Dec 5 10:36:32 2011 @@ -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> Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/settings-template.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/it0146/settings-template.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java?rev=1210403&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java (added) +++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java Mon Dec 5 10:36:32 2011 @@ -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() ); + } + } + +} Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision