No. You need to use deploy:deploy-file instead.
null
.
* @throws Exception If the verification failed.
*/
public static void verifyChecksum( File checksumFile )
throws Exception
{
File dataFile;
Digester digester;
if ( checksumFile.getName().endsWith( ".md5" ) )
{
digester = new Md5Digester();
dataFile = new File( checksumFile.getPath().substring( 0, checksumFile.getPath().length() - 4 ) );
}
else if ( checksumFile.getName().endsWith( ".sha1" ) )
{
digester = new Sha1Digester();
dataFile = new File( checksumFile.getPath().substring( 0, checksumFile.getPath().length() - 5 ) );
}
else
{
throw new IllegalArgumentException( "Unsupported checksum file: " + checksumFile );
}
String expected = FileUtils.fileRead( checksumFile, "UTF-8" );
digester.verify( dataFile, expected );
}
}
maven-install-plugin-2.4/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java 0000664 0001750 0001750 00000022527 11161005702 032267 0 ustar ebourg ebourg package org.apache.maven.plugin.install;
/*
* 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.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import java.io.File;
import java.io.Reader;
/**
* @author Allan Ramirez
*/
public class InstallFileMojoTest
extends AbstractMojoTestCase
{
private String groupId;
private String legacyGroupId;
private String artifactId;
private String version;
private String packaging;
private String classifier;
private File file;
private final String LOCAL_REPO = "target/local-repo/";
public void setUp()
throws Exception
{
super.setUp();
FileUtils.deleteDirectory( new File( getBasedir() + "/" + LOCAL_REPO ) );
}
public void testInstallFileTestEnvironment()
throws Exception
{
File testPom = new File( getBasedir(), "target/test-classes/unit/install-file-basic-test/plugin-config.xml" );
InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", testPom );
assertNotNull( mojo );
}
public void testBasicInstallFile()
throws Exception
{
File testPom = new File( getBasedir(), "target/test-classes/unit/install-file-basic-test/plugin-config.xml" );
InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", testPom );
assertNotNull( mojo );
assignValuesForParameter( mojo );
mojo.execute();
File installedArtifact = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version + "." + packaging );
assertTrue( installedArtifact.exists() );
}
public void testLayoutInstallFile()
throws Exception
{
File testPom = new File( getBasedir(), "target/test-classes/unit/install-file-layout-test/plugin-config.xml" );
InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", testPom );
assertNotNull( mojo );
assignValuesForParameter( mojo );
mojo.setLocalRepositoryPath( new File( getBasedir(), LOCAL_REPO ) );
mojo.execute();
File installedArtifact = new File( getBasedir(), LOCAL_REPO + legacyGroupId + "/" + "jars" + "/" + artifactId + "-"
+ version + "." + packaging );
assertTrue( installedArtifact.exists() );
}
public void testInstallFileWithClassifier()
throws Exception
{
File testPom =
new File( getBasedir(), "target/test-classes/unit/install-file-with-classifier/plugin-config.xml" );
InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", testPom );
assertNotNull( mojo );
assignValuesForParameter( mojo );
assertNotNull( classifier );
mojo.execute();
File installedArtifact = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version + "-" + classifier + "." + packaging );
assertTrue( installedArtifact.exists() );
}
public void testInstallFileWithGeneratePom()
throws Exception
{
File testPom =
new File( getBasedir(), "target/test-classes/unit/install-file-test-generatePom/plugin-config.xml" );
InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", testPom );
assertNotNull( mojo );
assignValuesForParameter( mojo );
mojo.execute();
File installedArtifact = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version + "." + packaging );
assertTrue( ( (Boolean) getVariableValueFromObject( mojo, "generatePom" ) ).booleanValue() );
assertTrue( installedArtifact.exists() );
File installedPom = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version + "." + "pom" );
Model model;
Reader reader = null;
try
{
reader = ReaderFactory.newXmlReader( installedPom );
model = new MavenXpp3Reader().read( reader );
}
finally
{
IOUtil.close( reader );
}
assertEquals( "4.0.0", model.getModelVersion() );
assertEquals( (String) getVariableValueFromObject( mojo, "groupId" ), model.getGroupId() );
assertEquals( artifactId, model.getArtifactId() );
assertEquals( version, model.getVersion() );
}
public void testInstallFileWithPomFile()
throws Exception
{
File testPom =
new File( getBasedir(), "target/test-classes/unit/install-file-with-pomFile-test/plugin-config.xml" );
InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", testPom );
assertNotNull( mojo );
assignValuesForParameter( mojo );
mojo.execute();
File pomFile = (File) getVariableValueFromObject( mojo, "pomFile" );
assertTrue( pomFile.exists() );
File installedArtifact = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version + "." + packaging );
assertTrue( installedArtifact.exists() );
File installedPom = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version + "." + "pom" );
assertTrue( installedPom.exists() );
}
public void testInstallFileWithPomAsPackaging()
throws Exception
{
File testPom = new File( getBasedir(),
"target/test-classes/unit/install-file-with-pom-as-packaging/" + "plugin-config.xml" );
InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", testPom );
assertNotNull( mojo );
assignValuesForParameter( mojo );
assertTrue( file.exists() );
assertEquals( "pom", packaging );
mojo.execute();
File installedPom = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version + "." + "pom" );
assertTrue( installedPom.exists() );
}
public void testInstallFileWithChecksum()
throws Exception
{
File testPom =
new File( getBasedir(), "target/test-classes/unit/install-file-with-checksum/" + "plugin-config.xml" );
InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", testPom );
assertNotNull( mojo );
assignValuesForParameter( mojo );
boolean createChecksum = ( (Boolean) getVariableValueFromObject( mojo, "createChecksum" ) ).booleanValue();
assertTrue( createChecksum );
mojo.execute();
//get the actual checksum of the artifact
String actualMd5Sum = mojo.md5Digester.calc( file );
String actualSha1Sum = mojo.sha1Digester.calc( file );
String localPath = getBasedir() + "/" + LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version;
File installedArtifact = new File( localPath + "." + "jar" );
File md5 = new File( localPath + ".jar.md5" );
File sha1 = new File( localPath + ".jar.sha1" );
assertTrue( md5.exists() );
assertTrue( sha1.exists() );
String generatedMd5 = FileUtils.fileRead( md5, "UTF-8" );
String generatedSha1 = FileUtils.fileRead( sha1, "UTF-8" );
assertEquals( actualMd5Sum, generatedMd5 );
assertEquals( actualSha1Sum, generatedSha1 );
assertTrue( installedArtifact.exists() );
}
private void assignValuesForParameter( Object obj )
throws Exception
{
this.groupId = dotToSlashReplacer( (String) getVariableValueFromObject( obj, "groupId" ) );
this.legacyGroupId = (String) getVariableValueFromObject( obj, "groupId" );
this.artifactId = (String) getVariableValueFromObject( obj, "artifactId" );
this.version = (String) getVariableValueFromObject( obj, "version" );
this.packaging = (String) getVariableValueFromObject( obj, "packaging" );
this.classifier = (String) getVariableValueFromObject( obj, "classifier" );
this.file = (File) getVariableValueFromObject( obj, "file" );
}
private String dotToSlashReplacer( String parameter )
{
return parameter.replace( '.', '/' );
}
}
maven-install-plugin-2.4/src/test/java/org/apache/maven/plugin/install/stubs/ 0000775 0001750 0001750 00000000000 12236252402 026666 5 ustar ebourg ebourg ././@LongLink 0000644 0000000 0000000 00000000150 12236252402 011634 L ustar root root maven-install-plugin-2.4/src/test/java/org/apache/maven/plugin/install/stubs/AttachedArtifactStub1.java maven-install-plugin-2.4/src/test/java/org/apache/maven/plugin/install/stubs/AttachedArtifactStub1.j0000664 0001750 0001750 00000001772 11123544663 033171 0 ustar ebourg ebourg package org.apache.maven.plugin.install.stubs;
/*
* 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.
*/
public class AttachedArtifactStub1
extends AttachedArtifactStub0
{
public String getArtifactId()
{
return "attached-artifact-test-1";
}
}
././@LongLink 0000644 0000000 0000000 00000000150 12236252402 011634 L ustar root root maven-install-plugin-2.4/src/test/java/org/apache/maven/plugin/install/stubs/AttachedArtifactStub0.java maven-install-plugin-2.4/src/test/java/org/apache/maven/plugin/install/stubs/AttachedArtifactStub0.j0000664 0001750 0001750 00000002436 11123544663 033166 0 ustar ebourg ebourg package org.apache.maven.plugin.install.stubs;
import java.io.File;
/*
* 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.
*/
public class AttachedArtifactStub0
extends InstallArtifactStub
{
public String getArtifactId()
{
return "attached-artifact-test-0";
}
public File getFile()
{
return new File( System.getProperty( "basedir" ),
"target/test-classes/unit/basic-install-test-with-attached-artifacts/" +
"target/maven-install-test-1.0-SNAPSHOT.jar" );
}
}
././@LongLink 0000644 0000000 0000000 00000000146 12236252402 011641 L ustar root root maven-install-plugin-2.4/src/test/java/org/apache/maven/plugin/install/stubs/InstallArtifactStub.java maven-install-plugin-2.4/src/test/java/org/apache/maven/plugin/install/stubs/InstallArtifactStub.jav0000664 0001750 0001750 00000005327 11123544663 033330 0 ustar ebourg ebourg package org.apache.maven.plugin.install.stubs;
/*
* 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.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.plugin.testing.stubs.ArtifactStub;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class InstallArtifactStub
extends ArtifactStub
{
private Map metadataMap;
private File file;
private boolean release;
public String getArtifactId()
{
return "maven-install-test";
}
public String getGroupId()
{
return "org.apache.maven.test";
}
public String getVersion()
{
return "1.0-SNAPSHOT";
}
public String getBaseVersion()
{
return getVersion();
}
public void setFile( File file )
{
this.file = file;
}
public File getFile()
{
return file;
}
public ArtifactHandler getArtifactHandler()
{
return new DefaultArtifactHandler()
{
public String getExtension()
{
return "jar";
}
};
}
public void addMetadata( ArtifactMetadata metadata )
{
if ( metadataMap == null )
{
metadataMap = new HashMap();
}
ArtifactMetadata m = (ArtifactMetadata) metadataMap.get( metadata.getKey() );
if ( m != null )
{
m.merge( metadata );
}
else
{
metadataMap.put( metadata.getKey(), metadata );
}
}
public Collection getMetadataList()
{
return metadataMap == null ? Collections.EMPTY_LIST : metadataMap.values();
}
public boolean isRelease()
{
return release;
}
public void setRelease( boolean release )
{
this.release = release;
}
}
maven-install-plugin-2.4/src/test/resources/ 0000775 0001750 0001750 00000000000 12236252402 020535 5 ustar ebourg ebourg maven-install-plugin-2.4/src/test/resources/unit/ 0000775 0001750 0001750 00000000000 12236252402 021514 5 ustar ebourg ebourg maven-install-plugin-2.4/src/test/resources/unit/install-file-with-pomFile-test/ 0000775 0001750 0001750 00000000000 12236252402 027416 5 ustar ebourg ebourg maven-install-plugin-2.4/src/test/resources/unit/install-file-with-pomFile-test/plugin-config.xml 0000664 0001750 0001750 00000005766 10712314063 032716 0 ustar ebourg ebourg <