Moved source plugins to main plugin
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@378781 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
9329c2c354
commit
009e7bceab
23 files changed
+1363
No files matched your search
@@ -0,0 +1,78 @@
|
||||
package org.apache.maven.plugin.source;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.MavenException;
|
||||
import org.apache.maven.project.Project;
|
||||
import org.apache.maven.repository.ArtifactTypeHandler;
|
||||
|
||||
/**
|
||||
* Java sources artifact type handler.
|
||||
*
|
||||
* @author <a href="snicoll@apache.org">Stephane Nicoll</a>
|
||||
* @version $Id: JavaSourceArtifactTypeHandler.java 371078 2006-01-21 15:55:44Z snicoll $
|
||||
*/
|
||||
public class JavaSourceArtifactTypeHandler
|
||||
implements ArtifactTypeHandler
|
||||
{
|
||||
/**
|
||||
* Map an artifact to a repository directory path.
|
||||
*
|
||||
* @param project the project for the artifact
|
||||
* @param type The type of the artifact
|
||||
* @return the path
|
||||
* @throws MavenException if an error occured while building the path
|
||||
*/
|
||||
public String constructRepositoryDirectoryPath( String type, Project project )
|
||||
throws MavenException
|
||||
{
|
||||
StringBuffer path = new StringBuffer();
|
||||
path.append( project.getArtifactDirectory() );
|
||||
path.append( "/java-sources/" );
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Map an artifact to a repository path.
|
||||
*
|
||||
* @param project the project for the artifact
|
||||
* @param type The type of the artifact
|
||||
* @param version The version of the artifact (may be a snapshot)
|
||||
* @return the path
|
||||
* @throws MavenException if an error occured while building the path
|
||||
*/
|
||||
public String constructRepositoryFullPath( String type, Project project, String version )
|
||||
throws MavenException
|
||||
{
|
||||
StringBuffer path = new StringBuffer( constructRepositoryDirectoryPath( type, project ) );
|
||||
path.append( project.getArtifactId() );
|
||||
path.append( "-" );
|
||||
path.append( version );
|
||||
|
||||
if ( type.equals( "java-source" ) )
|
||||
{
|
||||
path.append( "-sources.jar" );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new MavenException( "Unrecognised java-source type (is " + type + ")" );
|
||||
}
|
||||
|
||||
return path.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Your Corporation. All Rights Reserved.
|
||||
*/
|
||||
package org.apache.maven.plugin.source;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.maven.AbstractMavenComponent;
|
||||
import org.apache.maven.project.Project;
|
||||
import org.apache.maven.util.HttpUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* An helper class used to download java sources archives.
|
||||
*
|
||||
* @author <a href="snicoll@apache.org">Stephane Nicoll</a>
|
||||
* @version $Id: JavaSourcesDownloader.java 371078 2006-01-21 15:55:44Z snicoll $
|
||||
*/
|
||||
public class JavaSourcesDownloader
|
||||
extends AbstractMavenComponent
|
||||
{
|
||||
private static final String PROXY_LOGINHOST = "maven.proxy.ntlm.host";
|
||||
|
||||
private static final String PROXY_LOGINDOMAIN = "maven.proxy.ntlm.domain";
|
||||
|
||||
private static final Log log = LogFactory.getLog( JavaSourcesDownloader.class );
|
||||
|
||||
private Project project;
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String version;
|
||||
|
||||
private boolean ignoreErrors;
|
||||
|
||||
private boolean backwardCompatible;
|
||||
|
||||
|
||||
/**
|
||||
* Download the Java sources archive from the configured repositories.
|
||||
*
|
||||
* @throws NullPointerException if a mandatory parameter is not initialized
|
||||
* @throws FileNotFoundException if ignoreErrors is false and the archive is not found
|
||||
*/
|
||||
public void downloadJavaSources()
|
||||
throws NullPointerException, FileNotFoundException
|
||||
{
|
||||
if ( project == null )
|
||||
{
|
||||
throw new NullPointerException( "project should be set." );
|
||||
}
|
||||
|
||||
if ( groupId == null )
|
||||
{
|
||||
throw new NullPointerException( "groupId should be set." );
|
||||
}
|
||||
|
||||
if ( artifactId == null )
|
||||
{
|
||||
throw new NullPointerException( "artifactId should be set." );
|
||||
}
|
||||
|
||||
if ( version == null )
|
||||
{
|
||||
throw new NullPointerException( "version should be set." );
|
||||
}
|
||||
|
||||
final String dependencyId = groupId + ":" + artifactId + ":" + version;
|
||||
|
||||
final String relativePath = buildRelativePath();
|
||||
final File localFile = new File( project.getContext().getMavenRepoLocal(), relativePath );
|
||||
final String backwareCompatibleRelativePath = buildBackwardCompatibleRelativePath();
|
||||
final File backwardCompatibleLocalFile =
|
||||
new File( project.getContext().getMavenRepoLocal(), backwareCompatibleRelativePath );
|
||||
|
||||
boolean artifactFound;
|
||||
if ( isSnapshot() )
|
||||
{
|
||||
artifactFound = getRemoteArtifact( localFile, relativePath, dependencyId );
|
||||
if ( backwardCompatible )
|
||||
{
|
||||
artifactFound =
|
||||
getRemoteArtifact( backwardCompatibleLocalFile, backwareCompatibleRelativePath, dependencyId );
|
||||
}
|
||||
|
||||
// Do not go further if the artifact is in the local repository
|
||||
if ( localFile.exists() || ( backwardCompatible && backwardCompatibleLocalFile.exists() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( localFile.exists() || ( backwardCompatible && backwardCompatibleLocalFile.exists() ) )
|
||||
{
|
||||
log.debug( "source for " + dependencyId + " is available in the local repository." );
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// download it
|
||||
artifactFound = getRemoteArtifact( localFile, relativePath, dependencyId );
|
||||
if ( !artifactFound && backwardCompatible )
|
||||
{
|
||||
artifactFound =
|
||||
getRemoteArtifact( backwardCompatibleLocalFile, backwareCompatibleRelativePath, dependencyId );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !ignoreErrors && !artifactFound )
|
||||
{
|
||||
throw new FileNotFoundException( "Could not download source for " + dependencyId + " from any repository " +
|
||||
getProject().getContext().getMavenRepoRemote() );
|
||||
}
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
|
||||
public Project getProject()
|
||||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject( final Project project )
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public String getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId( final String groupId )
|
||||
{
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getArtifactId()
|
||||
{
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
public void setArtifactId( final String artifactId )
|
||||
{
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion( final String version )
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public boolean isIgnoreErrors()
|
||||
{
|
||||
return ignoreErrors;
|
||||
}
|
||||
|
||||
public void setIgnoreErrors( final boolean ignoreErrors )
|
||||
{
|
||||
this.ignoreErrors = ignoreErrors;
|
||||
}
|
||||
|
||||
public boolean isBackwardCompatible()
|
||||
{
|
||||
return backwardCompatible;
|
||||
}
|
||||
|
||||
public void setBackwardCompatible( final boolean backwardCompatible )
|
||||
{
|
||||
this.backwardCompatible = backwardCompatible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the relative path to the source archive.
|
||||
*
|
||||
* @return the relative path to the source archive
|
||||
*/
|
||||
private String buildRelativePath()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append( groupId ).append( "/java-sources/" ).append( artifactId ).append( "-" ).append( version ).append(
|
||||
"-sources.jar" );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the backware compatible relative path to the source archive.
|
||||
*
|
||||
* @return the backware compatible relative path to the source archive
|
||||
*/
|
||||
private String buildBackwardCompatibleRelativePath()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append( groupId ).append( "/src/" ).append( artifactId ).append( "-" ).append( version ).append( ".zip" );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether the source archive to download is a SNAPSHOT or not.
|
||||
*
|
||||
* @return true if the source archive is a SNAPSHOT, false otherwise
|
||||
*/
|
||||
private boolean isSnapshot()
|
||||
{
|
||||
return version.endsWith( "SNAPSHOT" );
|
||||
}
|
||||
|
||||
// Taken from maven core code in order to mimic the current behavior
|
||||
|
||||
/**
|
||||
* Retrieve a <code>remoteFile</code> from the maven remote repositories
|
||||
* and store it at <code>destinationFile</code>
|
||||
*
|
||||
* @param destinationFile the destination file in the local repository
|
||||
* @param relativePath the relative path to the dependency
|
||||
* @param dependencyId the dependency Id
|
||||
* @return true if the retrieval succeeds, false otherwise.
|
||||
*/
|
||||
private boolean getRemoteArtifact( File destinationFile, String relativePath, String dependencyId )
|
||||
{
|
||||
|
||||
// The directory structure for the project this dependency belongs to
|
||||
// may not exists so attempt to create the project directory structure
|
||||
// before attempting to download the dependency.
|
||||
File directory = destinationFile.getParentFile();
|
||||
|
||||
if ( !directory.exists() )
|
||||
{
|
||||
directory.mkdirs();
|
||||
}
|
||||
|
||||
log.info( "Attempting to download sources for " + dependencyId + " ("+relativePath+")" );
|
||||
|
||||
boolean artifactFound = false;
|
||||
|
||||
for ( Iterator i = getProject().getContext().getMavenRepoRemote().iterator(); i.hasNext(); )
|
||||
{
|
||||
String remoteRepo = (String) i.next();
|
||||
|
||||
if ( remoteRepo.endsWith( "/" ) )
|
||||
{
|
||||
remoteRepo = remoteRepo.substring( 0, remoteRepo.length() - 1 );
|
||||
}
|
||||
|
||||
// The username and password parameters are not being
|
||||
// used here. Those are the "" parameters you see below.
|
||||
String url = remoteRepo + "/" + relativePath;
|
||||
url = StringUtils.replace( url, "//", "/" );
|
||||
|
||||
if ( !url.startsWith( "file" ) )
|
||||
{
|
||||
if ( url.startsWith( "https" ) )
|
||||
{
|
||||
url = StringUtils.replace( url, "https:/", "https://" );
|
||||
}
|
||||
else
|
||||
{
|
||||
url = StringUtils.replace( url, "http:/", "http://" );
|
||||
}
|
||||
}
|
||||
log.debug( "Trying to download source at " + url );
|
||||
|
||||
// Attempt to retrieve the artifact and set the checksum if retrieval
|
||||
// of the checksum file was successful.
|
||||
try
|
||||
{
|
||||
String loginHost = (String) getProject().getContext().getVariable( PROXY_LOGINHOST );
|
||||
String loginDomain = (String) getProject().getContext().getVariable( PROXY_LOGINDOMAIN );
|
||||
HttpUtils.getFile( url, destinationFile, false, true, getProject().getContext().getProxyHost(),
|
||||
getProject().getContext().getProxyPort(),
|
||||
getProject().getContext().getProxyUserName(),
|
||||
getProject().getContext().getProxyPassword(), loginHost, loginDomain, true );
|
||||
|
||||
// Artifact was found, continue checking additional remote repos (if any)
|
||||
// in case there is a newer version (i.e. snapshots) in another repo
|
||||
artifactFound = true;
|
||||
|
||||
if ( !isSnapshot() )
|
||||
{
|
||||
log.info( "Downloded source for " + dependencyId + " at " + url );
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
// Multiple repositories may exist, and if the file is not found
|
||||
// in just one of them, it's no problem, and we don't want to
|
||||
// even print out an error.
|
||||
// if it's not found at all, artifactFound will be false, and the
|
||||
// build _will_ break, and the user will get an error message
|
||||
log.debug( "File not found on one of the repos", e );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// If there are additional remote repos, then ignore exception
|
||||
// as artifact may be found in another remote repo. If there
|
||||
// are no more remote repos to check and the artifact wasn't found in
|
||||
// a previous remote repo, then artifactFound is false indicating
|
||||
// that the artifact could not be found in any of the remote repos
|
||||
//
|
||||
// arguably, we need to give the user better control (another command-
|
||||
// line switch perhaps) of what to do in this case? Maven already has
|
||||
// a command-line switch to work in offline mode, but what about when
|
||||
// one of two or more remote repos is unavailable? There may be multiple
|
||||
// remote repos for redundancy, in which case you probably want the build
|
||||
// to continue. There may however be multiple remote repos because some
|
||||
// artifacts are on one, and some are on another. In this case, you may
|
||||
// want the build to break.
|
||||
//
|
||||
// print a warning, in any case, so user catches on to mistyped
|
||||
// hostnames, or other snafus
|
||||
// FIXME: localize this message
|
||||
String[] parsedUrl = HttpUtils.parseUrl( url );
|
||||
log.warn( "Error retrieving artifact from [" + parsedUrl[2] + "]: " + e );
|
||||
if ( parsedUrl[0] != null )
|
||||
{
|
||||
log.debug( "Username was '" + parsedUrl[0] + "', password hidden" );
|
||||
}
|
||||
log.debug( "Error details", e );
|
||||
}
|
||||
}
|
||||
|
||||
return artifactFound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>org.apache.maven.plugin.source</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Handles source archive artifact.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,56 @@
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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 xmlns:j="jelly:core"
|
||||
xmlns:u="jelly:util"
|
||||
xmlns:x="jelly:xml"
|
||||
xmlns:assert="assert"
|
||||
xmlns:maven="jelly:maven">
|
||||
|
||||
<preGoal name="java:compile">
|
||||
<!-- Invoke fake xdoclet plugin and update maven.compile.src.set -->
|
||||
<path id="fake.xdoclet.compile.src.set" location="src/xdoclet/java"/>
|
||||
<maven:addPath id="maven.compile.src.set" refid="fake.xdoclet.compile.src.set"/>
|
||||
</preGoal>
|
||||
|
||||
<goal name="testPlugin" prereqs="source:source,test-source">
|
||||
<attainGoal name="clean"/>
|
||||
</goal>
|
||||
|
||||
<goal name="test-source">
|
||||
|
||||
<j:set var="sourceFile" value="${maven.build.dir}/${maven.source.final.name}"/>
|
||||
<!-- tests that the source is generated -->
|
||||
<assert:assertFileExists file="${sourceFile}"/>
|
||||
|
||||
<!-- unzip the source and look for the App in the right package structure -->
|
||||
<j:set var="unzipDir" value= "${maven.build.dir}/sourceTest"/>
|
||||
<mkdir dir="${unzipDir}"/>
|
||||
<unzip src="${sourceFile}" dest="${unzipDir}"/>
|
||||
|
||||
<!-- check for source -->
|
||||
<assert:assertFileExists file="${unzipDir}/org/apache/maven/plugin/source/test/FakeSessionBean.java"
|
||||
msg="FakeSessionBean.java was not bundled"/>
|
||||
|
||||
<!-- check for generated code -->
|
||||
<assert:assertFileExists file="${unzipDir}/org/apache/maven/plugin/source/test/FakeSessionLocal.java"
|
||||
msg="FakeSessionLocal.java was not bundled"/>
|
||||
<assert:assertFileExists file="${unzipDir}/org/apache/maven/plugin/source/test/FakeSessionLocalHome.java"
|
||||
msg="FakeSessionLocalHome.java was not bundled"/>
|
||||
|
||||
</goal>
|
||||
</project>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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>
|
||||
<pomVersion>3</pomVersion>
|
||||
<id>test-maven-source-plugin-codeGenerationTest</id>
|
||||
<name>Code Generation Test Case for Maven Source Plugin</name>
|
||||
<groupId>maven</groupId>
|
||||
<currentVersion>1.0-SNAPSHOT</currentVersion>
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
<logo>http://maven.apache.org/images/apache-maven-project.png</logo>
|
||||
</organization>
|
||||
<inceptionYear>2006</inceptionYear>
|
||||
<package>org.apache.maven</package>
|
||||
<logo>http://maven.apache.org/images/maven.gif</logo>
|
||||
<description>Test for Maven Source plugin</description>
|
||||
<shortDescription>Test for Maven Source plugin</shortDescription>
|
||||
<url>http://maven.apache.org/maven-1.x/reference/plugins/source/</url>
|
||||
<siteDirectory>/www/maven.apache.org/maven-1.x/reference/plugins/source/</siteDirectory>
|
||||
<repository>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk/source/</connection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/maven/maven-1/plugins/trunk/source/</url>
|
||||
</repository>
|
||||
<build>
|
||||
<defaultGoal>testPlugin</defaultGoal>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package org.apache.maven.plugin.source.test;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:snicoll@apache.org">Stephane Nicoll</a>
|
||||
* @version $Id: App.java 232640 2005-08-14 20:46:54Z snicoll $
|
||||
*/
|
||||
public class FakeSessionBean
|
||||
{
|
||||
|
||||
// Only for testing purposes!!
|
||||
private FakeSessionLocal local;
|
||||
|
||||
public FakeSessionBean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package org.apache.maven.plugin.source.test;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:snicoll@apache.org">Stephane Nicoll</a>
|
||||
* @version $Id: App.java 232640 2005-08-14 20:46:54Z snicoll $
|
||||
*/
|
||||
public class FakeSessionLocal
|
||||
{
|
||||
// Fake just as if xdoclet generated it
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package org.apache.maven.plugin.source.test;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:snicoll@apache.org">Stephane Nicoll</a>
|
||||
* @version $Id: App.java 232640 2005-08-14 20:46:54Z snicoll $
|
||||
*/
|
||||
public class FakeSessionLocalHome
|
||||
{
|
||||
// Fake just as if xdoclet generated it
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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
|
||||
xmlns:maven="jelly:maven">
|
||||
|
||||
<goal name="testPlugin">
|
||||
<maven:reactor basedir="${basedir}"
|
||||
includes="*Test/project.xml"
|
||||
goals="testPlugin"
|
||||
banner="Test"
|
||||
ignoreFailures="false"/>
|
||||
</goal>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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>
|
||||
<pomVersion>3</pomVersion>
|
||||
<name>Test project for Maven Source Plugin</name>
|
||||
<groupId>maven</groupId>
|
||||
<currentVersion>1.0</currentVersion>
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
<logo>http://maven.apache.org/images/apache-maven-project.png</logo>
|
||||
</organization>
|
||||
<inceptionYear>2006</inceptionYear>
|
||||
<package>org.apache.maven</package>
|
||||
<logo>http://maven.apache.org/images/maven.gif</logo>
|
||||
<description>Test for Maven Source plugin</description>
|
||||
<shortDescription>Test for Maven Source plugin</shortDescription>
|
||||
<url>http://maven.apache.org/maven-1.x/reference/plugins/source/</url>
|
||||
<siteDirectory>/www/maven.apache.org/maven-1.x/reference/plugins/source/</siteDirectory>
|
||||
<repository>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk/source/</connection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/maven/maven-1/plugins/trunk/source/</url>
|
||||
</repository>
|
||||
<build>
|
||||
<defaultGoal>testPlugin</defaultGoal>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,43 @@
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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 xmlns:j="jelly:core"
|
||||
xmlns:u="jelly:util"
|
||||
xmlns:x="jelly:xml"
|
||||
xmlns:assert="assert">
|
||||
|
||||
<goal name="testPlugin" prereqs="source:source,test-source">
|
||||
<attainGoal name="clean"/>
|
||||
</goal>
|
||||
|
||||
<goal name="test-source">
|
||||
|
||||
<j:set var="sourceFile" value="${maven.build.dir}/${maven.source.final.name}"/>
|
||||
<!-- tests that the source is generated -->
|
||||
<assert:assertFileExists file="${sourceFile}"/>
|
||||
|
||||
<!-- unzip the source and look for the App in the right package structure -->
|
||||
<j:set var="unzipDir" value= "${maven.build.dir}/sourceTest"/>
|
||||
<mkdir dir="${unzipDir}"/>
|
||||
<unzip src="${sourceFile}" dest="${unzipDir}"/>
|
||||
|
||||
<!-- check for source -->
|
||||
<assert:assertFileExists file="${unzipDir}/org/apache/maven/plugin/source/test/App.java"
|
||||
msg="App.java was not bundled"/>
|
||||
|
||||
</goal>
|
||||
</project>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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>
|
||||
<pomVersion>3</pomVersion>
|
||||
<id>test-maven-source-plugin-simpleTest</id>
|
||||
<name>Simple Test Case for Maven Source Plugin</name>
|
||||
<groupId>maven</groupId>
|
||||
<currentVersion>1.0-SNAPSHOT</currentVersion>
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
<logo>http://maven.apache.org/images/apache-maven-project.png</logo>
|
||||
</organization>
|
||||
<inceptionYear>2006</inceptionYear>
|
||||
<package>org.apache.maven</package>
|
||||
<logo>http://maven.apache.org/images/maven.gif</logo>
|
||||
<description>Test for Maven Source plugin</description>
|
||||
<shortDescription>Test for Maven Source plugin</shortDescription>
|
||||
<url>http://maven.apache.org/maven-1.x/reference/plugins/source/</url>
|
||||
<siteDirectory>/www/maven.apache.org/maven-1.x/reference/plugins/source/</siteDirectory>
|
||||
<repository>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk/source/</connection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/maven/maven-1/plugins/trunk/source/</url>
|
||||
</repository>
|
||||
<build>
|
||||
<defaultGoal>testPlugin</defaultGoal>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package org.apache.maven.plugin.source.test;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:snicoll@apache.org">Stephane Nicoll</a>
|
||||
* @version $Id: App.java 232640 2005-08-14 20:46:54Z snicoll $
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.apache.maven.plugin.source;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.project.Project;
|
||||
import org.apache.maven.repository.ArtifactTypeHandler;
|
||||
import org.apache.maven.MavenException;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests the java source artifact type handler implementation.
|
||||
*
|
||||
* @author <a href="mailto:snicoll@apache.org">Stephane Nicoll</a>
|
||||
* @version $Id: JavaSourceArtifactTypeHandlerTest.java 232640 2005-08-14 20:46:54Z snicoll $
|
||||
*/
|
||||
public class JavaSourceArtifactTypeHandlerTest
|
||||
extends TestCase
|
||||
{
|
||||
private Project project;
|
||||
|
||||
private ArtifactTypeHandler handler;
|
||||
|
||||
private static final String VERSION = "VERSION";
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
project = new Project();
|
||||
project.setGroupId( "groupId" );
|
||||
project.setArtifactId( "artifactId" );
|
||||
handler = new JavaSourceArtifactTypeHandler();
|
||||
}
|
||||
|
||||
public void testConstructRepositoryDirectoryPath()
|
||||
throws Exception
|
||||
{
|
||||
assertEquals( "check artifact directory", "groupId/java-sources/",
|
||||
handler.constructRepositoryDirectoryPath( "java-source", project ) );
|
||||
}
|
||||
|
||||
public void testConstructRepositoryFullPath()
|
||||
throws Exception
|
||||
{
|
||||
assertEquals( "check artifact path", "groupId/java-sources/artifactId-VERSION-sources.jar",
|
||||
handler.constructRepositoryFullPath( "java-source", project, VERSION ) );
|
||||
}
|
||||
|
||||
public void testConstructRepositoryFullPathWithInvalidType()
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
handler.constructRepositoryFullPath( "foo", project, VERSION );
|
||||
fail( "expected exception" );
|
||||
}
|
||||
catch ( MavenException expected )
|
||||
{
|
||||
assertEquals( "Unrecognised java-source type (is foo)", expected.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user