mirror of https://github.com/apache/maven.git
PR: MNG-1001
Submitted by: Johnny R. Ruiz III add VCS section based on scm URL git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@327911 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0df347f0e5
commit
c6b56c0e4e
|
@ -113,23 +113,45 @@ public class IdeaMojo
|
|||
throws MojoExecutionException
|
||||
{
|
||||
File workspaceFile = new File( project.getBasedir(), project.getArtifactId() + ".iws" );
|
||||
if ( !workspaceFile.exists() )
|
||||
{
|
||||
FileWriter w = null;
|
||||
try
|
||||
{
|
||||
w = new FileWriter( workspaceFile );
|
||||
IOUtil.copy( getClass().getResourceAsStream( "/templates/default/workspace.xml" ), w );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Unable to create workspace file", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( w );
|
||||
}
|
||||
|
||||
FileWriter writer = null;
|
||||
|
||||
Reader reader = null;
|
||||
|
||||
Xpp3Dom module = null;
|
||||
|
||||
try
|
||||
{
|
||||
if ( workspaceFile.exists() )
|
||||
{
|
||||
reader = new FileReader( workspaceFile );
|
||||
}
|
||||
else
|
||||
{
|
||||
reader = new InputStreamReader( getClass().getResourceAsStream( "/templates/default/workspace.xml" ) );
|
||||
}
|
||||
module = Xpp3DomBuilder.build( reader );
|
||||
|
||||
setProjectScmType( module );
|
||||
|
||||
writer = new FileWriter( workspaceFile );
|
||||
|
||||
Xpp3DomWriter.write( writer, module );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Error parsing existing IWS file: " + workspaceFile.getAbsolutePath(),
|
||||
e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Unable to create workspace file", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(reader);
|
||||
|
||||
IOUtil.close( writer );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -609,6 +631,29 @@ Can't run this anyway as Xpp3Dom is in both classloaders...
|
|||
return setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a an Xpp3Dom element with (child) tag name and (name) attribute name.
|
||||
*
|
||||
* @param component Xpp3Dom element
|
||||
* @param name Setting attribute to find
|
||||
* @return option Xpp3Dom element
|
||||
*/
|
||||
private Xpp3Dom findElementName( Xpp3Dom component, String child, String name )
|
||||
{
|
||||
Xpp3Dom[] elements = component.getChildren( child );
|
||||
for ( int i = 0; i < elements.length; i++ )
|
||||
{
|
||||
if ( name.equals( elements[i].getAttribute( "name" ) ) )
|
||||
{
|
||||
return elements[i];
|
||||
}
|
||||
}
|
||||
|
||||
Xpp3Dom element = createElement( component, child );
|
||||
element.setAttribute( "name", name );
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Xpp3Dom element.
|
||||
*
|
||||
|
@ -640,4 +685,76 @@ Can't run this anyway as Xpp3Dom is in both classloaders...
|
|||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SCM type of the project
|
||||
*
|
||||
*/
|
||||
private void setProjectScmType( Xpp3Dom content )
|
||||
{
|
||||
String scmType = null;
|
||||
|
||||
scmType = getScmType();
|
||||
|
||||
if ( scmType != null )
|
||||
{
|
||||
Xpp3Dom component = findComponent( content, "VcsManagerConfiguration" );
|
||||
|
||||
Xpp3Dom element = findElementName( component, "option" , "ACTIVE_VCS_NAME" );
|
||||
|
||||
element.setAttribute( "value", scmType );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* used to retrieve the SCM Type
|
||||
*
|
||||
* @return the Scm Type string used to connect to the SCM
|
||||
*/
|
||||
protected String getScmType()
|
||||
{
|
||||
String scmType = null;
|
||||
|
||||
if ( project.getScm() == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
scmType = getScmType( project.getScm().getConnection() );
|
||||
|
||||
if ( scmType != null )
|
||||
{
|
||||
return scmType;
|
||||
}
|
||||
scmType = getScmType( project.getScm().getDeveloperConnection() );
|
||||
|
||||
return scmType;
|
||||
}
|
||||
|
||||
protected String getScmType( String connection )
|
||||
{
|
||||
String scmType = null;
|
||||
|
||||
if ( connection != null )
|
||||
{
|
||||
if ( connection.length() > 0 )
|
||||
{
|
||||
int startIndex = connection.indexOf( ":" );
|
||||
|
||||
int endIndex = connection.indexOf( ":", startIndex + 1);
|
||||
|
||||
if ( startIndex < endIndex )
|
||||
{
|
||||
scmType = connection.substring( startIndex + 1, endIndex);
|
||||
|
||||
return scmType;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProject( MavenProject project )
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,50 +199,49 @@
|
|||
<option name="AUTO_SHOW_ERRORS_IN_EDITOR" value="true"/>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<option name="SHOW_SETTINGS_BEFORE_RUNNING" value="true"/>
|
||||
<option name="COMPILE_BEFORE_RUNNING" value="true"/>
|
||||
<activeType name="Application"/>
|
||||
<configuration name="<template>" type="Application" default="true" selected="false">
|
||||
<option name="MAIN_CLASS_NAME"/>
|
||||
<option name="VM_PARAMETERS"/>
|
||||
<option name="PROGRAM_PARAMETERS"/>
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$"/>
|
||||
<activeType name="Application" />
|
||||
<configuration selected="false" default="true" type="Applet" factoryName="Applet">
|
||||
<module name="" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="HTML_FILE_NAME" />
|
||||
<option name="HTML_USED" value="false" />
|
||||
<option name="WIDTH" value="400" />
|
||||
<option name="HEIGHT" value="300" />
|
||||
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
</configuration>
|
||||
<configuration name="<template>" type="Applet" default="true" selected="false">
|
||||
<option name="MAIN_CLASS_NAME"/>
|
||||
<option name="HTML_FILE_NAME"/>
|
||||
<option name="HTML_USED" value="false"/>
|
||||
<option name="WIDTH" value="400"/>
|
||||
<option name="HEIGHT" value="300"/>
|
||||
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy"/>
|
||||
<option name="VM_PARAMETERS"/>
|
||||
<configuration selected="false" default="true" type="Remote" factoryName="Remote">
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" value="javadebug" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="5005" />
|
||||
</configuration>
|
||||
<configuration name="<template>" type="JUnit" default="true" selected="false">
|
||||
<option name="PACKAGE_NAME"/>
|
||||
<option name="MAIN_CLASS_NAME"/>
|
||||
<option name="METHOD_NAME"/>
|
||||
<option name="TEST_OBJECT"/>
|
||||
<option name="VM_PARAMETERS"/>
|
||||
<option name="PARAMETERS"/>
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$"/>
|
||||
<option name="ADDITIONAL_CLASS_PATH"/>
|
||||
<configuration selected="false" default="true" type="Application" factoryName="Application">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<module name="" />
|
||||
</configuration>
|
||||
<configuration name="<template>" type="Remote" default="true" selected="false">
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true"/>
|
||||
<option name="SERVER_MODE" value="false"/>
|
||||
<option name="SHMEM_ADDRESS" value="javadebug"/>
|
||||
<option name="HOST" value="localhost"/>
|
||||
<option name="PORT" value="5005"/>
|
||||
</configuration>
|
||||
<configuration name="<template>" type="WebApp" default="true" selected="false">
|
||||
<WebServerIntegration name=""/>
|
||||
<Host>localhost</Host>
|
||||
<Port>5050</Port>
|
||||
<LaunchServer>false</LaunchServer>
|
||||
<configuration selected="false" default="true" type="JUnit" factoryName="JUnit">
|
||||
<module name="" />
|
||||
<option name="PACKAGE_NAME" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="METHOD_NAME" />
|
||||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="ADDITIONAL_CLASS_PATH" />
|
||||
<option name="TEST_SEARCH_SCOPE">
|
||||
<value defaultName="wholeProject" />
|
||||
</option>
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ACTIVE_VCS_NAME" value=""/> <!-- TODO: CVS value -->
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ACTIVE_VCS_NAME" value="" />
|
||||
<option name="STATE" value="0" />
|
||||
</component>
|
||||
<component name="VssConfiguration">
|
||||
<CheckoutOptions>
|
||||
|
@ -314,4 +313,105 @@
|
|||
<option name="LAST_COMMIT_MESSAGE" value=""/>
|
||||
<option name="CHECKIN_DIALOG_SPLITTER_PROPORTION" value="0.8"/>
|
||||
</component>
|
||||
<component name="Cvs2Configuration">
|
||||
<option name="ON_FILE_ADDING" value="0" />
|
||||
<option name="ON_FILE_REMOVING" value="0" />
|
||||
<option name="PRUNE_EMPTY_DIRECTORIES" value="true" />
|
||||
<option name="SHOW_UPDATE_OPTIONS" value="true" />
|
||||
<option name="SHOW_ADD_OPTIONS" value="true" />
|
||||
<option name="SHOW_REMOVE_OPTIONS" value="true" />
|
||||
<option name="MERGING_MODE" value="0" />
|
||||
<option name="MERGE_WITH_BRANCH1_NAME" value="HEAD" />
|
||||
<option name="MERGE_WITH_BRANCH2_NAME" value="HEAD" />
|
||||
<option name="RESET_STICKY" value="false" />
|
||||
<option name="CREATE_NEW_DIRECTORIES" value="true" />
|
||||
<option name="DEFAULT_TEXT_FILE_SUBSTITUTION" value="kv" />
|
||||
<option name="PROCESS_UNKNOWN_FILES" value="false" />
|
||||
<option name="PROCESS_DELETED_FILES" value="false" />
|
||||
<option name="SHOW_EDIT_DIALOG" value="true" />
|
||||
<option name="RESERVED_EDIT" value="false" />
|
||||
<option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
|
||||
<option name="SHOW_CHECKOUT_OPTIONS" value="true" />
|
||||
<option name="CHECKOUT_DATE_OR_REVISION_SETTINGS">
|
||||
<value>
|
||||
<option name="BRANCH" value="" />
|
||||
<option name="DATE" value="" />
|
||||
<option name="USE_BRANCH" value="false" />
|
||||
<option name="USE_DATE" value="false" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="UPDATE_DATE_OR_REVISION_SETTINGS">
|
||||
<value>
|
||||
<option name="BRANCH" value="" />
|
||||
<option name="DATE" value="" />
|
||||
<option name="USE_BRANCH" value="false" />
|
||||
<option name="USE_DATE" value="false" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="SHOW_CHANGES_REVISION_SETTINGS">
|
||||
<value>
|
||||
<option name="BRANCH" value="" />
|
||||
<option name="DATE" value="" />
|
||||
<option name="USE_BRANCH" value="false" />
|
||||
<option name="USE_DATE" value="false" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="SHOW_OUTPUT" value="false" />
|
||||
<option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
|
||||
<option name="UPDATE_GROUP_BY_PACKAGES" value="false" />
|
||||
<option name="ADD_WATCH_INDEX" value="0" />
|
||||
<option name="REMOVE_WATCH_INDEX" value="0" />
|
||||
<option name="UPDATE_KEYWORD_SUBSTITUTION" />
|
||||
<option name="MAKE_NEW_FILES_READONLY" value="false" />
|
||||
<option name="SHOW_CORRUPTED_PROJECT_FILES" value="0" />
|
||||
<option name="TAG_AFTER_FILE_COMMIT" value="false" />
|
||||
<option name="TAG_AFTER_FILE_COMMIT_NAME" value="" />
|
||||
<option name="TAG_AFTER_PROJECT_COMMIT" value="false" />
|
||||
<option name="TAG_AFTER_PROJECT_COMMIT_NAME" value="" />
|
||||
<option name="PUT_FOCUS_INTO_COMMENT" value="false" />
|
||||
<option name="SHOW_CHECKIN_OPTIONS" value="true" />
|
||||
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="" />
|
||||
<option name="SAVE_LAST_COMMIT_MESSAGE" value="true" />
|
||||
<option name="CHECKIN_DIALOG_SPLITTER_PROPORTION" value="0.8" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_FILE_COMMIT" value="false" />
|
||||
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<option name="REFORMAT_BEFORE_FILE_COMMIT" value="false" />
|
||||
<option name="FILE_HISTORY_DIALOG_COMMENTS_SPLITTER_PROPORTION" value="0.8" />
|
||||
<option name="FILE_HISTORY_DIALOG_SPLITTER_PROPORTION" value="0.5" />
|
||||
</component>
|
||||
<component name="CvsTabbedWindow" />
|
||||
<component name="SvnConfiguration">
|
||||
<option name="USER" value="" />
|
||||
<option name="PASSWORD" value="" />
|
||||
<option name="AUTO_ADD_FILES" value="0" />
|
||||
<option name="AUTO_DEL_FILES" value="0" />
|
||||
</component>
|
||||
<component name="PerforceConfiguration">
|
||||
<option name="PORT" value="magic:1666" />
|
||||
<option name="USER" value="" />
|
||||
<option name="PASSWORD" value="" />
|
||||
<option name="CLIENT" value="" />
|
||||
<option name="TRACE" value="false" />
|
||||
<option name="PERFORCE_STATUS" value="true" />
|
||||
<option name="CHANGELIST_OPTION" value="false" />
|
||||
<option name="SYSTEMROOT" value="" />
|
||||
<option name="P4_EXECUTABLE" value="p4" />
|
||||
<option name="SHOW_BRANCH_HISTORY" value="false" />
|
||||
<option name="GENERATE_COMMENT" value="false" />
|
||||
<option name="SYNC_OPTION" value="Sync" />
|
||||
<option name="PUT_FOCUS_INTO_COMMENT" value="false" />
|
||||
<option name="SHOW_CHECKIN_OPTIONS" value="true" />
|
||||
<option name="FORCE_NON_EMPTY_COMMENT" value="true" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="" />
|
||||
<option name="SAVE_LAST_COMMIT_MESSAGE" value="true" />
|
||||
<option name="CHECKIN_DIALOG_SPLITTER_PROPORTION" value="0.8" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_FILE_COMMIT" value="false" />
|
||||
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<option name="REFORMAT_BEFORE_FILE_COMMIT" value="false" />
|
||||
<option name="FILE_HISTORY_DIALOG_COMMENTS_SPLITTER_PROPORTION" value="0.8" />
|
||||
<option name="FILE_HISTORY_DIALOG_SPLITTER_PROPORTION" value="0.5" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package org.apache.maven.plugin.idea;
|
||||
|
||||
/*
|
||||
* 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 junit.framework.TestCase;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Scm;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jruiz@exist.com">Johnny R. Ruiz III</a>
|
||||
* @version $Id:
|
||||
*/
|
||||
public class IdeaMojoTest
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
/*
|
||||
* Test method for 'org.apache.maven.plugin.idea.IdeaMojo.getScmType()'
|
||||
*/
|
||||
public void testGetScmType()
|
||||
{
|
||||
MavenProject project = new MavenProject( new Model() );
|
||||
|
||||
Scm scm = new Scm();
|
||||
|
||||
scm.setConnection( "scm:svn:svn://svn.codehaus.org/mojo/scm/trunk/" );
|
||||
|
||||
project.setScm( scm );
|
||||
|
||||
IdeaMojo idea = new IdeaMojo();
|
||||
|
||||
idea.setProject( project );
|
||||
|
||||
assertEquals( "svn", idea.getScmType() );
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'org.apache.maven.plugin.idea.IdeaMojo.getScmType(String)'
|
||||
*/
|
||||
public void testGetScmTypeString()
|
||||
{
|
||||
IdeaMojo idea = new IdeaMojo();
|
||||
|
||||
assertEquals( "svn", idea.getScmType( "scm:svn:svn://svn.codehaus.org/mojo/scm/trunk/" ) );
|
||||
|
||||
assertEquals( null, idea.getScmType( "scm:svn" ) );
|
||||
|
||||
assertEquals( null, idea.getScmType( null ) );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue