You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2007/08/07 14:05:59 UTC
svn commit: r563461 - in /maven/continuum/trunk:
continuum-api/src/main/java/org/apache/maven/continuum/installation/
continuum-core/src/main/java/org/apache/maven/continuum/installation/
continuum-core/src/test/java/org/apache/maven/continuum/installa...
Author: evenisse
Date: Tue Aug 7 05:05:58 2007
New Revision: 563461
URL: http://svn.apache.org/viewvc?view=rev&rev=563461
Log:
[CONTINUUM-1363] create "automatic" profiles for each installation for simpler configuration by JDK, etc.
Submitted by: Olivier Lamy
Modified:
maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/installation/InstallationService.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp
Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/installation/InstallationService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/installation/InstallationService.java?view=diff&rev=563461&r1=563460&r2=563461
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/installation/InstallationService.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/installation/InstallationService.java Tue Aug 7 05:05:58 2007
@@ -43,8 +43,11 @@
String ENVVAR_TYPE = "envvar";
- public Installation add( Installation installation )
+ public Installation add( Installation installation, boolean automaticProfile )
throws InstallationException;
+
+ public Installation add( Installation installation )
+ throws InstallationException;
public void update( Installation installation )
throws InstallationException;
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java?view=diff&rev=563461&r1=563460&r2=563461
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java Tue Aug 7 05:05:58 2007
@@ -21,6 +21,9 @@
import org.apache.maven.continuum.execution.ExecutorConfigurator;
import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.model.system.Profile;
+import org.apache.maven.continuum.profile.ProfileException;
+import org.apache.maven.continuum.profile.ProfileService;
import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -56,6 +59,11 @@
* @plexus.requirement role-hint="jdo"
*/
private ContinuumStore store;
+
+ /**
+ * @plexus.requirement role-hint="default"
+ */
+ private ProfileService profileService;
private Map<String, ExecutorConfigurator> typesValues;
@@ -85,6 +93,16 @@
public Installation add( Installation installation )
throws InstallationException
{
+ return this.add( installation, false );
+
+ }
+
+ public Installation add( Installation installation, boolean automaticProfile )
+ throws InstallationException
+ {
+
+ // TODO must be done in the same transaction
+ Installation storedOne = null;
try
{
String envVarName = this.getEnvVar( installation.getType() );
@@ -93,12 +111,27 @@
{
installation.setVarName( envVarName );
}
- return store.addInstallation( installation );
+ storedOne = store.addInstallation( installation );
}
catch ( ContinuumStoreException e )
{
throw new InstallationException( e.getMessage(), e );
}
+ try
+ {
+ if ( automaticProfile )
+ {
+ Profile profile = new Profile();
+ profile.setName( storedOne.getName() );
+ profile = profileService.addProfile( profile );
+ profileService.addEnvVarInProfile( profile, storedOne );
+ }
+ }
+ catch ( ProfileException e )
+ {
+ throw new InstallationException( "failed to create automatic Profile " + e.getMessage(), e );
+ }
+ return storedOne;
}
/**
@@ -107,7 +140,6 @@
public void delete( Installation installation )
throws InstallationException
{
- // TODO remove the installations attached to profiles : jdo failed
try
{
store.removeInstallation( installation );
Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java?view=diff&rev=563461&r1=563460&r2=563461
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java Tue Aug 7 05:05:58 2007
@@ -1,12 +1,14 @@
package org.apache.maven.continuum.installation;
+import java.util.List;
+
import org.apache.maven.continuum.AbstractContinuumTest;
import org.apache.maven.continuum.execution.ExecutorConfigurator;
import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.model.system.Profile;
+import org.apache.maven.continuum.profile.ProfileService;
import org.apache.maven.continuum.store.ContinuumStore;
-import java.util.List;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -176,5 +178,22 @@
String javaHome = System.getProperty( "M2_HOME" );
List<String> infos = installationService.getExecutorConfiguratorVersion( javaHome, java );
assertNotNull( infos );
+ }
+
+ public void testAddInstallationAutomaticProfile()
+ throws Exception
+ {
+
+ Installation installation = new Installation();
+ installation.setType( InstallationService.JDK_TYPE );
+ installation.setName( "automatic" );
+ installation.setVarName( "automaticvarName" );
+ installation.setVarValue( "automaticvarValue" );
+ installation = getInstallationService().add( installation, true );
+ ProfileService profileService = (ProfileService) lookup( ProfileService.ROLE, "default" );
+ List<Profile> profiles = profileService.getAllProfiles();
+ assertEquals( 1, profiles.size() );
+ Profile profile = (Profile) profiles.get( 0 );
+ assertEquals( "automatic", profile.getName() );
}
}
Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java?view=diff&rev=563461&r1=563460&r2=563461
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java Tue Aug 7 05:05:58 2007
@@ -49,13 +49,15 @@
private Installation installation;
- private Map typesLabels;
+ private Map<String, String> typesLabels;
- private List types;
+ private List<String> types;
private boolean varNameUpdatable = true;
private boolean nameUpdatable = true;
+
+ private boolean automaticProfile;
// -----------------------------------------------------
// Webwork methods
@@ -103,7 +105,7 @@
Installation installationToSave = installationService.getInstallation( this.installation.getName() );
if ( installationToSave == null )
{
- installationService.add( installation );
+ installationService.add( installation, this.automaticProfile );
}
else
{
@@ -148,7 +150,7 @@
this.installation = installation;
}
- public Map getTypesLabels()
+ public Map<String, String> getTypesLabels()
{
if ( this.typesLabels == null )
{
@@ -168,7 +170,7 @@
return typesLabels;
}
- public void setTypesLabels( Map typesLabels )
+ public void setTypesLabels( Map<String, String> typesLabels )
{
this.typesLabels = typesLabels;
}
@@ -183,11 +185,11 @@
this.varNameUpdatable = varNameUpdatable;
}
- public List getTypes()
+ public List<String> getTypes()
{
if ( this.types == null )
{
- this.types = new ArrayList();
+ this.types = new ArrayList<String>(5);
this.types.add( InstallationService.JDK_TYPE );
this.types.add( InstallationService.MAVEN2_TYPE );
this.types.add( InstallationService.MAVEN1_TYPE );
@@ -198,7 +200,7 @@
return types;
}
- public void setTypes( List types )
+ public void setTypes( List<String> types )
{
this.types = types;
}
@@ -211,6 +213,16 @@
public void setNameUpdatable( boolean nameUpdatable )
{
this.nameUpdatable = nameUpdatable;
+ }
+
+ public boolean isAutomaticProfile()
+ {
+ return automaticProfile;
+ }
+
+ public void setAutomaticProfile( boolean automaticProfile )
+ {
+ this.automaticProfile = automaticProfile;
}
}
Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?view=diff&rev=563461&r1=563460&r2=563461
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties Tue Aug 7 05:05:58 2007
@@ -620,6 +620,7 @@
installation.maven1.type.label = Maven 1
installation.envvar.type.label = Environment Variable
installation.ant.type.label = ANT
+installation.automaticProfile.label=Create a Profile with the installation name
Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp?view=diff&rev=563461&r1=563460&r2=563461
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp Tue Aug 7 05:05:58 2007
@@ -67,8 +67,9 @@
</ww:else>
<ww:textfield label="%{getText('installation.value.label')}" name="installation.varValue"
required="true"/>
-
-
+ <ww:if test="installation == null">
+ <ww:checkbox label="%{getText('installation.automaticProfile.label')}" name="automaticProfile" />
+ </ww:if>
</tbody>
</table>
<div class="functnbar3">