From 0594bdc6af0e68d413cf33c22b1cc1a21469dc67 Mon Sep 17 00:00:00 2001 From: Tom Huybrechts Date: Thu, 23 Sep 2010 21:05:39 -0700 Subject: [PATCH 0001/2361] added ignore --- war/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100755 war/.gitignore diff --git a/war/.gitignore b/war/.gitignore new file mode 100755 index 0000000000..22de730a7d --- /dev/null +++ b/war/.gitignore @@ -0,0 +1 @@ +work -- GitLab From dceafbbf7b37ad8bf7b7bf2c25f76b0ce4d8336a Mon Sep 17 00:00:00 2001 From: olamy Date: Thu, 4 Nov 2010 22:39:27 +0000 Subject: [PATCH 0002/2361] [HUDSON-4988] push some stuff to be able to get in an other place (sure git could be better :-) ) some issue when using maven 2 some stuff to do more in maven 3 build (recording mojo execution etc...) git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36643 71c3de6d-444a-0410-be80-ed276b4c234a --- core/pom.xml | 1 - core/src/main/java/hudson/PluginManager.java | 7 + maven-agent/pom.xml | 37 +- .../main/java/hudson/maven/agent/Main.java | 242 ++- .../hudson/maven/agent/classworlds-2.0.6.conf | 4 + .../hudson/maven/agent/classworlds.conf | 6 +- maven-interceptor/pom.xml | 14 +- .../maven/agent/DefaultPluginManager.java | 1546 +++++++++++++++++ .../maven/agent/PluginManagerInterceptor.java | 1 - maven-plugin/pom.xml | 357 ++-- .../hudson/maven/AbstractMavenBuilder.java | 88 + .../java/hudson/maven/EmbedderLoggerImpl.java | 21 +- .../main/java/hudson/maven/Maven3Builder.java | 328 ++++ .../hudson/maven/Maven3ProcessFactory.java | 396 +++++ .../main/java/hudson/maven/MavenBuilder.java | 112 +- .../hudson/maven/MavenComputerListener.java | 13 +- .../hudson/maven/MavenModuleSetBuild.java | 120 +- .../hudson/maven/MavenProcessFactory.java | 25 +- .../src/main/java/hudson/maven/MavenUtil.java | 78 +- .../hudson/maven/MavenVersionCallable.java | 63 + .../src/main/java/hudson/maven/MojoInfo.java | 4 +- .../java/hudson/maven/RedeployPublisher.java | 16 +- .../MavenAbstractArtifactRecord.java | 31 +- .../MavenAggregatedArtifactRecord.java | 9 +- .../hudson/maven/reporters/MavenArtifact.java | 15 +- .../maven/reporters/MavenArtifactRecord.java | 25 +- maven3-agent/.gitignore | 5 + maven3-agent/pom.xml | 37 + .../jvnet/hudson/maven3/agent/Maven3Main.java | 177 ++ .../maven3/agent/RealFilterOutputStream.java | 51 + .../hudson/maven3/agent/classworlds.conf | 11 + maven3-listener/.gitignore | 5 + maven3-listener/pom.xml | 55 + .../DefaultMavenExecutionRequestBuilder.java | 792 +++++++++ .../cli/MavenExecutionRequestBuilder.java | 36 + ...avenExecutionRequestsBuilderException.java | 33 + .../maven3/launcher/Maven3Launcher.java | 118 ++ .../listeners/HudsonMavenExecutionResult.java | 61 + .../listeners/MavenProjectBuildResult.java | 50 + .../maven3/listeners/MavenProjectInfo.java | 119 ++ pom.xml | 84 +- .../java/hudson/remoting/UserRequest.java | 2 + .../org/jvnet/hudson/test/HudsonTestCase.java | 5 +- 43 files changed, 4837 insertions(+), 363 deletions(-) create mode 100644 maven-interceptor/src/main/java/hudson/maven/agent/DefaultPluginManager.java create mode 100644 maven-plugin/src/main/java/hudson/maven/AbstractMavenBuilder.java create mode 100644 maven-plugin/src/main/java/hudson/maven/Maven3Builder.java create mode 100644 maven-plugin/src/main/java/hudson/maven/Maven3ProcessFactory.java create mode 100644 maven-plugin/src/main/java/hudson/maven/MavenVersionCallable.java create mode 100755 maven3-agent/.gitignore create mode 100755 maven3-agent/pom.xml create mode 100755 maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java create mode 100755 maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/RealFilterOutputStream.java create mode 100755 maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf create mode 100755 maven3-listener/.gitignore create mode 100755 maven3-listener/pom.xml create mode 100755 maven3-listener/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java create mode 100755 maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java create mode 100755 maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java create mode 100755 maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java create mode 100755 maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java create mode 100755 maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java create mode 100755 maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java diff --git a/core/pom.xml b/core/pom.xml index 0d0c407a4b..f28f19630c 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -461,7 +461,6 @@ THE SOFTWARE. org.apache.ant ant - 1.8.0 javax.servlet diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 3784009fca..4a7c9cb03c 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -626,6 +626,13 @@ public abstract class PluginManager extends AbstractModelObject { } return Collections.enumeration(resources); } + + @Override + public String toString() + { + // only for debugging purpose + return "classLoader " + getClass().getName(); + } } private static final Logger LOGGER = Logger.getLogger(PluginManager.class.getName()); diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index e473dc8ce8..a3c29b4cdf 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -73,25 +73,52 @@ THE SOFTWARE. org.jvnet.hudson.main maven-interceptor ${project.version} + + + org.codehaus.plexus + plexus-classworlds + + - classworlds - classworlds - 1.1 - + org.codehaus.plexus + plexus-classworlds + + + org.apache.ant + ant + commons-httpclient commons-httpclient 3.1-rc1 + + + org.apache.ant + ant + 1.8.0 + org.apache.maven maven-core - ${maven.version} + 2.0.9 test + + + classworlds + classworlds + + org.jvnet.hudson.main diff --git a/maven-agent/src/main/java/hudson/maven/agent/Main.java b/maven-agent/src/main/java/hudson/maven/agent/Main.java index 27cd4c7c2a..f6f8837fff 100644 --- a/maven-agent/src/main/java/hudson/maven/agent/Main.java +++ b/maven-agent/src/main/java/hudson/maven/agent/Main.java @@ -23,25 +23,36 @@ */ package hudson.maven.agent; -import org.codehaus.classworlds.ClassRealm; -import org.codehaus.classworlds.ClassWorld; -import org.codehaus.classworlds.DefaultClassRealm; -import org.codehaus.classworlds.Launcher; -import org.codehaus.classworlds.NoSuchRealmException; - +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; +import java.io.FilenameFilter; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; import java.net.Socket; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.apache.tools.ant.AntClassLoader; +import org.codehaus.classworlds.ClassWorldAdapter; +import org.codehaus.plexus.classworlds.ClassWorld; +import org.codehaus.plexus.classworlds.launcher.ConfigurationException; +import org.codehaus.plexus.classworlds.launcher.Launcher; +import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; +import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; + + /** * Entry point for launching Maven and Hudson remoting in the same VM, * in the classloader layout that Maven expects. @@ -100,26 +111,43 @@ public class Main { // I don't know how classworlds react to undefined variable, so (interceptorOverrideJar!=null?interceptorOverrideJar:interceptorJar).getPath()); + // FIXME change stuff for 206 earlier ! + boolean is206OrLater = !new File(m2Home,"core").exists(); - + + // load the default realms launcher = new Launcher(); launcher.setSystemClassLoader(Main.class.getClassLoader()); - launcher.configure(Main.class.getResourceAsStream( - is206OrLater?"classworlds-2.0.6.conf":"classworlds.conf")); - + + configureLauncher( m2Home, remotingJar, interceptorJar, interceptorOverrideJar, is206OrLater ); + + System.out.println( "realms size " + launcher.getWorld().getRealms().size() ); + for (Iterator iter = launcher.getWorld().getRealms().iterator();iter.hasNext();) + { + ClassRealm realm = (ClassRealm) iter.next(); + System.out.println( "realm " + realm + " urls " + Arrays.asList( realm.getURLs() ) ); + } + // have it eventually delegate to this class so that this can be visible - // create a realm for loading remoting subsystem. // this needs to be able to see maven. - ClassRealm remoting = new DefaultClassRealm(launcher.getWorld(),"hudson-remoting", launcher.getSystemClassLoader()); - remoting.setParent(launcher.getWorld().getRealm("plexus.core.maven")); - remoting.addConstituent(remotingJar.toURI().toURL()); + + System.out.print( "Main classLoader " + Main.class.getClassLoader() ); + //test en changeant le parent en plexus.core.maven ? + ClassRealm remoting = launcher.getWorld().newRealm( "hudson-remoting", launcher.getWorld().getClassRealm( "plexus.core" ) ); + remoting.importFrom( "plexus.core.maven", "org.apache.maven" ); + //remoting.setParentClassLoader( launcher.getWorld().getClassRealm( "plexus.core.maven" ) ); + remoting.addURL(remotingJar.toURI().toURL()); final Socket s = new Socket((String)null,tcpPort); + Class remotingLauncher = remoting.loadClass("hudson.remoting.Launcher"); - remotingLauncher.getMethod("main",new Class[]{InputStream.class,OutputStream.class}).invoke(null, + + Method mainMethod = remotingLauncher.getMethod("main",new Class[]{InputStream.class,OutputStream.class}); + + mainMethod.invoke(null, new Object[]{ // do partial close, since socket.getInputStream and getOutputStream doesn't do it by new BufferedInputStream(new FilterInputStream(s.getInputStream()) { @@ -133,6 +161,7 @@ public class Main { } }) }); + System.out.println(" remoting classLoader " + remoting.toString() ); System.exit(0); } @@ -153,17 +182,129 @@ public class Main { } } } + + /** + * old one + * @throws ConfigurationException + * @throws IOException + * @throws NoSuchRealmException + * @throws DuplicateRealmException + */ + private static void configureLauncher(File m2Home, File remotingJar, File interceptorJar, File interceptorOverrideJar, boolean is206OrLater) + throws DuplicateRealmException, NoSuchRealmException, IOException, ConfigurationException { + + launcher.configure(Main.class.getResourceAsStream(is206OrLater?"classworlds-2.0.6.conf":"classworlds.conf")); + } + /** + * with various classLoader hierarchy stuff + * @throws MalformedURLException + * @throws DuplicateRealmException + */ + private static void configureLauncher2(File m2Home, File remotingJar, File interceptorJar, File interceptorOverrideJar, boolean is206OrLater) + throws MalformedURLException, DuplicateRealmException { + ClassWorld world = new ClassWorld(); + launcher.setWorld( world ); + ClassRealm plexusCore = world.newRealm( "plexus.core" ); + plexusCore.setParentClassLoader( Main.class.getClassLoader() ); + File mavenCore = new File(m2Home, is206OrLater ? "boot" : "core"); + + String[] coreJars = mavenCore.list( new FilenameFilter() + { + + public boolean accept( File dir, String name ) + { + return name.endsWith( ".jar" ); + } + }); + + for (int i = 0,size = coreJars.length;i org.apache.maven maven-core - ${maven.version} + 2.0.9 + provided + + + classworlds + classworlds + + + + + org.codehaus.plexus + plexus-classworlds + diff --git a/maven-interceptor/src/main/java/hudson/maven/agent/DefaultPluginManager.java b/maven-interceptor/src/main/java/hudson/maven/agent/DefaultPluginManager.java new file mode 100644 index 0000000000..2bbc34d261 --- /dev/null +++ b/maven-interceptor/src/main/java/hudson/maven/agent/DefaultPluginManager.java @@ -0,0 +1,1546 @@ + +package hudson.maven.agent; + +/* + * 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 java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.maven.MavenArtifactFilterManager; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.metadata.ResolutionGroup; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.ArtifactNotFoundException; +import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.ArtifactResolutionResult; +import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; +import org.apache.maven.artifact.resolver.filter.ArtifactFilter; +import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.execution.RuntimeInformation; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.monitor.event.EventDispatcher; +import org.apache.maven.monitor.event.MavenEvents; +import org.apache.maven.monitor.logging.DefaultLog; +import org.apache.maven.plugin.ContextEnabled; +import org.apache.maven.plugin.DebugConfigurationListener; +import org.apache.maven.plugin.InvalidPluginException; +import org.apache.maven.plugin.MavenPluginCollector; +import org.apache.maven.plugin.Mojo; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.PluginConfigurationException; +import org.apache.maven.plugin.PluginManager; +import org.apache.maven.plugin.PluginManagerException; +import org.apache.maven.plugin.PluginMappingManager; +import org.apache.maven.plugin.PluginNotFoundException; +import org.apache.maven.plugin.PluginParameterException; +import org.apache.maven.plugin.PluginParameterExpressionEvaluator; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugin.version.PluginVersionManager; +import org.apache.maven.plugin.version.PluginVersionNotFoundException; +import org.apache.maven.plugin.version.PluginVersionResolutionException; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.project.artifact.InvalidDependencyVersionException; +import org.apache.maven.project.artifact.MavenMetadataSource; +import org.apache.maven.project.path.PathTranslator; +import org.apache.maven.reporting.MavenReport; +import org.apache.maven.settings.Settings; +import org.codehaus.classworlds.ClassRealm; +import org.codehaus.classworlds.NoSuchRealmException; +import org.codehaus.plexus.PlexusConstants; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.PlexusContainerException; +import org.codehaus.plexus.component.configurator.ComponentConfigurationException; +import org.codehaus.plexus.component.configurator.ComponentConfigurator; +import org.codehaus.plexus.component.configurator.ConfigurationListener; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; +import org.codehaus.plexus.context.Context; +import org.codehaus.plexus.context.ContextException; +import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +/** + * olamy : code removed in maven 3 so imported sources + * from maven 2.0.9 tag : /maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java + * really hackhish ! + * @author olamy + * + */ +public class DefaultPluginManager + extends AbstractLogEnabled + implements PluginManager, Initializable, Contextualizable +{ + protected PlexusContainer container; + + protected PluginDescriptorBuilder pluginDescriptorBuilder; + + protected ArtifactFilter artifactFilter; + + private Log mojoLogger; + + private Map resolvedCoreArtifactFiles = new HashMap(); + + // component requirements + protected PathTranslator pathTranslator; + + protected MavenPluginCollector pluginCollector; + + protected PluginVersionManager pluginVersionManager; + + protected ArtifactFactory artifactFactory; + + protected ArtifactResolver artifactResolver; + + protected ArtifactMetadataSource artifactMetadataSource; + + protected RuntimeInformation runtimeInformation; + + protected MavenProjectBuilder mavenProjectBuilder; + + protected PluginMappingManager pluginMappingManager; + + // END component requirements + + public DefaultPluginManager() + { + pluginDescriptorBuilder = new PluginDescriptorBuilder(); + } + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + public PluginDescriptor getPluginDescriptorForPrefix( String prefix ) + { + return pluginCollector.getPluginDescriptorForPrefix( prefix ); + } + + public Plugin getPluginDefinitionForPrefix( String prefix, + MavenSession session, + MavenProject project ) + { + // TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other + // use for the mapping manager in here + return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(), + project.getPluginArtifactRepositories(), + session.getLocalRepository() ); + } + + public PluginDescriptor verifyPlugin( Plugin plugin, + MavenProject project, + Settings settings, + ArtifactRepository localRepository ) + throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, + InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, + PluginVersionNotFoundException + { + // TODO: this should be possibly outside + // All version-resolution logic has been moved to DefaultPluginVersionManager. + if ( plugin.getVersion() == null ) + { + String version = pluginVersionManager.resolvePluginVersion( plugin.getGroupId(), plugin.getArtifactId(), + project, settings, localRepository ); + plugin.setVersion( version ); + } + + return verifyVersionedPlugin( plugin, project, localRepository ); + } + + private PluginDescriptor verifyVersionedPlugin( Plugin plugin, + MavenProject project, + ArtifactRepository localRepository ) + throws PluginVersionResolutionException, ArtifactNotFoundException, ArtifactResolutionException, + InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException + { + // TODO: this might result in an artifact "RELEASE" being resolved continuously + // FIXME: need to find out how a plugin gets marked as 'installed' + // and no ChildContainer exists. The check for that below fixes + // the 'Can't find plexus container for plugin: xxx' error. + try + { + VersionRange versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() ); + + List remoteRepositories = new ArrayList(); + remoteRepositories.addAll( project.getPluginArtifactRepositories() ); + remoteRepositories.addAll( project.getRemoteArtifactRepositories() ); + + checkRequiredMavenVersion( plugin, localRepository, remoteRepositories ); + + Artifact pluginArtifact = + artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); + + pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact ); + + artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository ); + + PlexusContainer pluginContainer = container.getChildContainer( plugin.getKey() ); + + File pluginFile = pluginArtifact.getFile(); + + if ( !pluginCollector.isPluginInstalled( plugin ) || ( pluginContainer == null ) ) + { + addPlugin( plugin, pluginArtifact, project, localRepository ); + } + else if ( pluginFile.lastModified() > pluginContainer.getCreationDate().getTime() ) + { + getLogger().info( + "Reloading plugin container for: " + plugin.getKey() + ". The plugin artifact has changed." ); + + pluginContainer.dispose(); + + pluginCollector.flushPluginDescriptor( plugin ); + + addPlugin( plugin, pluginArtifact, project, localRepository ); + } + + project.addPlugin( plugin ); + } + catch ( ArtifactNotFoundException e ) + { + String groupId = plugin.getGroupId(); + String artifactId = plugin.getArtifactId(); + String version = plugin.getVersion(); + + if ( ( groupId == null ) || ( artifactId == null ) || ( version == null ) ) + { + throw new PluginNotFoundException( e ); + } + else if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) && + version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) ) + { + throw new PluginNotFoundException( e ); + } + else + { + throw e; + } + } + + return pluginCollector.getPluginDescriptor( plugin ); + } + + /** + * @todo would be better to store this in the plugin descriptor, but then it won't be available to the version + * manager which executes before the plugin is instantiated + */ + private void checkRequiredMavenVersion( Plugin plugin, + ArtifactRepository localRepository, + List remoteRepositories ) + throws PluginVersionResolutionException, InvalidPluginException + { + try + { + Artifact artifact = artifactFactory.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(), + plugin.getVersion() ); + MavenProject project = + mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository, false ); + // if we don't have the required Maven version, then ignore an update + if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven() != null ) ) + { + DefaultArtifactVersion requiredVersion = + new DefaultArtifactVersion( project.getPrerequisites().getMaven() ); + if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 ) + { + throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(), + "Plugin requires Maven version " + requiredVersion ); + } + } + } + catch ( ProjectBuildingException e ) + { + throw new InvalidPluginException( + "Unable to build project for plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); + } + } + + protected void addPlugin( Plugin plugin, + Artifact pluginArtifact, + MavenProject project, + ArtifactRepository localRepository ) + throws PluginManagerException, InvalidPluginException + { + PlexusContainer child; + + try + { + child = container.createChildContainer( plugin.getKey(), + Collections.singletonList( pluginArtifact.getFile() ), + Collections.EMPTY_MAP, + Collections.singletonList( pluginCollector ) ); + try + { + child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.Xpp3Dom" ); + child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull" ); + + // MNG-2878 + child.getContainerRealm().importFrom( "plexus.core", "/default-report.xml" ); + } + catch ( NoSuchRealmException e ) + { + // won't happen + } + } + catch ( PlexusContainerException e ) + { + throw new PluginManagerException( + "Failed to create plugin container for plugin '" + plugin + "': " + e.getMessage(), e ); + } + + // this plugin's descriptor should have been discovered in the child creation, so we should be able to + // circle around and set the artifacts and class realm + PluginDescriptor addedPlugin = pluginCollector.getPluginDescriptor( plugin ); + + if ( addedPlugin == null ) + { + throw new IllegalStateException( "The PluginDescriptor for the plugin " + plugin + " was not found." ); + } + + addedPlugin.setClassRealm( child.getContainerRealm() ); + + // we're only setting the plugin's artifact itself as the artifact list, to allow it to be retrieved + // later when the plugin is first invoked. Retrieving this artifact will in turn allow us to + // transitively resolve its dependencies, and add them to the plugin container... + addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) ); + + try + { + // the only Plugin instance which will have dependencies is the one specified in the project. + // We need to look for a Plugin instance there, in case the instance we're using didn't come from + // the project. + Plugin projectPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getKey() ); + + if ( projectPlugin == null ) + { + projectPlugin = plugin; + } + + Set artifacts = MavenMetadataSource.createArtifacts( artifactFactory, projectPlugin.getDependencies(), null, + null, project ); + +// Set artifacts = +// MavenMetadataSource.createArtifacts( artifactFactory, plugin.getDependencies(), null, null, project ); + + addedPlugin.setIntroducedDependencyArtifacts( artifacts ); + } + catch ( InvalidDependencyVersionException e ) + { + throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(), e ); + } + } + + // ---------------------------------------------------------------------- + // Mojo execution + // ---------------------------------------------------------------------- + + public void executeMojo( MavenProject project, + MojoExecution mojoExecution, + MavenSession session ) + throws ArtifactResolutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException, + InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException + { + MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); + + // NOTE: I'm putting these checks in here, since this is the central point of access for + // anything that wants to execute a mojo. + if ( mojoDescriptor.isProjectRequired() && !session.isUsingPOMsFromFilesystem() ) + { + throw new MojoExecutionException( "Cannot execute mojo: " + mojoDescriptor.getGoal() + + ". It requires a project with an existing pom.xml, but the build is not using one." ); + } + + if ( mojoDescriptor.isOnlineRequired() && session.getSettings().isOffline() ) + { + // TODO: Should we error out, or simply warn and skip?? + throw new MojoExecutionException( "Mojo: " + mojoDescriptor.getGoal() + + " requires online mode for execution. Maven is currently offline." ); + } + + if ( mojoDescriptor.isDependencyResolutionRequired() != null ) + { + Collection projects; + + if ( mojoDescriptor.isAggregator() ) + { + projects = session.getSortedProjects(); + } + else + { + projects = Collections.singleton( project ); + } + + for ( Iterator i = projects.iterator(); i.hasNext(); ) + { + MavenProject p = (MavenProject) i.next(); + + resolveTransitiveDependencies( session, artifactResolver, + mojoDescriptor.isDependencyResolutionRequired(), artifactFactory, p, mojoDescriptor.isAggregator() ); + } + + downloadDependencies( project, session, artifactResolver ); + } + + String goalName = mojoDescriptor.getFullGoalName(); + + Mojo plugin; + + PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); + String goalId = mojoDescriptor.getGoal(); + String groupId = pluginDescriptor.getGroupId(); + String artifactId = pluginDescriptor.getArtifactId(); + String executionId = mojoExecution.getExecutionId(); + Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId ); + Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId ); + dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom ); + if ( mojoExecution.getConfiguration() != null ) + { + dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); + } + + plugin = getConfiguredMojo( session, dom, project, false, mojoExecution ); + + // Event monitoring. + String event = MavenEvents.MOJO_EXECUTION; + EventDispatcher dispatcher = session.getEventDispatcher(); + + String goalExecId = goalName; + + if ( mojoExecution.getExecutionId() != null ) + { + goalExecId += " {execution: " + mojoExecution.getExecutionId() + "}"; + } + + dispatcher.dispatchStart( event, goalExecId ); + + ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); + + try + { + Thread.currentThread().setContextClassLoader( + mojoDescriptor.getPluginDescriptor().getClassRealm().getClassLoader() ); + + plugin.execute(); + + dispatcher.dispatchEnd( event, goalExecId ); + } + catch ( MojoExecutionException e ) + { + session.getEventDispatcher().dispatchError( event, goalExecId, e ); + + throw e; + } + catch ( MojoFailureException e ) + { + session.getEventDispatcher().dispatchError( event, goalExecId, e ); + + throw e; + } + catch ( LinkageError e ) + { + if ( getLogger().isFatalErrorEnabled() ) + { + getLogger().fatalError( + plugin.getClass().getName() + "#execute() caused a linkage error (" + + e.getClass().getName() + ") and may be out-of-date. Check the realms:" ); + + ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm(); + StringBuffer sb = new StringBuffer(); + sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' ); + for ( int i = 0; i < pluginRealm.getConstituents().length; i++ ) + { + sb.append( "urls[" + i + "] = " + pluginRealm.getConstituents()[i] ); + if ( i != ( pluginRealm.getConstituents().length - 1 ) ) + { + sb.append( '\n' ); + } + } + getLogger().fatalError( sb.toString() ); + + ClassRealm containerRealm = container.getContainerRealm(); + sb = new StringBuffer(); + sb.append( "Container realm = " + containerRealm.getId() ).append( '\n' ); + for ( int i = 0; i < containerRealm.getConstituents().length; i++ ) + { + sb.append( "urls[" + i + "] = " + containerRealm.getConstituents()[i] ); + if ( i != ( containerRealm.getConstituents().length - 1 ) ) + { + sb.append( '\n' ); + } + } + getLogger().fatalError( sb.toString() ); + } + + session.getEventDispatcher().dispatchError( event, goalExecId, e ); + + throw e; + } + finally + { + + Thread.currentThread().setContextClassLoader( oldClassLoader ); + + try + { + PlexusContainer pluginContainer = getPluginContainer( mojoDescriptor.getPluginDescriptor() ); + + pluginContainer.release( plugin ); + } + catch ( ComponentLifecycleException e ) + { + if ( getLogger().isErrorEnabled() ) + { + getLogger().error( "Error releasing plugin - ignoring.", e ); + } + } + } + } + + public MavenReport getReport( MavenProject project, + MojoExecution mojoExecution, + MavenSession session ) + throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException, + ArtifactResolutionException + { + MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); + PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor(); + Xpp3Dom dom = project.getReportConfiguration( descriptor.getGroupId(), descriptor.getArtifactId(), + mojoExecution.getExecutionId() ); + if ( mojoExecution.getConfiguration() != null ) + { + dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); + } + + return (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution ); + } + + public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, + MavenProject project, + MavenSession session ) + throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException, + InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, + PluginVersionNotFoundException + { + String version = reportPlugin.getVersion(); + + if ( version == null ) + { + version = pluginVersionManager.resolveReportPluginVersion( reportPlugin.getGroupId(), + reportPlugin.getArtifactId(), project, + session.getSettings(), + session.getLocalRepository() ); + reportPlugin.setVersion( version ); + } + + Plugin forLookup = new Plugin(); + + forLookup.setGroupId( reportPlugin.getGroupId() ); + forLookup.setArtifactId( reportPlugin.getArtifactId() ); + forLookup.setVersion( version ); + + return verifyVersionedPlugin( forLookup, project, session.getLocalRepository() ); + } + + private PlexusContainer getPluginContainer( PluginDescriptor pluginDescriptor ) + throws PluginManagerException + { + String pluginKey = pluginDescriptor.getPluginLookupKey(); + + PlexusContainer pluginContainer = container.getChildContainer( pluginKey ); + + if ( pluginContainer == null ) + { + throw new PluginManagerException( "Cannot find Plexus container for plugin: " + pluginKey ); + } + + return pluginContainer; + } + + private Mojo getConfiguredMojo( MavenSession session, + Xpp3Dom dom, + MavenProject project, + boolean report, + MojoExecution mojoExecution ) + throws PluginConfigurationException, ArtifactNotFoundException, PluginManagerException, + ArtifactResolutionException + { + MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); + + PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); + + PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); + + // if this is the first time this plugin has been used, the plugin's container will only + // contain the plugin's artifact in isolation; we need to finish resolving the plugin's + // dependencies, and add them to the container. + ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session ); + + Mojo plugin; + try + { + plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() ); + if ( report && !( plugin instanceof MavenReport ) ) + { + // TODO: the mojoDescriptor should actually capture this information so we don't get this far + return null; + } + } + catch ( ComponentLookupException e ) + { + throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getRoleHint() + + "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'", e ); + } + + if ( plugin instanceof ContextEnabled ) + { + Map pluginContext = session.getPluginContext( pluginDescriptor, project ); + + ( (ContextEnabled) plugin ).setPluginContext( pluginContext ); + } + + plugin.setLog( mojoLogger ); + + XmlPlexusConfiguration pomConfiguration; + if ( dom == null ) + { + pomConfiguration = new XmlPlexusConfiguration( "configuration" ); + } + else + { + pomConfiguration = new XmlPlexusConfiguration( dom ); + } + + // Validate against non-editable (@readonly) parameters, to make sure users aren't trying to + // override in the POM. + validatePomConfiguration( mojoDescriptor, pomConfiguration ); + + PlexusConfiguration mergedConfiguration = mergeMojoConfiguration( pomConfiguration, mojoDescriptor ); + + // TODO: plexus changes to make this more like the component descriptor so this can be used instead + // PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration, + // mojoDescriptor.getConfiguration() ); + + ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution, + pathTranslator, getLogger(), + project, + session.getExecutionProperties() ); + + PlexusConfiguration extractedMojoConfiguration = + extractMojoConfiguration( mergedConfiguration, mojoDescriptor ); + + checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator ); + + populatePluginFields( plugin, mojoDescriptor, extractedMojoConfiguration, pluginContainer, + expressionEvaluator ); + return plugin; + } + + private void ensurePluginContainerIsComplete( PluginDescriptor pluginDescriptor, + PlexusContainer pluginContainer, + MavenProject project, + MavenSession session ) + throws ArtifactNotFoundException, PluginManagerException, ArtifactResolutionException + { + // if the plugin's already been used once, don't re-do this step... + // otherwise, we have to finish resolving the plugin's classpath and start the container. + if ( ( pluginDescriptor.getArtifacts() != null ) && ( pluginDescriptor.getArtifacts().size() == 1 ) ) + { + Artifact pluginArtifact = (Artifact) pluginDescriptor.getArtifacts().get( 0 ); + + ArtifactRepository localRepository = session.getLocalRepository(); + + ResolutionGroup resolutionGroup; + try + { + resolutionGroup = artifactMetadataSource.retrieve( pluginArtifact, localRepository, + project.getPluginArtifactRepositories() ); + } + catch ( ArtifactMetadataRetrievalException e ) + { + throw new ArtifactResolutionException( "Unable to download metadata from repository for plugin '" + + pluginArtifact.getId() + "': " + e.getMessage(), pluginArtifact, e ); + } + + checkPlexusUtils( resolutionGroup, artifactFactory ); + + // [jdcasey; 20-March-2008]: + // This is meant to eliminate the introduction of duplicated artifacts. + // Since much of the reasoning for reversing the order of introduction of + // plugin dependencies rests on the notion that we need to be able to + // introduce upgraded versions of plugin dependencies on a case-by-case + // basis, we need to remove the original version prior to artifact + // resolution. This is consistent with recent thinking on duplicated + // dependency specifications within a POM, where that case should + // throw a model validation exception. + // + // Here, we just want to remove any chance that the ArtifactCollector + // could make a bad choice, and use the old version in spite of our + // explicit preference otherwise. + + // First, we're going to accumulate plugin dependencies in an ordered map, + // keyed by dependencyConflictId (the ordered map is meant to preserve relative + // ordering of the dependencies that do make the cut). + Map dependencyMap = new LinkedHashMap(); + + // Next, we need to accumulate all dependencies in a List, to make it + // simpler to iterate through them all and add them to the map. + List all = new ArrayList(); + + // plugin-level dependencies from the consuming POM override dependencies + // from the plugin's own POM. + all.addAll( pluginDescriptor.getIntroducedDependencyArtifacts() ); + + // add in the deps from the plugin POM now. + all.addAll( resolutionGroup.getArtifacts() ); + + for ( Iterator it = all.iterator(); it.hasNext(); ) + { + Artifact artifact = (Artifact) it.next(); + String conflictId = artifact.getDependencyConflictId(); + + // if the map already contains this dependencyConflictId, it constitutes an + // overridden dependency. Don't use the old one (we know it's old from the + // order in which dependencies were added to this list). + if ( !dependencyMap.containsKey( conflictId ) ) + { + dependencyMap.put( conflictId, artifact ); + } + } + + // Create an ordered set of dependencies from the ordered map we used above, to feed into the resolver. + Set dependencies = new LinkedHashSet( dependencyMap.values() ); + + if ( getLogger().isDebugEnabled() ) + { + // list all dependencies to be used by this plugin (first-level deps, not transitive ones). + getLogger().debug( "Plugin dependencies for:\n\n" + pluginDescriptor.getId() + + "\n\nare:\n\n" + + StringUtils.join( dependencies.iterator(), "\n" ) + "\n\n" ); + } + + List repositories = new ArrayList(); + repositories.addAll( resolutionGroup.getResolutionRepositories() ); + repositories.addAll( project.getRemoteArtifactRepositories() ); + + /* get plugin managed versions */ + Map pluginManagedDependencies = new HashMap(); + try + { + MavenProject pluginProject = + mavenProjectBuilder.buildFromRepository( pluginArtifact, project.getRemoteArtifactRepositories(), + localRepository ); + if ( pluginProject != null ) + { + pluginManagedDependencies = pluginProject.getManagedVersionMap(); + } + } + catch ( ProjectBuildingException e ) + { + // this can't happen, it would have blowed up at artifactMetadataSource.retrieve() + } + + ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact, + pluginManagedDependencies, + localRepository, repositories, + artifactMetadataSource, + artifactFilter ); + + Set resolved = result.getArtifacts(); + + for ( Iterator it = resolved.iterator(); it.hasNext(); ) + { + Artifact artifact = (Artifact) it.next(); + + if ( !artifact.equals( pluginArtifact ) ) + { + artifact = project.replaceWithActiveArtifact( artifact ); + + try + { + pluginContainer.addJarResource( artifact.getFile() ); + } + catch ( PlexusContainerException e ) + { + throw new PluginManagerException( "Error adding plugin dependency '" + + artifact.getDependencyConflictId() + "' into plugin manager: " + e.getMessage(), e ); + } + } + } + + pluginDescriptor.setClassRealm( pluginContainer.getContainerRealm() ); + + List unresolved = new ArrayList( dependencies ); + + unresolved.removeAll( resolved ); + + if ( getLogger().isDebugEnabled() ) + { + // list all artifacts that were filtered out during the resolution process. + // these are already present in the core container. + getLogger().debug( " The following artifacts were filtered out for plugin: " + + pluginDescriptor.getId() + + " because they're already in the core of Maven:\n\n" + + StringUtils.join( unresolved.iterator(), "\n" ) + + "\n\nThese will use the artifact files already in the core ClassRealm instead, to allow them to be included in PluginDescriptor.getArtifacts().\n\n" ); + } + + // Grab a file for all filtered artifacts, even if it means resolving them. This + // is necessary in order to present a full complement of a plugin's transitive + // dependencies to anyone who calls PluginDescriptor.getArtifacts(). + resolveCoreArtifacts( unresolved, localRepository, resolutionGroup.getResolutionRepositories() ); + + // Re-join resolved and filtered-but-now-resolved artifacts. + // NOTE: The process of filtering then re-adding some artifacts will + // result in different ordering within the PluginDescriptor.getArtifacts() + // List than should have happened if none had been filtered. All filtered + // artifacts will be listed last... + List allResolved = new ArrayList( resolved.size() + unresolved.size() ); + + allResolved.addAll( resolved ); + allResolved.addAll( unresolved ); + + pluginDescriptor.setArtifacts( allResolved ); + } + } + + public static void checkPlexusUtils( ResolutionGroup resolutionGroup, ArtifactFactory artifactFactory ) + { + // ---------------------------------------------------------------------------- + // If the plugin already declares a dependency on plexus-utils then we're all + // set as the plugin author is aware of its use. If we don't have a dependency + // on plexus-utils then we must protect users from stupid plugin authors who + // did not declare a direct dependency on plexus-utils because the version + // Maven uses is hidden from downstream use. We will also bump up any + // anything below 1.1 to 1.1 as this mimics the behaviour in 2.0.5 where + // plexus-utils 1.1 was being forced into use. + // ---------------------------------------------------------------------------- + + VersionRange vr = null; + + try + { + vr = VersionRange.createFromVersionSpec( "[1.1,)" ); + } + catch ( InvalidVersionSpecificationException e ) + { + // Won't happen + } + + boolean plexusUtilsPresent = false; + + for ( Iterator i = resolutionGroup.getArtifacts().iterator(); i.hasNext(); ) + { + Artifact a = (Artifact) i.next(); + + if ( a.getArtifactId().equals( "plexus-utils" ) && + vr.containsVersion( new DefaultArtifactVersion( a.getVersion() ) ) ) + { + plexusUtilsPresent = true; + + break; + } + } + + if ( !plexusUtilsPresent ) + { + // We will add plexus-utils as every plugin was getting this anyway from Maven itself. We will set the + // version to the latest version we know that works as of the 2.0.6 release. We set the scope to runtime + // as this is what's implicitly happening in 2.0.6. + + resolutionGroup.getArtifacts().add( artifactFactory.createArtifact( "org.codehaus.plexus", + "plexus-utils", "1.1", + Artifact.SCOPE_RUNTIME, "jar" ) ); + } + } + + private void resolveCoreArtifacts( List unresolved, + ArtifactRepository localRepository, + List resolutionRepositories ) + throws ArtifactResolutionException, ArtifactNotFoundException + { + for ( Iterator it = unresolved.iterator(); it.hasNext(); ) + { + Artifact artifact = (Artifact) it.next(); + + File artifactFile = (File) resolvedCoreArtifactFiles.get( artifact.getId() ); + + if ( artifactFile == null ) + { + String resource = + "/META-INF/maven/" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/pom.xml"; + + URL resourceUrl = container.getContainerRealm().getResource( resource ); + + if ( resourceUrl == null ) + { + artifactResolver.resolve( artifact, resolutionRepositories, localRepository ); + + artifactFile = artifact.getFile(); + } + else + { + String artifactPath = resourceUrl.getPath(); + + if ( artifactPath.startsWith( "file:" ) ) + { + artifactPath = artifactPath.substring( "file:".length() ); + } + + artifactPath = artifactPath.substring( 0, artifactPath.length() - resource.length() ); + + if ( artifactPath.endsWith( "/" ) ) + { + artifactPath = artifactPath.substring( 0, artifactPath.length() - 1 ); + } + + if ( artifactPath.endsWith( "!" ) ) + { + artifactPath = artifactPath.substring( 0, artifactPath.length() - 1 ); + } + + artifactFile = new File( artifactPath ).getAbsoluteFile(); + } + + resolvedCoreArtifactFiles.put( artifact.getId(), artifactFile ); + } + + artifact.setFile( artifactFile ); + } + } + + private PlexusConfiguration extractMojoConfiguration( PlexusConfiguration mergedConfiguration, + MojoDescriptor mojoDescriptor ) + { + Map parameterMap = mojoDescriptor.getParameterMap(); + + PlexusConfiguration[] mergedChildren = mergedConfiguration.getChildren(); + + XmlPlexusConfiguration extractedConfiguration = new XmlPlexusConfiguration( "configuration" ); + + for ( int i = 0; i < mergedChildren.length; i++ ) + { + PlexusConfiguration child = mergedChildren[i]; + + if ( parameterMap.containsKey( child.getName() ) ) + { + extractedConfiguration.addChild( copyConfiguration( child ) ); + } + else + { + // TODO: I defy anyone to find these messages in the '-X' output! Do we need a new log level? + // ideally, this would be elevated above the true debug output, but below the default INFO level... + // [BP] (2004-07-18): need to understand the context more but would prefer this could be either WARN or + // removed - shouldn't need DEBUG to diagnose a problem most of the time. + getLogger().debug( "*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" + + mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" ); + } + } + + return extractedConfiguration; + } + + private void checkRequiredParameters( MojoDescriptor goal, + PlexusConfiguration configuration, + ExpressionEvaluator expressionEvaluator ) + throws PluginConfigurationException + { + // TODO: this should be built in to the configurator, as we presently double process the expressions + + List parameters = goal.getParameters(); + + if ( parameters == null ) + { + return; + } + + List invalidParameters = new ArrayList(); + + for ( int i = 0; i < parameters.size(); i++ ) + { + Parameter parameter = (Parameter) parameters.get( i ); + + if ( parameter.isRequired() ) + { + // the key for the configuration map we're building. + String key = parameter.getName(); + + Object fieldValue = null; + String expression = null; + PlexusConfiguration value = configuration.getChild( key, false ); + try + { + if ( value != null ) + { + expression = value.getValue( null ); + + fieldValue = expressionEvaluator.evaluate( expression ); + + if ( fieldValue == null ) + { + fieldValue = value.getAttribute( "default-value", null ); + } + } + + if ( ( fieldValue == null ) && StringUtils.isNotEmpty( parameter.getAlias() ) ) + { + value = configuration.getChild( parameter.getAlias(), false ); + if ( value != null ) + { + expression = value.getValue( null ); + fieldValue = expressionEvaluator.evaluate( expression ); + if ( fieldValue == null ) + { + fieldValue = value.getAttribute( "default-value", null ); + } + } + } + } + catch ( ExpressionEvaluationException e ) + { + throw new PluginConfigurationException( goal.getPluginDescriptor(), e.getMessage(), e ); + } + + // only mark as invalid if there are no child nodes + if ( ( fieldValue == null ) && ( ( value == null ) || ( value.getChildCount() == 0 ) ) ) + { + parameter.setExpression( expression ); + invalidParameters.add( parameter ); + } + } + } + + if ( !invalidParameters.isEmpty() ) + { + throw new PluginParameterException( goal, invalidParameters ); + } + } + + private void validatePomConfiguration( MojoDescriptor goal, + PlexusConfiguration pomConfiguration ) + throws PluginConfigurationException + { + List parameters = goal.getParameters(); + + if ( parameters == null ) + { + return; + } + + for ( int i = 0; i < parameters.size(); i++ ) + { + Parameter parameter = (Parameter) parameters.get( i ); + + // the key for the configuration map we're building. + String key = parameter.getName(); + + PlexusConfiguration value = pomConfiguration.getChild( key, false ); + + if ( ( value == null ) && StringUtils.isNotEmpty( parameter.getAlias() ) ) + { + key = parameter.getAlias(); + value = pomConfiguration.getChild( key, false ); + } + + if ( value != null ) + { + // Make sure the parameter is either editable/configurable, or else is NOT specified in the POM + if ( !parameter.isEditable() ) + { + StringBuffer errorMessage = new StringBuffer() + .append( "ERROR: Cannot override read-only parameter: " ); + errorMessage.append( key ); + errorMessage.append( " in goal: " ).append( goal.getFullGoalName() ); + + throw new PluginConfigurationException( goal.getPluginDescriptor(), errorMessage.toString() ); + } + + String deprecated = parameter.getDeprecated(); + if ( StringUtils.isNotEmpty( deprecated ) ) + { + getLogger().warn( "DEPRECATED [" + parameter.getName() + "]: " + deprecated ); + } + } + } + } + + private PlexusConfiguration mergeMojoConfiguration( XmlPlexusConfiguration fromPom, + MojoDescriptor mojoDescriptor ) + { + XmlPlexusConfiguration result = new XmlPlexusConfiguration( fromPom.getName() ); + result.setValue( fromPom.getValue( null ) ); + + if ( mojoDescriptor.getParameters() != null ) + { + PlexusConfiguration fromMojo = mojoDescriptor.getMojoConfiguration(); + + for ( Iterator it = mojoDescriptor.getParameters().iterator(); it.hasNext(); ) + { + Parameter parameter = (Parameter) it.next(); + + String paramName = parameter.getName(); + String alias = parameter.getAlias(); + String implementation = parameter.getImplementation(); + + PlexusConfiguration pomConfig = fromPom.getChild( paramName ); + PlexusConfiguration aliased = null; + + if ( alias != null ) + { + aliased = fromPom.getChild( alias ); + } + + PlexusConfiguration mojoConfig = fromMojo.getChild( paramName, false ); + + // first we'll merge configurations from the aliased and real params. + // TODO: Is this the right thing to do? + if ( aliased != null ) + { + if ( pomConfig == null ) + { + pomConfig = new XmlPlexusConfiguration( paramName ); + } + + pomConfig = buildTopDownMergedConfiguration( pomConfig, aliased ); + } + + PlexusConfiguration toAdd = null; + + if ( pomConfig != null ) + { + pomConfig = buildTopDownMergedConfiguration( pomConfig, mojoConfig ); + + if ( StringUtils.isNotEmpty( pomConfig.getValue( null ) ) || ( pomConfig.getChildCount() > 0 ) ) + { + toAdd = pomConfig; + } + } + + if ( ( toAdd == null ) && ( mojoConfig != null ) ) + { + toAdd = copyConfiguration( mojoConfig ); + } + + if ( toAdd != null ) + { + if ( ( implementation != null ) && ( toAdd.getAttribute( "implementation", null ) == null ) ) + { + + XmlPlexusConfiguration implementationConf = new XmlPlexusConfiguration( paramName ); + + implementationConf.setAttribute( "implementation", parameter.getImplementation() ); + + toAdd = buildTopDownMergedConfiguration( toAdd, implementationConf ); + } + + result.addChild( toAdd ); + } + } + } + return result; + } + + private XmlPlexusConfiguration buildTopDownMergedConfiguration( PlexusConfiguration dominant, + PlexusConfiguration recessive ) + { + XmlPlexusConfiguration result = new XmlPlexusConfiguration( dominant.getName() ); + + String value = dominant.getValue( null ); + + if ( StringUtils.isEmpty( value ) && ( recessive != null ) ) + { + value = recessive.getValue( null ); + } + + if ( StringUtils.isNotEmpty( value ) ) + { + result.setValue( value ); + } + + String[] attributeNames = dominant.getAttributeNames(); + + for ( int i = 0; i < attributeNames.length; i++ ) + { + String attributeValue = dominant.getAttribute( attributeNames[i], null ); + + result.setAttribute( attributeNames[i], attributeValue ); + } + + if ( recessive != null ) + { + attributeNames = recessive.getAttributeNames(); + + for ( int i = 0; i < attributeNames.length; i++ ) + { + String attributeValue = recessive.getAttribute( attributeNames[i], null ); + // TODO: recessive seems to be dominant here? + result.setAttribute( attributeNames[i], attributeValue ); + } + } + + PlexusConfiguration[] children = dominant.getChildren(); + + for ( int i = 0; i < children.length; i++ ) + { + PlexusConfiguration childDom = children[i]; + PlexusConfiguration childRec = recessive == null ? null : recessive.getChild( childDom.getName(), false ); + + if ( childRec != null ) + { + result.addChild( buildTopDownMergedConfiguration( childDom, childRec ) ); + } + else + { // FIXME: copy, or use reference? + result.addChild( copyConfiguration( childDom ) ); + } + } + + return result; + } + + public static PlexusConfiguration copyConfiguration( PlexusConfiguration src ) + { + // TODO: shouldn't be necessary + XmlPlexusConfiguration dom = new XmlPlexusConfiguration( src.getName() ); + dom.setValue( src.getValue( null ) ); + + String[] attributeNames = src.getAttributeNames(); + for ( int i = 0; i < attributeNames.length; i++ ) + { + String attributeName = attributeNames[i]; + dom.setAttribute( attributeName, src.getAttribute( attributeName, null ) ); + } + + PlexusConfiguration[] children = src.getChildren(); + for ( int i = 0; i < children.length; i++ ) + { + dom.addChild( copyConfiguration( children[i] ) ); + } + + return dom; + } + + // ---------------------------------------------------------------------- + // Mojo Parameter Handling + // ---------------------------------------------------------------------- + + private void populatePluginFields( Mojo plugin, + MojoDescriptor mojoDescriptor, + PlexusConfiguration configuration, + PlexusContainer pluginContainer, + ExpressionEvaluator expressionEvaluator ) + throws PluginConfigurationException + { + ComponentConfigurator configurator = null; + + try + { + String configuratorId = mojoDescriptor.getComponentConfigurator(); + + // TODO: could the configuration be passed to lookup and the configurator known to plexus via the descriptor + // so that this meethod could entirely be handled by a plexus lookup? + if ( StringUtils.isNotEmpty( configuratorId ) ) + { + configurator = + (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE, configuratorId ); + } + else + { + configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE ); + } + + ConfigurationListener listener = new DebugConfigurationListener( getLogger() ); + + getLogger().debug( "Configuring mojo '" + mojoDescriptor.getId() + "' -->" ); + configurator.configureComponent( plugin, configuration, expressionEvaluator, + pluginContainer.getContainerRealm(), listener ); + getLogger().debug( "-- end configuration --" ); + } + catch ( ComponentConfigurationException e ) + { + throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), + "Unable to parse the created DOM for plugin configuration", e ); + } + catch ( ComponentLookupException e ) + { + throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), + "Unable to retrieve component configurator for plugin configuration", + e ); + } + catch ( LinkageError e ) + { + if ( getLogger().isFatalErrorEnabled() ) + { + getLogger().fatalError( + configurator.getClass().getName() + "#configureComponent(...) caused a linkage error (" + + e.getClass().getName() + ") and may be out-of-date. Check the realms:" ); + + ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm(); + StringBuffer sb = new StringBuffer(); + sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' ); + for ( int i = 0; i < pluginRealm.getConstituents().length; i++ ) + { + sb.append( "urls[" + i + "] = " + pluginRealm.getConstituents()[i] ); + if ( i != ( pluginRealm.getConstituents().length - 1 ) ) + { + sb.append( '\n' ); + } + } + getLogger().fatalError( sb.toString() ); + + ClassRealm containerRealm = container.getContainerRealm(); + sb = new StringBuffer(); + sb.append( "Container realm = " + containerRealm.getId() ).append( '\n' ); + for ( int i = 0; i < containerRealm.getConstituents().length; i++ ) + { + sb.append( "urls[" + i + "] = " + containerRealm.getConstituents()[i] ); + if ( i != ( containerRealm.getConstituents().length - 1 ) ) + { + sb.append( '\n' ); + } + } + getLogger().fatalError( sb.toString() ); + } + + throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), + e.getClass().getName() + ": " + e.getMessage(), e ); + } + finally + { + if ( configurator != null ) + { + try + { + pluginContainer.release( configurator ); + } + catch ( ComponentLifecycleException e ) + { + getLogger().debug( "Failed to release plugin container - ignoring." ); + } + } + } + } + + public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, + Parameter parameter, + String expression ) + { + StringBuffer message = new StringBuffer(); + + message.append( "The '" ); + message.append( parameter.getName() ); + message.append( "' parameter is required for the execution of the " ); + message.append( mojo.getFullGoalName() ); + message.append( " mojo and cannot be null." ); + if ( expression != null ) + { + message.append( " The retrieval expression was: " ).append( expression ); + } + + return message.toString(); + } + + // ---------------------------------------------------------------------- + // Lifecycle + // ---------------------------------------------------------------------- + + public void contextualize( Context context ) + throws ContextException + { + container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); + + mojoLogger = new DefaultLog( container.getLoggerManager().getLoggerForComponent( Mojo.ROLE ) ); + } + + public void initialize() + { + artifactFilter = MavenArtifactFilterManager.createStandardFilter(); + } + + // ---------------------------------------------------------------------- + // Artifact resolution + // ---------------------------------------------------------------------- + + private void resolveTransitiveDependencies( MavenSession context, + ArtifactResolver artifactResolver, + String scope, + ArtifactFactory artifactFactory, + MavenProject project, boolean isAggregator ) + throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException + { + ArtifactFilter filter = new ScopeArtifactFilter( scope ); + + // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type + Artifact artifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(), + project.getVersion(), project.getPackaging() ); + + // TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same + // check this with yourkit as a hot spot. + // Don't recreate if already created - for effeciency, and because clover plugin adds to it + if ( project.getDependencyArtifacts() == null ) + { + project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) ); + } + + Set resolvedArtifacts; + try + { + ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(), + artifact, + project.getManagedVersionMap(), + context.getLocalRepository(), + project.getRemoteArtifactRepositories(), + artifactMetadataSource, filter ); + resolvedArtifacts = result.getArtifacts(); + } + catch (MultipleArtifactsNotFoundException me) + { + /*only do this if we are an aggregating plugin: MNG-2277 + if the dependency doesn't yet exist but is in the reactor, then + all we can do is warn and skip it. A better fix can be inserted into 2.1*/ + if (isAggregator && checkMissingArtifactsInReactor( context.getSortedProjects(), me.getMissingArtifacts() )) + { + resolvedArtifacts = new HashSet(me.getResolvedArtifacts()); + } + else + { + //we can't find all the artifacts in the reactor so bubble the exception up. + throw me; + } + } + project.setArtifacts( resolvedArtifacts ); + } + + /** + * This method is checking to see if the artifacts that can't be resolved are all + * part of this reactor. This is done to prevent a chicken or egg scenario with + * fresh projects that have a plugin that is an aggregator and requires dependencies. See + * MNG-2277 for more info. + * @param projects the sibling projects in the reactor + * @param missing the artifacts that can't be found + * @return true if ALL missing artifacts are found in the reactor. + */ + private boolean checkMissingArtifactsInReactor(Collection projects, Collection missing) + { + Collection foundInReactor = new HashSet(); + Iterator iter = missing.iterator(); + while (iter.hasNext()) + { + Artifact mArtifact = (Artifact) iter.next(); + Iterator pIter = projects.iterator(); + while (pIter.hasNext()) + { + MavenProject p = (MavenProject) pIter.next(); + if (p.getArtifactId().equals( mArtifact.getArtifactId()) && + p.getGroupId().equals( mArtifact.getGroupId()) && + p.getVersion().equals( mArtifact.getVersion())) + { + //TODO: the packaging could be different, but the exception doesn't contain that info + //most likely it would be produced by the project we just found in the reactor since all + //the other info matches. Assume it's ok. + getLogger().warn( "The dependency: "+ p.getId()+" can't be resolved but has been found in the reactor.\nThis dependency has been excluded from the plugin execution. You should rerun this mojo after executing mvn install.\n" ); + + //found it, move on. + foundInReactor.add( p ); + break; + } + } + } + + //if all of them have been found, we can continue. + return foundInReactor.size() == missing.size(); + } + + + // ---------------------------------------------------------------------- + // Artifact downloading + // ---------------------------------------------------------------------- + + private void downloadDependencies( MavenProject project, + MavenSession context, + ArtifactResolver artifactResolver ) + throws ArtifactResolutionException, ArtifactNotFoundException + { + ArtifactRepository localRepository = context.getLocalRepository(); + List remoteArtifactRepositories = project.getRemoteArtifactRepositories(); + + for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); ) + { + Artifact artifact = (Artifact) it.next(); + + artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository ); + } + } + + public Object getPluginComponent( Plugin plugin, + String role, + String roleHint ) + throws PluginManagerException, ComponentLookupException + { + PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin ); + + PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); + + return pluginContainer.lookup( role, roleHint ); + } + + public Map getPluginComponents( Plugin plugin, + String role ) + throws ComponentLookupException, PluginManagerException + { + PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin ); + + PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); + + return pluginContainer.lookupMap( role ); + } +} \ No newline at end of file diff --git a/maven-interceptor/src/main/java/hudson/maven/agent/PluginManagerInterceptor.java b/maven-interceptor/src/main/java/hudson/maven/agent/PluginManagerInterceptor.java index 34477eed18..94131b9721 100644 --- a/maven-interceptor/src/main/java/hudson/maven/agent/PluginManagerInterceptor.java +++ b/maven-interceptor/src/main/java/hudson/maven/agent/PluginManagerInterceptor.java @@ -26,7 +26,6 @@ package hudson.maven.agent; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.DefaultPluginManager; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index e66aed0343..af8b0d5d24 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -37,165 +37,206 @@ THE SOFTWARE. Now it is a plug-in that is installed by default, but can be disabled. http://wiki.hudson-ci.org/display/HUDSON/Maven+2+Project+Plugin - - - org.jvnet.hudson.main - hudson-core - ${project.version} - provided - - - javax.servlet - servlet-api - 2.4 - provided - - - - ${project.groupId} - maven-agent - ${project.version} - - - org.jvnet.hudson - maven2.1-interceptor - 1.2 - - - org.jvnet.hudson - maven-embedder - 2.0.4-hudson-1 - - - - jtidy - jtidy - - - commons-cli - commons-cli - - - xml-apis - xml-apis - - - - org.apache.maven.wagon - wagon-webdav - - - - - - - org.jvnet.hudson + + + org.jvnet.hudson.main + hudson-core + ${project.version} + provided + + + javax.servlet + servlet-api + 2.4 + provided + + + + ${project.groupId} + maven-agent + ${project.version} + + + + org.jvnet.hudson.main + maven-interceptor + ${project.version} + + + + org.jvnet.hudson + maven2.1-interceptor + 1.2 + + + + org.jvnet.hudson.main + maven3-agent + ${project.version} + + + + org.jvnet.hudson.main + maven3-listener + ${project.version} + + + + org.apache.ant + ant + + + org.apache.maven + maven-core + + + org.apache.maven.reporting + maven-reporting-api + 3.0 + + + org.apache.maven + maven-compat + + + org.codehaus.plexus + plexus-classworlds + + + org.jvnet.hudson + maven-embedder + 3.0-SNAPSHOT + + + + jtidy + jtidy + + + commons-cli + commons-cli + + + xml-apis + xml-apis + + + + org.apache.maven.wagon wagon-webdav - 1.0-beta-2-hudson-1 - - - jdom - jdom - - - - + + + - - - ${project.artifactId} - package - - - org.jvnet.hudson.tools - maven-hpi-plugin - 1.54 - true - - true - true - - - - org.kohsuke.stapler - maven-stapler-plugin - 1.12 - true - - - org.jvnet.localizer - maven-localizer-plugin - 1.8 - - - - generate - - - Messages.properties - target/generated-sources/localizer - - - - - - - - - - cobertura2 - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.4-apb-SNAPSHOT - true + + + org.jvnet.hudson + wagon-webdav + 1.0-beta-2-hudson-1 + + + jdom + jdom + + + + + + + + ${project.artifactId} + package + + + org.jvnet.hudson.tools + maven-hpi-plugin + 1.54 + true + + true + true + + + + org.kohsuke.stapler + maven-stapler-plugin + 1.12 + true + + + org.jvnet.localizer + maven-localizer-plugin + 1.8 + + + + generate + - - html - xml - + Messages.properties + target/generated-sources/localizer - - - coverage-instrument - process-test-classes - - instrument - - - - coverage-report - test - - generate-report - - - - - - - - - + + + + + + + + + cobertura2 + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.4-apb-SNAPSHOT + true + + + html + xml + + + + + coverage-instrument + process-test-classes + + instrument + + + + coverage-report + test + + generate-report + + + + + + + + + diff --git a/maven-plugin/src/main/java/hudson/maven/AbstractMavenBuilder.java b/maven-plugin/src/main/java/hudson/maven/AbstractMavenBuilder.java new file mode 100644 index 0000000000..8dc469dfb0 --- /dev/null +++ b/maven-plugin/src/main/java/hudson/maven/AbstractMavenBuilder.java @@ -0,0 +1,88 @@ +/* + * The MIT License + * + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Olivier Lamy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.maven; + +import hudson.model.BuildListener; +import hudson.model.Hudson; +import hudson.model.Result; +import hudson.remoting.DelegatingCallable; + +import java.io.IOException; +import java.text.NumberFormat; +import java.util.List; +import java.util.Map; + +/** + * @author Olivier Lamy + * + */ +public abstract class AbstractMavenBuilder implements DelegatingCallable { + + /** + * Goals to be executed in this Maven execution. + */ + protected final List goals; + /** + * Hudson-defined system properties. These will be made available to Maven, + * and accessible as if they are specified as -Dkey=value + */ + protected final Map systemProps; + /** + * Where error messages and so on are sent. + */ + protected final BuildListener listener; + + protected AbstractMavenBuilder(BuildListener listener, List goals, Map systemProps) { + this.listener = listener; + this.goals = goals; + this.systemProps = systemProps; + } + + protected String formatArgs(List args) { + StringBuilder buf = new StringBuilder("Executing Maven: "); + for (String arg : args) { + final String argPassword = "-Dpassword=" ; + String filteredArg = arg ; + // check if current arg is password arg. Then replace password by ***** + if (arg.startsWith(argPassword)) { + filteredArg=argPassword+"*********"; + } + buf.append(' ').append(filteredArg); + } + return buf.toString(); + } + + + + + protected String format(NumberFormat n, long nanoTime) { + return n.format(nanoTime/1000000); + } + + // since reporters might be from plugins, use the uberjar to resolve them. + public ClassLoader getClassLoader() { + return Hudson.getInstance().getPluginManager().uberClassLoader; + } + +} diff --git a/maven-plugin/src/main/java/hudson/maven/EmbedderLoggerImpl.java b/maven-plugin/src/main/java/hudson/maven/EmbedderLoggerImpl.java index 5d61e704e8..57f08058a7 100644 --- a/maven-plugin/src/main/java/hudson/maven/EmbedderLoggerImpl.java +++ b/maven-plugin/src/main/java/hudson/maven/EmbedderLoggerImpl.java @@ -24,22 +24,25 @@ package hudson.maven; import hudson.model.TaskListener; -import org.apache.maven.embedder.AbstractMavenEmbedderLogger; -import org.apache.maven.embedder.MavenEmbedderLogger; import java.io.PrintStream; import java.util.StringTokenizer; +import org.apache.maven.cli.MavenLoggerManager; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.logging.console.ConsoleLogger; + /** * {@link MavenEmbedderLogger} implementation that * sends output to {@link TaskListener}. * * @author Kohsuke Kawaguchi */ -public final class EmbedderLoggerImpl extends AbstractMavenEmbedderLogger { +public final class EmbedderLoggerImpl extends MavenLoggerManager { private final PrintStream logger; - public EmbedderLoggerImpl(TaskListener listener) { + public EmbedderLoggerImpl(TaskListener listener, int threshold) { + super(new ConsoleLogger( threshold, "hudson-logger" )); logger = listener.getLogger(); } @@ -57,22 +60,22 @@ public final class EmbedderLoggerImpl extends AbstractMavenEmbedderLogger { } public void debug(String message, Throwable throwable) { - print(message, throwable, LEVEL_DEBUG, "[DEBUG] "); + print(message, throwable, Logger.LEVEL_DEBUG, "[DEBUG] "); } public void info(String message, Throwable throwable) { - print(message, throwable, LEVEL_INFO, "[INFO ] "); + print(message, throwable, Logger.LEVEL_INFO, "[INFO ] "); } public void warn(String message, Throwable throwable) { - print(message, throwable, LEVEL_WARN, "[WARN ] "); + print(message, throwable, Logger.LEVEL_WARN, "[WARN ] "); } public void error(String message, Throwable throwable) { - print(message, throwable, LEVEL_ERROR, "[ERROR] "); + print(message, throwable, Logger.LEVEL_ERROR, "[ERROR] "); } public void fatalError(String message, Throwable throwable) { - print(message, throwable, LEVEL_FATAL, "[FATAL] "); + print(message, throwable, Logger.LEVEL_FATAL, "[FATAL] "); } } diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java new file mode 100644 index 0000000000..a9ec111025 --- /dev/null +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -0,0 +1,328 @@ +/* + * The MIT License + * + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Olivier Lamy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.maven; + +import hudson.model.BuildListener; +import hudson.model.Hudson; +import hudson.model.Result; +import hudson.remoting.Channel; +import hudson.remoting.DelegatingCallable; +import hudson.remoting.Future; +import hudson.util.IOException2; + +import java.io.IOException; +import java.io.PrintStream; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import org.apache.maven.execution.AbstractExecutionListener; +import org.apache.maven.execution.ExecutionEvent; +import org.apache.maven.execution.ExecutionListener; +import org.jvnet.hudson.maven3.agent.Maven3Main; +import org.jvnet.hudson.maven3.launcher.Maven3Launcher; +import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult; + +/** + * @author Olivier Lamy + * + */ +public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCallable { + + /** + * Flag needs to be set at the constructor, so that this reflects + * the setting at master. + */ + private final boolean profile = MavenProcessFactory.profile; + + /** + * Record all asynchronous executions as they are scheduled, + * to make sure they are all completed before we finish. + */ + protected transient /*final*/ List> futures; + + HudsonMavenExecutionResult mavenExecutionResult; + + protected Maven3Builder(BuildListener listener, List goals, Map systemProps) { + super( listener, goals, systemProps ); + } + + public Result call() + throws IOException + { + + try { + futures = new ArrayList>(); + MavenExecutionListener mavenExecutionListener = new MavenExecutionListener( this ); + Maven3Launcher.setMavenExecutionListener( mavenExecutionListener ); + + markAsSuccess = false; + + // working around NPE when someone puts a null value into systemProps. + for (Map.Entry e : systemProps.entrySet()) { + if (e.getValue()==null) + throw new IllegalArgumentException("System property "+e.getKey()+" has a null value"); + System.getProperties().put(e.getKey(), e.getValue()); + } + + listener.getLogger().println(formatArgs(goals)); + + int r = Maven3Main.launch( goals.toArray(new String[goals.size()])); + + // now check the completion status of async ops + boolean messageReported = false; + long startTime = System.nanoTime(); + for (Future f : futures) { + try { + if(!f.isDone() && !messageReported) { + messageReported = true; + // FIXME messages + listener.getLogger().println("maven builder waiting"); + } + f.get(); + } catch (InterruptedException e) { + // attempt to cancel all asynchronous tasks + for (Future g : futures) + g.cancel(true); + // FIXME messages + listener.getLogger().println("build aborted"); + return Result.ABORTED; + } catch (ExecutionException e) { + // FIXME messages + e.printStackTrace(listener.error("async build failed")); + } + } + mavenExecutionListener.overheadTime += System.nanoTime()-startTime; + futures.clear(); + + if(profile) { + NumberFormat n = NumberFormat.getInstance(); + PrintStream logger = listener.getLogger(); + logger.println("Total overhead was "+format(n,mavenExecutionListener.overheadTime)+"ms"); + Channel ch = Channel.current(); + logger.println("Class loading " +format(n,ch.classLoadingTime.get()) +"ms, "+ch.classLoadingCount+" classes"); + logger.println("Resource loading "+format(n,ch.resourceLoadingTime.get())+"ms, "+ch.resourceLoadingCount+" times"); + } + + mavenExecutionResult = Maven3Launcher.getMavenExecutionResult(); + + PrintStream logger = listener.getLogger(); + logger.println("Maven3Builder classLoaderDebug"); + logger.println("getClass().getClassLoader(): " + getClass().getClassLoader()); + + + if(r==0) { + logger.print( "r==0" ); + markAsSuccess = true; + } + + if(markAsSuccess) { + // FIXME message + //listener.getLogger().println(Messages.MavenBuilder_Failed()); + listener.getLogger().println("success"); + return Result.SUCCESS; + } + + return Result.FAILURE; + } catch (NoSuchMethodException e) { + throw new IOException2(e); + } catch (IllegalAccessException e) { + throw new IOException2(e); + } catch (InvocationTargetException e) { + throw new IOException2(e); + } catch (ClassNotFoundException e) { + throw new IOException2(e); + } catch (Exception e) { + throw new IOException2(e); + } + } + + // since reporters might be from plugins, use the uberjar to resolve them. + public ClassLoader getClassLoader() { + return Hudson.getInstance().getPluginManager().uberClassLoader; + } + + + + private static final class MavenExecutionListener extends AbstractExecutionListener implements Serializable, ExecutionListener { + + private final Maven3Builder maven3Builder; + + /** + * Number of total nanoseconds {@link Maven3Builder} spent. + */ + long overheadTime; + + public MavenExecutionListener(Maven3Builder listener) { + this.maven3Builder = listener; + } + /** + * @see org.apache.maven.execution.ExecutionListener#projectDiscoveryStarted(org.apache.maven.execution.ExecutionEvent) + */ + public void projectDiscoveryStarted( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#sessionStarted(org.apache.maven.execution.ExecutionEvent) + */ + public void sessionStarted( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#sessionEnded(org.apache.maven.execution.ExecutionEvent) + */ + public void sessionEnded( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#projectSkipped(org.apache.maven.execution.ExecutionEvent) + */ + public void projectSkipped( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#projectStarted(org.apache.maven.execution.ExecutionEvent) + */ + public void projectStarted( ExecutionEvent event ) + { + maven3Builder.listener.getLogger().println( "projectStarted in MavenExecutionListener " + + event.getProject().getGroupId() + ":" + + event.getProject().getArtifactId() ); + } + + /** + * @see org.apache.maven.execution.ExecutionListener#projectSucceeded(org.apache.maven.execution.ExecutionEvent) + */ + public void projectSucceeded( ExecutionEvent event ) + { + maven3Builder.listener.getLogger().println("projectSucceeded in adapter" ); + } + + /** + * @see org.apache.maven.execution.ExecutionListener#projectFailed(org.apache.maven.execution.ExecutionEvent) + */ + public void projectFailed( ExecutionEvent event ) + { + maven3Builder.listener.getLogger().println("projectFailed" ); + } + + /** + * @see org.apache.maven.execution.ExecutionListener#mojoSkipped(org.apache.maven.execution.ExecutionEvent) + */ + public void mojoSkipped( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#mojoStarted(org.apache.maven.execution.ExecutionEvent) + */ + public void mojoStarted( ExecutionEvent event ) + { + maven3Builder.listener.getLogger().println("mojoStarted " + event.getMojoExecution().getArtifactId()); + } + + /** + * @see org.apache.maven.execution.ExecutionListener#mojoSucceeded(org.apache.maven.execution.ExecutionEvent) + */ + public void mojoSucceeded( ExecutionEvent event ) + { + maven3Builder.listener.getLogger().println("mojoSucceeded " + event.getMojoExecution().getArtifactId()); + } + + /** + * @see org.apache.maven.execution.ExecutionListener#mojoFailed(org.apache.maven.execution.ExecutionEvent) + */ + public void mojoFailed( ExecutionEvent event ) + { + maven3Builder.listener.getLogger().println("mojoFailed " + event.getMojoExecution().getArtifactId()); + } + + /** + * @see org.apache.maven.execution.ExecutionListener#forkStarted(org.apache.maven.execution.ExecutionEvent) + */ + public void forkStarted( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#forkSucceeded(org.apache.maven.execution.ExecutionEvent) + */ + public void forkSucceeded( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#forkFailed(org.apache.maven.execution.ExecutionEvent) + */ + public void forkFailed( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#forkedProjectStarted(org.apache.maven.execution.ExecutionEvent) + */ + public void forkedProjectStarted( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#forkedProjectSucceeded(org.apache.maven.execution.ExecutionEvent) + */ + public void forkedProjectSucceeded( ExecutionEvent event ) + { + + } + + /** + * @see org.apache.maven.execution.ExecutionListener#forkedProjectFailed(org.apache.maven.execution.ExecutionEvent) + */ + public void forkedProjectFailed( ExecutionEvent event ) + { + + } + + } + + public static boolean markAsSuccess; + + private static final long serialVersionUID = 1L; + +} diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3ProcessFactory.java b/maven-plugin/src/main/java/hudson/maven/Maven3ProcessFactory.java new file mode 100644 index 0000000000..429408971c --- /dev/null +++ b/maven-plugin/src/main/java/hudson/maven/Maven3ProcessFactory.java @@ -0,0 +1,396 @@ +/* + * The MIT License + * + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Olivier Lamy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.maven; + +import static hudson.Util.fixNull; +import hudson.AbortException; +import hudson.EnvVars; +import hudson.FilePath; +import hudson.Launcher; +import hudson.Proc; +import hudson.model.BuildListener; +import hudson.model.Computer; +import hudson.model.Executor; +import hudson.model.Hudson; +import hudson.model.JDK; +import hudson.model.Node; +import hudson.model.Run.RunnerAbortedException; +import hudson.model.TaskListener; +import hudson.remoting.Callable; +import hudson.remoting.Channel; +import hudson.remoting.RemoteInputStream; +import hudson.remoting.RemoteOutputStream; +import hudson.remoting.SocketInputStream; +import hudson.remoting.SocketOutputStream; +import hudson.remoting.Which; +import hudson.slaves.Channels; +import hudson.tasks.Maven.MavenInstallation; +import hudson.util.ArgumentListBuilder; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Serializable; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketTimeoutException; +import java.util.Arrays; +import java.util.logging.Logger; + +import org.jvnet.hudson.maven3.agent.Maven3Main; +import org.jvnet.hudson.maven3.launcher.Maven3Launcher; +import org.kohsuke.stapler.framework.io.IOException2; + +/** + * @author Olivier Lamy + * + */ +public class Maven3ProcessFactory implements ProcessCache.Factory +{ + private final MavenModuleSet mms; + private final Launcher launcher; + /** + * Environment variables to be set to the maven process. + * The same variables are exposed to the system property as well. + */ + private final EnvVars envVars; + + /** + * Optional working directory. Because of the process reuse, we can't always guarantee + * that the returned Maven process has this as the working directory. But for the + * aggregator style build, the process reuse is disabled, so in practice this always works. + * + * Also, Maven is supposed to work correctly regardless of the process current directory, + * so a good behaving maven project shouldn't rely on the current project. + */ + private final FilePath workDir; + + Maven3ProcessFactory(MavenModuleSet mms, Launcher launcher, EnvVars envVars, FilePath workDir) { + this.mms = mms; + this.launcher = launcher; + this.envVars = envVars; + this.workDir = workDir; + } + + /** + * Represents a bi-directional connection. + * + *

+ * This implementation is remoting aware, so it can be safely sent to the remote callable object. + * + *

+ * When we run Maven on a slave, the master may not have a direct TCP/IP connectivty to the slave. + * That means the {@link Channel} between the master and the Maven needs to be tunneled through + * the channel between master and the slave, then go to TCP socket to the Maven. + */ + private static final class Connection implements Serializable { + public InputStream in; + public OutputStream out; + + Connection(InputStream in, OutputStream out) { + this.in = in; + this.out = out; + } + + private Object writeReplace() { + return new Connection(new RemoteInputStream(in),new RemoteOutputStream(out)); + } + + private Object readResolve() { + // ObjectInputStream seems to access data at byte-level and do not do any buffering, + // so if we are remoted, buffering would be crucial. + this.in = new BufferedInputStream(in); + this.out = new BufferedOutputStream(out); + return this; + } + + private static final long serialVersionUID = 1L; + } + + interface Acceptor { + Connection accept() throws IOException; + int getPort(); + } + + /** + * Opens a server socket and returns {@link Acceptor} so that + * we can accept a connection later on it. + */ + private static final class SocketHandler implements Callable { + public Acceptor call() throws IOException { + return new AcceptorImpl(); + } + + private static final long serialVersionUID = 1L; + + static final class AcceptorImpl implements Acceptor, Serializable { + private transient final ServerSocket serverSocket; + private transient Socket socket; + + AcceptorImpl() throws IOException { + // open a TCP socket to talk to the launched Maven process. + // let the OS pick up a random open port + this.serverSocket = new ServerSocket(); + serverSocket.bind(null); // new InetSocketAddress(InetAddress.getLocalHost(),0)); + // prevent a hang at the accept method in case the forked process didn't start successfully + serverSocket.setSoTimeout(MavenProcessFactory.socketTimeOut); + } + + public Connection accept() throws IOException { + socket = serverSocket.accept(); + // we'd only accept one connection + serverSocket.close(); + + return new Connection(new SocketInputStream(socket),new SocketOutputStream(socket)); + } + + public int getPort() { + return serverSocket.getLocalPort(); + } + + /** + * When sent to the remote node, send a proxy. + */ + private Object writeReplace() { + return Channel.current().export(Acceptor.class, this); + } + } + } + + /** + * Starts maven process. + */ + public ProcessCache.NewProcess newProcess(BuildListener listener, OutputStream out) throws IOException, InterruptedException { + if(MavenProcessFactory.debug) + listener.getLogger().println("Using env variables: "+ envVars); + try { + final Acceptor acceptor = launcher.getChannel().call(new SocketHandler()); + + final ArgumentListBuilder cmdLine = buildMavenAgentCmdLine(listener,acceptor.getPort()); + String[] cmds = cmdLine.toCommandArray(); + final Proc proc = launcher.launch().cmds(cmds).envs(envVars).stdout(out).pwd(workDir).start(); + + Connection con; + try { + con = acceptor.accept(); + } catch (SocketTimeoutException e) { + // failed to connect. Is the process dead? + // if so, the error should have been provided by the launcher already. + // so abort gracefully without a stack trace. + if(!proc.isAlive()) + throw new AbortException("Failed to launch Maven. Exit code = "+proc.join()); + throw e; + } + + return new ProcessCache.NewProcess( + Channels.forProcess("Channel to Maven "+ Arrays.toString(cmds), + Computer.threadPoolForRemoting, new BufferedInputStream(con.in), new BufferedOutputStream(con.out), + listener.getLogger(), proc), + proc); + } catch (IOException e) { + if(fixNull(e.getMessage()).contains("java: not found")) { + // diagnose issue #659 + JDK jdk = mms.getJDK(); + if(jdk==null) + throw new IOException2(mms.getDisplayName()+" is not configured with a JDK, but your PATH doesn't include Java",e); + } + throw e; + } + } + + /** + * Builds the command line argument list to launch the maven process. + * + */ + private ArgumentListBuilder buildMavenAgentCmdLine(BuildListener listener,int tcpPort) throws IOException, InterruptedException { + MavenInstallation mvn = getMavenInstallation(listener); + if(mvn==null) { + listener.error("Maven version is not configured for this project. Can't determine which Maven to run"); + throw new RunnerAbortedException(); + } + if(mvn.getHome()==null) { + listener.error("Maven '%s' doesn't have its home set",mvn.getName()); + throw new RunnerAbortedException(); + } + + // find classworlds.jar + String classWorldsJar = launcher.getChannel().call(new GetClassWorldsJar(mvn.getHome(),listener)); + + boolean isMaster = getCurrentNode()== Hudson.getInstance(); + FilePath slaveRoot=null; + if(!isMaster) + slaveRoot = getCurrentNode().getRootPath(); + + ArgumentListBuilder args = new ArgumentListBuilder(); + JDK jdk = getJava(listener); + if(jdk==null) { + args.add("java"); + } else { + args.add(jdk.getHome()+"/bin/java"); // use JDK.getExecutable() here ? + } + + if(MavenProcessFactory.debugPort!=0) + args.add("-Xrunjdwp:transport=dt_socket,server=y,address="+MavenProcessFactory.debugPort); + if(MavenProcessFactory.yjp) + args.add("-agentlib:yjpagent=tracing"); + + args.addTokenized(getMavenOpts()); + + args.add("-cp"); + args.add( + (isMaster? Which.jarFile(Maven3Main.class).getAbsolutePath():slaveRoot.child("maven3-agent.jar").getRemote())+ + (launcher.isUnix()?":":";")+classWorldsJar); + args.add(Maven3Main.class.getName()); + + // M2_HOME + args.add(mvn.getHome()); + + // remoting.jar + String remotingJar = launcher.getChannel().call(new GetRemotingJar()); + if(remotingJar==null) {// this shouldn't be possible, but there are still reports indicating this, so adding a probe here. + listener.error("Failed to determine the location of slave.jar"); + throw new RunnerAbortedException(); + } + args.add(remotingJar); + + args.add(isMaster? + Which.jarFile(Maven3Launcher.class).getAbsolutePath(): + slaveRoot.child("maven3-listener.jar").getRemote()); + + // TCP/IP port to establish the remoting infrastructure + args.add(tcpPort); + + return args; + } + + public String getMavenOpts() { + String mavenOpts = mms.getMavenOpts(); + + if ((mavenOpts==null) || (mavenOpts.trim().length()==0)) { + Node n = getCurrentNode(); + if (n!=null) { + try { + String localMavenOpts = n.toComputer().getEnvironment().get("MAVEN_OPTS"); + + if ((localMavenOpts!=null) && (localMavenOpts.trim().length()>0)) { + mavenOpts = localMavenOpts; + } + } catch (IOException e) { + } catch (InterruptedException e) { + // Don't do anything - this just means the slave isn't running, so we + // don't want to use its MAVEN_OPTS anyway. + } + + } + } + + return envVars.expand(mavenOpts); + } + + public MavenInstallation getMavenInstallation(TaskListener log) throws IOException, InterruptedException { + MavenInstallation mi = mms.getMaven(); + if (mi != null) mi = mi.forNode(getCurrentNode(), log).forEnvironment(envVars); + return mi; + + } + + public JDK getJava(TaskListener log) throws IOException, InterruptedException { + JDK jdk = mms.getJDK(); + if (jdk != null) jdk = jdk.forNode(getCurrentNode(), log).forEnvironment(envVars); + return jdk; + } + + /** + * Finds classworlds.jar + */ + private static final class GetClassWorldsJar implements Callable { + private final String mvnHome; + private final TaskListener listener; + + private GetClassWorldsJar(String mvnHome, TaskListener listener) { + this.mvnHome = mvnHome; + this.listener = listener; + } + + public String call() throws IOException { + File home = new File(mvnHome); + if (MavenProcessFactory.debug) + listener.getLogger().println("Using mvnHome: "+ mvnHome); + File bootDir = new File(home, "boot"); + File[] classworlds = bootDir.listFiles(CLASSWORLDS_FILTER); + if(classworlds==null || classworlds.length==0) { + // Maven 2.0.6 puts it to a different place + bootDir = new File(home, "boot"); + classworlds = bootDir.listFiles(CLASSWORLDS_FILTER); + if(classworlds==null || classworlds.length==0) { + // FIXME use messages + //listener.error(Messages.MavenProcessFactory_ClassWorldsNotFound(home)); + listener.error("classworld not found"); + throw new RunnerAbortedException(); + } + } + return classworlds[0].getAbsolutePath(); + } + } + + private static final class GetRemotingJar implements Callable { + public String call() throws IOException { + return Which.jarFile(hudson.remoting.Launcher.class).getPath(); + } + } + + /** + * Returns the current {@link Node} on which we are buildling. + */ + private Node getCurrentNode() { + return Executor.currentExecutor().getOwner().getNode(); + } + + /** + * Locates classworlds jar file. + * + * Note that Maven 3.0 changed the name to plexus-classworlds + * + *

+     * $ find tools/ -name "plexus-classworlds*.jar"
+     * tools/maven-3.0-alpha-2/boot/plexus-classworlds-1.3.jar
+     * tools/maven-3.0-alpha-3/boot/plexus-classworlds-2.2.2.jar
+     * tools/maven-3.0-alpha-4/boot/plexus-classworlds-2.2.2.jar
+     * tools/maven-3.0-alpha-5/boot/plexus-classworlds-2.2.2.jar
+     * tools/maven-3.0-alpha-6/boot/plexus-classworlds-2.2.2.jar
+     * 
+ */ + private static final FilenameFilter CLASSWORLDS_FILTER = new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.contains("plexus-classworlds") && name.endsWith(".jar"); + } + }; + + private static final Logger LOGGER = Logger.getLogger(MavenProcessFactory.class.getName()); + +} diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java index 958ed55b86..0ff3223544 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java @@ -25,7 +25,6 @@ package hudson.maven; import hudson.maven.agent.AbortException; import hudson.maven.agent.Main; -import hudson.maven.agent.PluginManagerInterceptor; import hudson.maven.agent.PluginManagerListener; import hudson.maven.reporters.SurefireArchiver; import hudson.model.BuildListener; @@ -40,6 +39,7 @@ import hudson.util.IOException2; import java.io.IOException; import java.io.PrintStream; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; @@ -50,14 +50,12 @@ import org.apache.maven.BuildFailureException; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; import org.apache.maven.lifecycle.LifecycleExecutionException; -import org.apache.maven.lifecycle.LifecycleExecutorInterceptor; import org.apache.maven.lifecycle.LifecycleExecutorListener; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReport; -import org.codehaus.classworlds.NoSuchRealmException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; @@ -74,20 +72,8 @@ import org.codehaus.plexus.configuration.PlexusConfiguration; * @author Kohsuke Kawaguchi * @since 1.133 */ -public abstract class MavenBuilder implements DelegatingCallable { - /** - * Goals to be executed in this Maven execution. - */ - private final List goals; - /** - * Hudson-defined system properties. These will be made available to Maven, - * and accessible as if they are specified as -Dkey=value - */ - private final Map systemProps; - /** - * Where error messages and so on are sent. - */ - protected final BuildListener listener; +public abstract class MavenBuilder extends AbstractMavenBuilder implements DelegatingCallable { + /** * Flag needs to be set at the constructor, so that this reflects @@ -102,9 +88,7 @@ public abstract class MavenBuilder implements DelegatingCallable> futures; protected MavenBuilder(BuildListener listener, List goals, Map systemProps) { - this.listener = listener; - this.goals = goals; - this.systemProps = systemProps; + super( listener, goals, systemProps ); } /** @@ -147,11 +131,17 @@ public abstract class MavenBuilder implements DelegatingCallable>(); Adapter a = new Adapter(this); + // FIXME are we using maven 2 or 3 + callSetListenerWithReflectOnInterceptors( a ); + + /* PluginManagerInterceptor.setListener(a); LifecycleExecutorInterceptor.setListener(a); - + */ + markAsSuccess = false; // working around NPE when someone puts a null value into systemProps. @@ -202,46 +192,78 @@ public abstract class MavenBuilder implements DelegatingCallable args) { - StringBuilder buf = new StringBuilder("Executing Maven: "); - for (String arg : args) { - final String argPassword = "-Dpassword=" ; - String filteredArg = arg ; - // check if current arg is password arg. Then replace password by ***** - if (arg.startsWith(argPassword)) { - filteredArg=argPassword+"*********"; - } - buf.append(' ').append(filteredArg); - } - return buf.toString(); - } - - private String format(NumberFormat n, long nanoTime) { - return n.format(nanoTime/1000000); + private void callSetListenerWithReflectOnInterceptors( PluginManagerListener pluginManagerListener ) + throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, + IllegalAccessException, InvocationTargetException + { + Class pluginManagerInterceptorClazz = + Thread.currentThread().getContextClassLoader().loadClass( "hudson.maven.agent.PluginManagerInterceptor" ); + Method setListenerMethod = + pluginManagerInterceptorClazz.getMethod( "setListener", + new Class[] { Thread.currentThread().getContextClassLoader().loadClass( "hudson.maven.agent.PluginManagerListener" ) } ); + setListenerMethod.invoke( null, new Object[] { pluginManagerListener } ); + + Class lifecycleInterceptorClazz = + Thread.currentThread().getContextClassLoader().loadClass( "org.apache.maven.lifecycle.LifecycleExecutorInterceptor" ); + + setListenerMethod = + lifecycleInterceptorClazz.getMethod( "setListener", + new Class[] { Thread.currentThread().getContextClassLoader().loadClass( "org.apache.maven.lifecycle.LifecycleExecutorListener" ) } ); + + setListenerMethod.invoke( null, new Object[] { pluginManagerListener } ); } + + private void callSetListenerWithReflectOnInterceptorsQuietly( PluginManagerListener pluginManagerListener ) + { + try + { + callSetListenerWithReflectOnInterceptors(pluginManagerListener); + } + catch ( SecurityException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + catch ( IllegalArgumentException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + catch ( ClassNotFoundException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + catch ( NoSuchMethodException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + catch ( IllegalAccessException e ) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch ( InvocationTargetException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + } - // since reporters might be from plugins, use the uberjar to resolve them. - public ClassLoader getClassLoader() { - return Hudson.getInstance().getPluginManager().uberClassLoader; - } /** * Receives {@link PluginManagerListener} and {@link LifecycleExecutorListener} events diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index 5d4c1ed3f8..63796a2dc8 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -26,8 +26,8 @@ package hudson.maven; import hudson.Extension; import hudson.FilePath; import hudson.maven.agent.Main; -import hudson.maven.agent.PluginManagerInterceptor; import hudson.maven.agent.Maven21Interceptor; +import hudson.maven.agent.PluginManagerInterceptor; import hudson.model.Computer; import hudson.model.TaskListener; import hudson.remoting.Channel; @@ -38,8 +38,12 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; -import org.apache.tools.ant.taskdefs.Zip; +import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Zip; +import org.codehaus.plexus.classworlds.ClassWorld; +import org.jvnet.hudson.maven3.agent.Maven3Main; +import org.jvnet.hudson.maven3.launcher.Maven3Launcher; /** * When a slave is connected, copy maven-agent.jar and maven-intercepter.jar @@ -52,8 +56,13 @@ public class MavenComputerListener extends ComputerListener { public void preOnline(Computer c, Channel channel,FilePath root, TaskListener listener) throws IOException, InterruptedException { PrintStream logger = listener.getLogger(); copyJar(logger, root, Main.class, "maven-agent"); + copyJar(logger, root, Maven3Main.class, "maven3-agent"); + copyJar(logger, root, Maven3Launcher.class, "maven3-listener"); copyJar(logger, root, PluginManagerInterceptor.class, "maven-interceptor"); copyJar(logger, root, Maven21Interceptor.class, "maven2.1-interceptor"); + // FIXME not needed + copyJar(logger, root, ClassWorld.class, "plexus-classworld"); + copyJar(logger, root, AntClassLoader.class, "maven-plugin-ant"); } /** diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 0da7313465..a19f972609 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -24,13 +24,29 @@ */ package hudson.maven; -import hudson.*; +import static hudson.model.Result.FAILURE; +import hudson.AbortException; +import hudson.EnvVars; +import hudson.FilePath; import hudson.FilePath.FileCallable; +import hudson.Launcher; +import hudson.Util; import hudson.maven.MavenBuild.ProxyImpl2; import hudson.maven.reporters.MavenFingerprinter; import hudson.maven.reporters.MavenMailer; -import hudson.model.*; +import hudson.model.AbstractProject; +import hudson.model.Action; +import hudson.model.Build; +import hudson.model.BuildListener; import hudson.model.Cause.UpstreamCause; +import hudson.model.Computer; +import hudson.model.Environment; +import hudson.model.Fingerprint; +import hudson.model.Hudson; +import hudson.model.ParametersAction; +import hudson.model.Result; +import hudson.model.Run; +import hudson.model.TaskListener; import hudson.remoting.Channel; import hudson.remoting.VirtualChannel; import hudson.scm.ChangeLogSet; @@ -40,8 +56,30 @@ import hudson.tasks.Maven.MavenInstallation; import hudson.util.ArgumentListBuilder; import hudson.util.IOUtils; import hudson.util.StreamTaskListener; + +import java.io.File; +import java.io.IOException; +import java.io.InterruptedIOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.Serializable; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.commons.io.FilenameUtils; import org.apache.maven.BuildFailureException; -import org.apache.maven.embedder.MavenEmbedderException; +import org.apache.maven.artifact.versioning.ComparableVersion; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; import org.apache.maven.lifecycle.LifecycleExecutionException; @@ -50,15 +88,6 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import org.apache.commons.io.FilenameUtils; - -import java.io.*; -import java.util.*; -import java.util.Map.Entry; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static hudson.model.Result.FAILURE; /** * {@link Build} for {@link MavenModuleSet}. @@ -371,6 +400,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild= 0; + + if (maven3orLater) + { + LOGGER.info( "using maven 3 " + mavenVersion ); + process = MavenBuild.mavenProcessCache.get(launcher.getChannel(), slistener, + new Maven3ProcessFactory(project,launcher,envVars,pom.getParent())); + } else + { + process = MavenBuild.mavenProcessCache.get(launcher.getChannel(), slistener, new MavenProcessFactory(project,launcher,envVars,pom.getParent())); - + } ArgumentListBuilder margs = new ArgumentListBuilder().add("-B").add("-f", pom.getRemote()); if(project.usesPrivateRepository()) margs.add("-Dmaven.repo.local="+getWorkspace().child(".repository")); @@ -471,18 +515,34 @@ public class MavenModuleSetBuild extends AbstractMavenBuild e = cl.getResources("META-INF/plexus/components.xml"); - while (e.hasMoreElements()) { - URL url = e.nextElement(); - LOGGER.fine("components.xml from "+url); - } - } + + + MavenRequest mavenRequest = new MavenRequest(); + // make sure ~/.m2 exists to avoid http://www.nabble.com/BUG-Report-tf3401736.html File m2Home = new File(MavenEmbedder.userHome, ".m2"); m2Home.mkdirs(); @@ -170,15 +159,41 @@ public class MavenUtil { "\nSee https://hudson.dev.java.net/cannot-create-.m2.html"); if (privateRepository!=null) - maven.setLocalRepositoryDirectory(new File(privateRepository)); + mavenRequest.setLocalRepositoryPath( privateRepository); - maven.setProfiles(profiles); + if (profiles != null) + { + mavenRequest.setProfiles(Arrays.asList( StringUtils.split( profiles, "," ) )); + } + if (alternateSettings!=null) - maven.setAlternateSettings(alternateSettings); + mavenRequest.setUserSettingsFile( alternateSettings.getAbsolutePath() ); + + // TODO olamy check this sould be userProperties + mavenRequest.setSystemProperties(systemProperties); + + + EmbedderLoggerImpl logger = + new EmbedderLoggerImpl( listener, debugMavenEmbedder ? org.codehaus.plexus.logging.Logger.LEVEL_DEBUG + : org.codehaus.plexus.logging.Logger.LEVEL_INFO ); + mavenRequest.setMavenLoggerManager( logger ); + + ClassLoader cl = MavenUtil.class.getClassLoader(); + + // TODO check this MaskingClassLoader with maven 3 artifacts + MavenEmbedder maven = new MavenEmbedder( new MaskingClassLoader(cl), mavenRequest ); + + + { + Enumeration e = cl.getResources("META-INF/plexus/components.xml"); + while (e.hasMoreElements()) { + URL url = e.nextElement(); + LOGGER.fine("components.xml from "+url); + } + } - maven.setSystemProperties(systemProperties); - maven.start(); + return maven; } @@ -198,11 +213,12 @@ public class MavenUtil { * * @throws AbortException * errors will be reported to the listener and the exception thrown. + * @throws MavenEmbedderException */ public static void resolveModules(MavenEmbedder embedder, MavenProject project, String rel, Map relativePathInfo, BuildListener listener, boolean nonRecursive) throws ProjectBuildingException, - AbortException { + AbortException, MavenEmbedderException { File basedir = project.getFile().getParentFile(); relativePathInfo.put(project,rel); diff --git a/maven-plugin/src/main/java/hudson/maven/MavenVersionCallable.java b/maven-plugin/src/main/java/hudson/maven/MavenVersionCallable.java new file mode 100644 index 0000000000..ef8238617b --- /dev/null +++ b/maven-plugin/src/main/java/hudson/maven/MavenVersionCallable.java @@ -0,0 +1,63 @@ +package hudson.maven; + +/* + * The MIT License + * + * Copyright (c) 2004-2010, Sun Microsystems, Inc. Olivier Lamy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import hudson.remoting.Callable; + +import java.io.File; +import java.io.IOException; + +import org.kohsuke.stapler.framework.io.IOException2; + +/** + * + * @author Olivier Lamy + * + */ +public class MavenVersionCallable + implements Callable +{ + + private final String mavenHome; + + public MavenVersionCallable( String mavenHome ) + { + this.mavenHome = mavenHome; + } + + public String call() + throws IOException + { + try + { + return MavenEmbedderUtils.getMavenVersion( new File(mavenHome) ); + } + catch ( MavenEmbedderException e ) + { + throw new IOException2( e ); + } + } + +} diff --git a/maven-plugin/src/main/java/hudson/maven/MojoInfo.java b/maven-plugin/src/main/java/hudson/maven/MojoInfo.java index a46a2ba0dc..06e4ac41f5 100644 --- a/maven-plugin/src/main/java/hudson/maven/MojoInfo.java +++ b/maven-plugin/src/main/java/hudson/maven/MojoInfo.java @@ -126,13 +126,13 @@ public class MojoInfo { public T getConfigurationValue(String configName, Class type) throws ComponentConfigurationException { PlexusConfiguration child = configuration.getChild(configName); if(child==null) return null; // no such config - + ConfigurationConverter converter = converterLookup.lookupConverterForType(type); return type.cast(converter.fromConfiguration(converterLookup,child,type, // the implementation seems to expect the type of the bean for which the configuration is done // in this parameter, but we have no such type. So passing in a dummy Object.class, - mojoExecution.getMojoDescriptor().getPluginDescriptor().getClassRealm().getClassLoader(), + mojoExecution.getMojoDescriptor().getPluginDescriptor().getClassRealm(), expressionEvaluator)); } diff --git a/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java b/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java index 27574971ff..cfffe57972 100644 --- a/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java +++ b/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java @@ -23,8 +23,8 @@ */ package hudson.maven; -import hudson.Launcher; import hudson.Extension; +import hudson.Launcher; import hudson.Util; import hudson.maven.reporters.MavenAbstractArtifactRecord; import hudson.model.AbstractBuild; @@ -32,22 +32,23 @@ import hudson.model.AbstractProject; import hudson.model.BuildListener; import hudson.model.Result; import hudson.tasks.BuildStepDescriptor; +import hudson.tasks.BuildStepMonitor; import hudson.tasks.Publisher; import hudson.tasks.Recorder; -import hudson.tasks.BuildStepMonitor; import hudson.util.FormValidation; + +import java.io.IOException; + import net.sf.json.JSONObject; + import org.apache.maven.artifact.deployer.ArtifactDeploymentException; 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.embedder.MavenEmbedderException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.kohsuke.stapler.DataBoundConstructor; -import org.kohsuke.stapler.StaplerRequest; - -import java.io.IOException; import org.kohsuke.stapler.QueryParameter; +import org.kohsuke.stapler.StaplerRequest; /** * {@link Publisher} for {@link MavenModuleSetBuild} to deploy artifacts @@ -108,7 +109,7 @@ public class RedeployPublisher extends Recorder { MavenEmbedder embedder = MavenUtil.createEmbedder(listener,build); ArtifactRepositoryLayout layout = - (ArtifactRepositoryLayout) embedder.getContainer().lookup( ArtifactRepositoryLayout.ROLE,"default"); + (ArtifactRepositoryLayout) embedder.lookup( ArtifactRepositoryLayout.ROLE,"default"); ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) embedder.lookup(ArtifactRepositoryFactory.ROLE); @@ -117,7 +118,6 @@ public class RedeployPublisher extends Recorder { mar.deploy(embedder,repository,listener); - embedder.stop(); return true; } catch (MavenEmbedderException e) { e.printStackTrace(listener.error(e.getMessage())); diff --git a/maven-plugin/src/main/java/hudson/maven/reporters/MavenAbstractArtifactRecord.java b/maven-plugin/src/main/java/hudson/maven/reporters/MavenAbstractArtifactRecord.java index f1e138d6a2..53725b8cec 100644 --- a/maven-plugin/src/main/java/hudson/maven/reporters/MavenAbstractArtifactRecord.java +++ b/maven-plugin/src/main/java/hudson/maven/reporters/MavenAbstractArtifactRecord.java @@ -25,40 +25,42 @@ package hudson.maven.reporters; import hudson.console.AnnotatedLargeText; import hudson.maven.MavenEmbedder; +import hudson.maven.MavenEmbedderException; import hudson.maven.MavenUtil; import hudson.model.AbstractBuild; import hudson.model.AbstractProject; import hudson.model.BallColor; +import hudson.model.BuildBadgeAction; import hudson.model.Result; import hudson.model.TaskAction; import hudson.model.TaskListener; import hudson.model.TaskThread; -import hudson.model.BuildBadgeAction; import hudson.model.TaskThread.ListenerAndText; -import hudson.security.Permission; import hudson.security.ACL; +import hudson.security.Permission; import hudson.util.Iterators; import hudson.widgets.HistoryWidget; import hudson.widgets.HistoryWidget.Adapter; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.concurrent.CopyOnWriteArrayList; + +import javax.servlet.ServletException; + import org.apache.maven.artifact.deployer.ArtifactDeploymentException; 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.embedder.MavenEmbedderException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.kohsuke.stapler.HttpRedirect; +import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import org.kohsuke.stapler.HttpResponse; -import org.kohsuke.stapler.HttpRedirect; - -import javax.servlet.ServletException; -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.concurrent.CopyOnWriteArrayList; /** * UI to redeploy artifacts after the fact. @@ -204,7 +206,7 @@ public abstract class MavenAbstractArtifactRecord> try { MavenEmbedder embedder = MavenUtil.createEmbedder(listener,getBuild()); ArtifactRepositoryLayout layout = - (ArtifactRepositoryLayout) embedder.getContainer().lookup( ArtifactRepositoryLayout.ROLE,"default"); + (ArtifactRepositoryLayout) embedder.lookup( ArtifactRepositoryLayout.class,"default"); ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) embedder.lookup(ArtifactRepositoryFactory.ROLE); @@ -213,7 +215,6 @@ public abstract class MavenAbstractArtifactRecord> deploy(embedder,repository,listener); - embedder.stop(); record.result = Result.SUCCESS; } finally { if(record.result==null) diff --git a/maven-plugin/src/main/java/hudson/maven/reporters/MavenAggregatedArtifactRecord.java b/maven-plugin/src/main/java/hudson/maven/reporters/MavenAggregatedArtifactRecord.java index 4d91d08d05..03840985f1 100644 --- a/maven-plugin/src/main/java/hudson/maven/reporters/MavenAggregatedArtifactRecord.java +++ b/maven-plugin/src/main/java/hudson/maven/reporters/MavenAggregatedArtifactRecord.java @@ -26,20 +26,21 @@ package hudson.maven.reporters; import hudson.maven.MavenAggregatedReport; import hudson.maven.MavenBuild; import hudson.maven.MavenEmbedder; +import hudson.maven.MavenEmbedderException; import hudson.maven.MavenModule; import hudson.maven.MavenModuleSet; import hudson.maven.MavenModuleSetBuild; import hudson.model.Action; import hudson.model.TaskListener; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.embedder.MavenEmbedderException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.io.IOException; import java.util.List; import java.util.Map; +import org.apache.maven.artifact.deployer.ArtifactDeploymentException; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; + /** * Redeploy action for the entire {@link MavenModuleSetBuild}. * diff --git a/maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifact.java b/maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifact.java index 0232687390..de8a7ac26f 100644 --- a/maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifact.java +++ b/maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifact.java @@ -36,11 +36,14 @@ import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import com.google.common.collect.Maps; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.Serializable; import java.util.Collections; +import java.util.Map; import java.util.logging.Logger; /** @@ -145,14 +148,14 @@ public final class MavenArtifact implements Serializable { // in the repository during deployment. So simulate that behavior if that's necessary. final String canonicalExtension = canonicalName.substring(canonicalName.lastIndexOf('.')+1); ArtifactHandler ah = handlerManager.getArtifactHandler(type); - // Fix for HUDSON-3814 - changed from comparing against canonical extension to canonicalName.endsWith. - if(!canonicalName.endsWith(ah.getExtension())) { - handlerManager.addHandlers(Collections.singletonMap(type, - new DefaultArtifactHandler(type) { + Map handlers = Maps.newHashMap(); + handlers.put( type, new DefaultArtifactHandler(type) { public String getExtension() { return canonicalExtension; - } - })); + } } ); + // Fix for HUDSON-3814 - changed from comparing against canonical extension to canonicalName.endsWith. + if(!canonicalName.endsWith(ah.getExtension())) { + handlerManager.addHandlers(handlers); } Artifact a = factory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier); diff --git a/maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifactRecord.java b/maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifactRecord.java index c6b5eec860..b82e8a1b19 100644 --- a/maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifactRecord.java +++ b/maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifactRecord.java @@ -27,10 +27,17 @@ import hudson.maven.AggregatableAction; import hudson.maven.MavenAggregatedReport; import hudson.maven.MavenBuild; import hudson.maven.MavenEmbedder; +import hudson.maven.MavenEmbedderException; import hudson.maven.MavenModule; import hudson.maven.MavenModuleSetBuild; import hudson.model.Action; import hudson.model.TaskListener; + +import java.io.IOException; +import java.io.PrintStream; +import java.util.List; +import java.util.Map; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeployer; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; @@ -39,15 +46,9 @@ import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.installer.ArtifactInstaller; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.embedder.MavenEmbedderException; import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import java.io.IOException; -import java.io.PrintStream; -import java.util.List; -import java.util.Map; - /** * {@link Action} that remembers {@link MavenArtifact artifact}s that are built. * @@ -105,9 +106,9 @@ public class MavenArtifactRecord extends MavenAbstractArtifactRecord @Override public void deploy(MavenEmbedder embedder, ArtifactRepository deploymentRepository, TaskListener listener) throws MavenEmbedderException, IOException, ComponentLookupException, ArtifactDeploymentException { - ArtifactHandlerManager handlerManager = (ArtifactHandlerManager) embedder.lookup(ArtifactHandlerManager.ROLE); - ArtifactDeployer deployer = (ArtifactDeployer) embedder.lookup(ArtifactDeployer.ROLE); - ArtifactFactory factory = (ArtifactFactory) embedder.lookup(ArtifactFactory.ROLE); + ArtifactHandlerManager handlerManager = embedder.lookup(ArtifactHandlerManager.class); + ArtifactDeployer deployer = embedder.lookup(ArtifactDeployer.class); + ArtifactFactory factory = embedder.lookup(ArtifactFactory.class); PrintStream logger = listener.getLogger(); Artifact main = mainArtifact.toArtifact(handlerManager,factory,parent); @@ -129,9 +130,9 @@ public class MavenArtifactRecord extends MavenAbstractArtifactRecord * Installs the artifact to the local Maven repository. */ public void install(MavenEmbedder embedder) throws MavenEmbedderException, IOException, ComponentLookupException, ArtifactInstallationException { - ArtifactHandlerManager handlerManager = (ArtifactHandlerManager) embedder.lookup(ArtifactHandlerManager.ROLE); - ArtifactInstaller installer = (ArtifactInstaller) embedder.lookup(ArtifactInstaller.class.getName()); - ArtifactFactory factory = (ArtifactFactory) embedder.lookup(ArtifactFactory.class.getName()); + ArtifactHandlerManager handlerManager = embedder.lookup(ArtifactHandlerManager.class); + ArtifactInstaller installer = embedder.lookup(ArtifactInstaller.class); + ArtifactFactory factory = embedder.lookup(ArtifactFactory.class); Artifact main = mainArtifact.toArtifact(handlerManager,factory,parent); if(!isPOM()) diff --git a/maven3-agent/.gitignore b/maven3-agent/.gitignore new file mode 100755 index 0000000000..e92bb49fdd --- /dev/null +++ b/maven3-agent/.gitignore @@ -0,0 +1,5 @@ +.settings +.project +target +.classpath +build diff --git a/maven3-agent/pom.xml b/maven3-agent/pom.xml new file mode 100755 index 0000000000..70fc9f1efb --- /dev/null +++ b/maven3-agent/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + org.jvnet.hudson.main + pom + 1.381-SNAPSHOT + + maven3-agent + maven3-agent + + + org.jvnet.hudson.main + maven3-listener + provided + ${project.version} + + + org.apache.maven + maven-embedder + + + org.codehaus.plexus + plexus-classworlds + + + org.sonatype.sisu + sisu-inject-plexus + + + junit + junit + test + + + diff --git a/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java b/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java new file mode 100755 index 0000000000..b90b305003 --- /dev/null +++ b/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java @@ -0,0 +1,177 @@ +/* + * The MIT License + * + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jvnet.hudson.maven3.agent; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.codehaus.plexus.classworlds.launcher.Launcher; +import org.codehaus.plexus.classworlds.realm.ClassRealm; + + + +/** + * Entry point for launching Maven 3 and Hudson remoting in the same VM, in the + * classloader layout that Maven expects. + * + *

+ * The actual Maven execution will be started by the program sent through + * remoting. + *

+ * + * @author Kohsuke Kawaguchi + * @author Olivier Lamy + */ +public class Maven3Main { + /** + * Used to pass the classworld instance to the code running inside the + * remoting system. + */ + private static Launcher launcher; + + public static void main(String[] args) throws Exception { + main(new File(args[0]), new File(args[1]),new File(args[2]), + Integer.parseInt(args[3])); + } + + /** + * + * @param m2Home + * Maven2 installation. This is where we find Maven jars that + * we'll run. + * @param remotingJar + * Hudson's remoting.jar that we'll load. + * @param listenerJar + * maven-listener.jar that we'll load. + * @param tcpPort + * TCP socket that the launching Hudson will be listening to. + * This is used for the remoting communication. + * @param projectBuildLaunch + * launch the projectBuilder and not a mavenExecution + */ + public static void main(File m2Home, File remotingJar, File listenerJar, + int tcpPort) throws Exception { + // Unix master with Windows slave ends up passing path in Unix format, + // so convert it to Windows format now so that no one chokes with the + // path format later. + try { + m2Home = m2Home.getCanonicalFile(); + } catch (IOException e) { + // ignore. We'll check the error later if m2Home exists anyway + } + + if (!m2Home.exists()) { + System.err.println("No such directory exists: " + m2Home); + System.exit(1); + } + + versionCheck(); + + // expose variables used in the classworlds configuration + System.setProperty("maven.home", m2Home.getPath()); + System.setProperty("maven3.listener", (listenerJar != null ? listenerJar + : listenerJar).getPath()); + + // load the default realms + launcher = new Launcher(); + launcher.setSystemClassLoader(Maven3Main.class.getClassLoader()); + launcher.configure(Maven3Main.class + .getResourceAsStream("classworlds.conf")); + + + // create a realm for loading remoting subsystem. + // this needs to be able to see maven. + ClassRealm remoting = launcher.getWorld().newRealm( "hudson-remoting", launcher.getSystemClassLoader() ); + remoting.setParentRealm(launcher.getWorld().getRealm("plexus.core")); + remoting.addURL(remotingJar.toURI().toURL()); + + final Socket s = new Socket((String) null, tcpPort); + + Class remotingLauncher = remoting.loadClass("hudson.remoting.Launcher"); + remotingLauncher.getMethod("main", + new Class[] { InputStream.class, OutputStream.class }).invoke( + null, + new Object[] { + // do partial close, since socket.getInputStream and + // getOutputStream doesn't do it by + new BufferedInputStream(new FilterInputStream(s + .getInputStream()) { + public void close() throws IOException { + s.shutdownInput(); + } + }), + new BufferedOutputStream(new RealFilterOutputStream(s + .getOutputStream()) { + public void close() throws IOException { + s.shutdownOutput(); + } + }) }); + System.exit(0); + } + + /** + * Called by the code in remoting to launch. + */ + public static int launch(String[] args) throws Exception { + + try { + launcher.launch(args); + } catch (Throwable e) + { + e.printStackTrace(); + throw new Exception( e ); + } + return launcher.getExitCode(); + } + + /** + * Makes sure that this is Java5 or later. + */ + private static void versionCheck() { + String v = System.getProperty("java.class.version"); + if (v != null) { + try { + if (Float.parseFloat(v) < 49.0) { + System.err + .println("Native maven support requires Java 1.5 or later, but this Maven is using " + + System.getProperty("java.home")); + System.err.println("Please use the freestyle project."); + System.exit(1); + } + } catch (NumberFormatException e) { + // couldn't check. + } + } + } + +} \ No newline at end of file diff --git a/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/RealFilterOutputStream.java b/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/RealFilterOutputStream.java new file mode 100755 index 0000000000..3cbc7f7662 --- /dev/null +++ b/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/RealFilterOutputStream.java @@ -0,0 +1,51 @@ +/* + * The MIT License + * + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jvnet.hudson.maven3.agent; + +import java.io.OutputStream; +import java.io.IOException; +import java.io.FilterOutputStream; + +/** + * JDK's {@link FilterOutputStream} has some real issues. + * + * @author Kohsuke Kawaguchi + */ +class RealFilterOutputStream extends FilterOutputStream { + public RealFilterOutputStream(OutputStream core) { + super(core); + } + + public void write(byte[] b) throws IOException { + out.write(b); + } + + public void write(byte[] b, int off, int len) throws IOException { + out.write(b, off, len); + } + + public void close() throws IOException { + out.close(); + } +} diff --git a/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf b/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf new file mode 100755 index 0000000000..e2d3b6a041 --- /dev/null +++ b/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf @@ -0,0 +1,11 @@ +# +# mostly copied as-is from $MAVEN_HOME/bin/m2.conf +# +#main is org.apache.maven.cli.MavenCli from plexus.core.maven +main is org.jvnet.hudson.maven3.launcher.Maven3Launcher from plexus.core + +set maven.home default ${user.home}/m2 + +[plexus.core] +load ${maven3.listener} +load ${maven.home}/lib/*.jar \ No newline at end of file diff --git a/maven3-listener/.gitignore b/maven3-listener/.gitignore new file mode 100755 index 0000000000..e92bb49fdd --- /dev/null +++ b/maven3-listener/.gitignore @@ -0,0 +1,5 @@ +.settings +.project +target +.classpath +build diff --git a/maven3-listener/pom.xml b/maven3-listener/pom.xml new file mode 100755 index 0000000000..1d8cfe5a23 --- /dev/null +++ b/maven3-listener/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + org.jvnet.hudson.main + pom + 1.381-SNAPSHOT + + maven3-listener + maven3-listener + + + + org.apache.maven + maven-core + + + org.apache.maven + maven-embedder + + + org.apache.maven + maven-aether-provider + + + + org.sonatype.sisu + sisu-inject-plexus + + + + junit + junit + test + + + + + + + org.codehaus.plexus + plexus-component-metadata + 1.5.4 + + + + generate-metadata + + + + + + + diff --git a/maven3-listener/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java b/maven3-listener/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java new file mode 100755 index 0000000000..84ac396200 --- /dev/null +++ b/maven3-listener/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java @@ -0,0 +1,792 @@ +package org.apache.maven.cli; + +/* + * 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 java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.StringTokenizer; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.ParseException; +import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.execution.MavenExecutionRequestPopulationException; +import org.apache.maven.execution.MavenExecutionRequestPopulator; +import org.apache.maven.lifecycle.internal.LifecycleWeaveBuilder; +import org.apache.maven.model.building.ModelProcessor; +import org.apache.maven.properties.internal.EnvironmentUtils; +import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; +import org.apache.maven.settings.building.SettingsBuilder; +import org.apache.maven.settings.building.SettingsBuildingException; +import org.apache.maven.settings.building.SettingsBuildingRequest; +import org.apache.maven.settings.building.SettingsBuildingResult; +import org.apache.maven.settings.building.SettingsProblem; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.classworlds.ClassWorld; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; +import org.codehaus.plexus.util.StringUtils; +import org.sonatype.aether.impl.internal.EnhancedLocalRepositoryManager; +import org.sonatype.aether.transfer.TransferListener; +import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; +import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; +import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; +import org.sonatype.plexus.components.sec.dispatcher.SecUtil; +import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity; + +/** + * Most of code is coming from asf svn repo waiting before having available + * @author Olivier Lamy + * @since + */ +@Component( role = MavenExecutionRequestBuilder.class) +public class DefaultMavenExecutionRequestBuilder + implements MavenExecutionRequestBuilder, Initializable +{ + + @Requirement + private SettingsBuilder settingsBuilder; + + @Requirement + private MavenExecutionRequestPopulator executionRequestPopulator; + + @Requirement + private Logger plexusLogger; + + @Requirement + private ModelProcessor modelProcessor; + + @Requirement + private PlexusContainer plexusContainer; + + private DefaultSecDispatcher dispatcher; + + public void initialize() + throws InitializationException + { + try + { + dispatcher = (DefaultSecDispatcher) plexusContainer.lookup( SecDispatcher.class, "maven" ); + } + catch ( ComponentLookupException e ) + { + throw new InitializationException( e.getMessage(), e ); + } + } + + /** + * @throws MavenExecutionRequestPopulationException + * @see org.jvnet.hudson.maven3.MavenExecutionRequestBuilder.MavenExecutionRequestsBuilder#getMavenExecutionRequest(java.lang.String[]) + */ + public MavenExecutionRequest getMavenExecutionRequest( String[] args, PrintStream printStream ) + throws MavenExecutionRequestPopulationException, SettingsBuildingException, + MavenExecutionRequestsBuilderException + { + try + { + CliRequest cliRequest = new CliRequest( args, null ); + initialize( cliRequest, printStream ); + // Need to process cli options first to get possible logging options + cli( cliRequest ); + logging( cliRequest ); + commands( cliRequest ); + properties( cliRequest ); + // we are in a container so no need + //container( cliRequest ); + settings( cliRequest ); + populateRequest( cliRequest ); + encryption( cliRequest ); + + MavenExecutionRequest request = executionRequestPopulator.populateDefaults( cliRequest.request ); + + // TODO move this in ASF sources ? + + if (request.getProjectBuildingRequest().getRepositorySession()== null) + { + MavenRepositorySystemSession session = new MavenRepositorySystemSession(); + if (session.getLocalRepositoryManager() == null) + { + session.setLocalRepositoryManager( new EnhancedLocalRepositoryManager( request.getLocalRepositoryPath() ) ); + } + request.getProjectBuildingRequest().setRepositorySession( session ); + } + + return request; + } + catch ( Exception e ) + { + throw new MavenExecutionRequestsBuilderException( e.getMessage(), e ); + } + + } + + static File resolveFile( File file, String workingDirectory ) + { + if ( file == null ) + { + return null; + } + else if ( file.isAbsolute() ) + { + return file; + } + else if ( file.getPath().startsWith( File.separator ) ) + { + // drive-relative Windows path + return file.getAbsoluteFile(); + } + else + { + return new File( workingDirectory, file.getPath() ).getAbsoluteFile(); + } + } + + private void initialize( CliRequest cliRequest, PrintStream printStream ) + { + if ( cliRequest.stdout == null ) + { + cliRequest.stdout = System.out; + } + if ( cliRequest.stderr == null ) + { + cliRequest.stderr = System.err; + } + + if ( cliRequest.logger == null ) + { + cliRequest.logger = new PrintStreamLogger( cliRequest.stdout ); + } + else + { + cliRequest.logger.setStream( cliRequest.stdout ); + } + + if ( cliRequest.workingDirectory == null ) + { + cliRequest.workingDirectory = System.getProperty( "user.dir" ); + } + + // + // Make sure the Maven home directory is an absolute path to save us from confusion with say drive-relative + // Windows paths. + // + String mavenHome = System.getProperty( "maven.home" ); + + if ( mavenHome != null ) + { + System.setProperty( "maven.home", new File( mavenHome ).getAbsolutePath() ); + } + } + + private void cli( CliRequest cliRequest ) + throws Exception + { + CLIManager cliManager = new CLIManager(); + + try + { + cliRequest.commandLine = cliManager.parse( cliRequest.args ); + } + catch ( ParseException e ) + { + cliRequest.stderr.println( "Unable to parse command line options: " + e.getMessage() ); + cliManager.displayHelp( cliRequest.stdout ); + throw e; + } + + // TODO: these should be moved out of here. Wrong place. + // + if ( cliRequest.commandLine.hasOption( CLIManager.HELP ) ) + { + cliManager.displayHelp( cliRequest.stdout ); + throw new MavenCli.ExitException( 0 ); + } + + if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) ) + { + CLIReportingUtils.showVersion( cliRequest.stdout ); + throw new MavenCli.ExitException( 0 ); + } + } + + private void logging( CliRequest cliRequest ) + { + cliRequest.debug = cliRequest.commandLine.hasOption( CLIManager.DEBUG ); + cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption( CLIManager.QUIET ); + cliRequest.showErrors = cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.ERRORS ); + + if ( cliRequest.debug ) + { + cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG ); + } + else if ( cliRequest.quiet ) + { + // TODO: we need to do some more work here. Some plugins use sys out or log errors at info level. + // Ideally, we could use Warn across the board + cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR ); + // TODO:Additionally, we can't change the mojo level because the component key includes the version and + // it isn't known ahead of time. This seems worth changing. + } + else + { + cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO ); + } + + plexusLogger.setThreshold( cliRequest.request.getLoggingLevel() ); + + if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) ) + { + File logFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.LOG_FILE ) ); + logFile = resolveFile( logFile, cliRequest.workingDirectory ); + + try + { + cliRequest.fileStream = new PrintStream( logFile ); + cliRequest.logger.setStream( cliRequest.fileStream ); + } + catch ( FileNotFoundException e ) + { + cliRequest.stderr.println( e ); + cliRequest.logger.setStream( cliRequest.stdout ); + } + } + else + { + cliRequest.logger.setStream( cliRequest.stdout ); + } + + cliRequest.request.setExecutionListener( new ExecutionEventLogger( cliRequest.logger ) ); + } + + private void commands( CliRequest cliRequest ) + { + if ( cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION ) ) + { + CLIReportingUtils.showVersion( cliRequest.stdout ); + } + + if ( cliRequest.showErrors ) + { + cliRequest.logger.info( "Error stacktraces are turned on." ); + } + + // + // TODO: move checksum policies to + // + if ( MavenExecutionRequest.CHECKSUM_POLICY_WARN.equals( cliRequest.request.getGlobalChecksumPolicy() ) ) + { + cliRequest.logger.info( "Disabling strict checksum verification on all artifact downloads." ); + } + else if ( MavenExecutionRequest.CHECKSUM_POLICY_FAIL.equals( cliRequest.request.getGlobalChecksumPolicy() ) ) + { + cliRequest.logger.info( "Enabling strict checksum verification on all artifact downloads." ); + } + } + + private void properties( CliRequest cliRequest ) + { + populateProperties( cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties ); + } + + // ---------------------------------------------------------------------- + // System properties handling + // ---------------------------------------------------------------------- + + static void populateProperties( CommandLine commandLine, Properties systemProperties, Properties userProperties ) + { + EnvironmentUtils.addEnvVars( systemProperties ); + + // ---------------------------------------------------------------------- + // Options that are set on the command line become system properties + // and therefore are set in the session properties. System properties + // are most dominant. + // ---------------------------------------------------------------------- + + if ( commandLine.hasOption( CLIManager.SET_SYSTEM_PROPERTY ) ) + { + String[] defStrs = commandLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY ); + + if ( defStrs != null ) + { + for ( int i = 0; i < defStrs.length; ++i ) + { + setCliProperty( defStrs[i], userProperties ); + } + } + } + + systemProperties.putAll( System.getProperties() ); + } + + private static void setCliProperty( String property, Properties properties ) + { + String name; + + String value; + + int i = property.indexOf( "=" ); + + if ( i <= 0 ) + { + name = property.trim(); + + value = "true"; + } + else + { + name = property.substring( 0, i ).trim(); + + value = property.substring( i + 1 ); + } + + properties.setProperty( name, value ); + + // ---------------------------------------------------------------------- + // I'm leaving the setting of system properties here as not to break + // the SystemPropertyProfileActivator. This won't harm embedding. jvz. + // ---------------------------------------------------------------------- + + System.setProperty( name, value ); + } + + private void settings( CliRequest cliRequest ) + throws Exception + { + File userSettingsFile; + + if ( cliRequest.commandLine.hasOption( CLIManager.ALTERNATE_USER_SETTINGS ) ) + { + userSettingsFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) ); + userSettingsFile = resolveFile( userSettingsFile, cliRequest.workingDirectory ); + + if ( !userSettingsFile.isFile() ) + { + throw new FileNotFoundException( "The specified user settings file does not exist: " + userSettingsFile ); + } + } + else + { + userSettingsFile = MavenCli.DEFAULT_USER_SETTINGS_FILE; + } + + cliRequest.logger.debug( "Reading user settings from " + userSettingsFile ); + + File globalSettingsFile; + + if ( cliRequest.commandLine.hasOption( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) ) + { + globalSettingsFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) ); + globalSettingsFile = resolveFile( globalSettingsFile, cliRequest.workingDirectory ); + + if ( !globalSettingsFile.isFile() ) + { + throw new FileNotFoundException( "The specified global settings file does not exist: " + + globalSettingsFile ); + } + } + else + { + globalSettingsFile = MavenCli.DEFAULT_GLOBAL_SETTINGS_FILE; + } + + cliRequest.logger.debug( "Reading global settings from " + globalSettingsFile ); + + cliRequest.request.setGlobalSettingsFile( globalSettingsFile ); + cliRequest.request.setUserSettingsFile( userSettingsFile ); + + SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest(); + settingsRequest.setGlobalSettingsFile( globalSettingsFile ); + settingsRequest.setUserSettingsFile( userSettingsFile ); + settingsRequest.setSystemProperties( cliRequest.systemProperties ); + settingsRequest.setUserProperties( cliRequest.userProperties ); + + SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest ); + + executionRequestPopulator.populateFromSettings( cliRequest.request, settingsResult.getEffectiveSettings() ); + + if ( !settingsResult.getProblems().isEmpty() && cliRequest.logger.isWarnEnabled() ) + { + cliRequest.logger.warn( "" ); + cliRequest.logger.warn( "Some problems were encountered while building the effective settings" ); + + for ( SettingsProblem problem : settingsResult.getProblems() ) + { + cliRequest.logger.warn( problem.getMessage() + " @ " + problem.getLocation() ); + } + + cliRequest.logger.warn( "" ); + } + } + + private MavenExecutionRequest populateRequest( CliRequest cliRequest ) + { + MavenExecutionRequest request = cliRequest.request; + CommandLine commandLine = cliRequest.commandLine; + String workingDirectory = cliRequest.workingDirectory; + boolean debug = cliRequest.debug; + boolean quiet = cliRequest.quiet; + boolean showErrors = cliRequest.showErrors; + + String[] deprecatedOptions = { "up", "npu", "cpu", "npr" }; + for ( String deprecatedOption : deprecatedOptions ) + { + if ( commandLine.hasOption( deprecatedOption ) ) + { + cliRequest.stdout.println( "[WARNING] Command line option -" + deprecatedOption + + " is deprecated and will be removed in future Maven versions." ); + } + } + + // ---------------------------------------------------------------------- + // Now that we have everything that we need we will fire up plexus and + // bring the maven component to life for use. + // ---------------------------------------------------------------------- + + if ( commandLine.hasOption( CLIManager.BATCH_MODE ) ) + { + request.setInteractiveMode( false ); + } + + boolean noSnapshotUpdates = false; + if ( commandLine.hasOption( CLIManager.SUPRESS_SNAPSHOT_UPDATES ) ) + { + noSnapshotUpdates = true; + } + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + @SuppressWarnings("unchecked") + List goals = commandLine.getArgList(); + + boolean recursive = true; + + // this is the default behavior. + String reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST; + + if ( commandLine.hasOption( CLIManager.NON_RECURSIVE ) ) + { + recursive = false; + } + + if ( commandLine.hasOption( CLIManager.FAIL_FAST ) ) + { + reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST; + } + else if ( commandLine.hasOption( CLIManager.FAIL_AT_END ) ) + { + reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_AT_END; + } + else if ( commandLine.hasOption( CLIManager.FAIL_NEVER ) ) + { + reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_NEVER; + } + + if ( commandLine.hasOption( CLIManager.OFFLINE ) ) + { + request.setOffline( true ); + } + + boolean updateSnapshots = false; + + if ( commandLine.hasOption( CLIManager.UPDATE_SNAPSHOTS ) ) + { + updateSnapshots = true; + } + + String globalChecksumPolicy = null; + + if ( commandLine.hasOption( CLIManager.CHECKSUM_FAILURE_POLICY ) ) + { + globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_FAIL; + } + else if ( commandLine.hasOption( CLIManager.CHECKSUM_WARNING_POLICY ) ) + { + globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_WARN; + } + + File baseDirectory = new File( workingDirectory, "" ).getAbsoluteFile(); + + // ---------------------------------------------------------------------- + // Profile Activation + // ---------------------------------------------------------------------- + + List activeProfiles = new ArrayList(); + + List inactiveProfiles = new ArrayList(); + + if ( commandLine.hasOption( CLIManager.ACTIVATE_PROFILES ) ) + { + String[] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES ); + if ( profileOptionValues != null ) + { + for ( int i = 0; i < profileOptionValues.length; ++i ) + { + StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i], "," ); + + while ( profileTokens.hasMoreTokens() ) + { + String profileAction = profileTokens.nextToken().trim(); + + if ( profileAction.startsWith( "-" ) || profileAction.startsWith( "!" ) ) + { + inactiveProfiles.add( profileAction.substring( 1 ) ); + } + else if ( profileAction.startsWith( "+" ) ) + { + activeProfiles.add( profileAction.substring( 1 ) ); + } + else + { + activeProfiles.add( profileAction ); + } + } + } + } + } + + TransferListener transferListener; + + if ( quiet ) + { + transferListener = new QuietMavenTransferListener( ); + } + else if ( request.isInteractiveMode() ) + { + transferListener = new ConsoleMavenTransferListener( cliRequest.stdout ); + } + else + { + transferListener = new BatchModeMavenTransferListener( cliRequest.stdout ); + } + + //transferListener. .setShowChecksumEvents( false ); + + String alternatePomFile = null; + if ( commandLine.hasOption( CLIManager.ALTERNATE_POM_FILE ) ) + { + alternatePomFile = commandLine.getOptionValue( CLIManager.ALTERNATE_POM_FILE ); + } + + int loggingLevel; + + if ( debug ) + { + loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_DEBUG; + } + else if ( quiet ) + { + // TODO: we need to do some more work here. Some plugins use sys out or log errors at info level. + // Ideally, we could use Warn across the board + loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_ERROR; + // TODO:Additionally, we can't change the mojo level because the component key includes the version and + // it isn't known ahead of time. This seems worth changing. + } + else + { + loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_INFO; + } + + File userToolchainsFile; + if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ) + { + userToolchainsFile = new File( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ); + userToolchainsFile = resolveFile( userToolchainsFile, workingDirectory ); + } + else + { + userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE; + } + + request.setBaseDirectory( baseDirectory ).setGoals( goals ).setSystemProperties( cliRequest.systemProperties ) + .setUserProperties( cliRequest.userProperties ).setReactorFailureBehavior( reactorFailureBehaviour ) // default: fail fast + .setRecursive( recursive ) // default: true + .setShowErrors( showErrors ) // default: false + .addActiveProfiles( activeProfiles ) // optional + .addInactiveProfiles( inactiveProfiles ) // optional + .setLoggingLevel( loggingLevel ) // default: info + .setTransferListener( transferListener ) // default: batch mode which goes along with interactive + .setUpdateSnapshots( updateSnapshots ) // default: false + .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false + .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn + .setUserToolchainsFile( userToolchainsFile ); + + if ( alternatePomFile != null ) + { + File pom = resolveFile( new File( alternatePomFile ), workingDirectory ); + + request.setPom( pom ); + } + else + { + File pom = modelProcessor.locatePom( baseDirectory ); + + if ( pom.isFile() ) + { + request.setPom( pom ); + } + } + + if ( ( request.getPom() != null ) && ( request.getPom().getParentFile() != null ) ) + { + request.setBaseDirectory( request.getPom().getParentFile() ); + } + + if ( commandLine.hasOption( CLIManager.RESUME_FROM ) ) + { + request.setResumeFrom( commandLine.getOptionValue( CLIManager.RESUME_FROM ) ); + } + + if ( commandLine.hasOption( CLIManager.PROJECT_LIST ) ) + { + String projectList = commandLine.getOptionValue( CLIManager.PROJECT_LIST ); + String[] projects = StringUtils.split( projectList, "," ); + request.setSelectedProjects( Arrays.asList( projects ) ); + } + + if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && !commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) ) + { + request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM ); + } + else if ( !commandLine.hasOption( CLIManager.ALSO_MAKE ) + && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) ) + { + request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM ); + } + else if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) + && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) ) + { + request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_BOTH ); + } + + String localRepoProperty = request.getUserProperties().getProperty( MavenCli.LOCAL_REPO_PROPERTY ); + + if ( localRepoProperty == null ) + { + localRepoProperty = request.getSystemProperties().getProperty( MavenCli.LOCAL_REPO_PROPERTY ); + } + + if ( localRepoProperty != null ) + { + request.setLocalRepositoryPath( localRepoProperty ); + } + + final String threadConfiguration = commandLine.hasOption( CLIManager.THREADS ) ? commandLine + .getOptionValue( CLIManager.THREADS ) : request.getSystemProperties() + .getProperty( MavenCli.THREADS_DEPRECATED ); // TODO: Remove this setting. Note that the int-tests use it + + if ( threadConfiguration != null ) + { + request.setPerCoreThreadCount( threadConfiguration.contains( "C" ) ); + if ( threadConfiguration.contains( "W" ) ) + { + LifecycleWeaveBuilder.setWeaveMode( request.getUserProperties() ); + } + request.setThreadCount( threadConfiguration.replace( "C", "" ).replace( "W", "" ).replace( "auto", "" ) ); + } + + return request; + } + + private void encryption( CliRequest cliRequest ) + throws Exception + { + if ( cliRequest.commandLine.hasOption( CLIManager.ENCRYPT_MASTER_PASSWORD ) ) + { + String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_MASTER_PASSWORD ); + + DefaultPlexusCipher cipher = new DefaultPlexusCipher(); + + cliRequest.stdout.println( cipher.encryptAndDecorate( passwd, + DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); + + throw new MavenCli.ExitException( 0 ); + } + else if ( cliRequest.commandLine.hasOption( CLIManager.ENCRYPT_PASSWORD ) ) + { + String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_PASSWORD ); + + String configurationFile = dispatcher.getConfigurationFile(); + + if ( configurationFile.startsWith( "~" ) ) + { + configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); + } + + String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); + + String master = null; + + SettingsSecurity sec = SecUtil.read( file, true ); + if ( sec != null ) + { + master = sec.getMaster(); + } + + if ( master == null ) + { + throw new IllegalStateException( "Master password is not set in the setting security file: " + file ); + } + + DefaultPlexusCipher cipher = new DefaultPlexusCipher(); + String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); + cliRequest.stdout.println( cipher.encryptAndDecorate( passwd, masterPasswd ) ); + + throw new MavenCli.ExitException( 0 ); + } + } + + static class CliRequest + { + String[] args; + CommandLine commandLine; + PrintStream stdout; + PrintStream stderr; + ClassWorld classWorld; + String workingDirectory; + boolean debug; + boolean quiet; + boolean showErrors = true; + PrintStream fileStream; + Properties userProperties = new Properties(); + Properties systemProperties = new Properties(); + MavenExecutionRequest request; + PrintStreamLogger logger; + + CliRequest( String[] args, ClassWorld classWorld ) + { + this.args = args; + this.classWorld = classWorld; + this.request = new DefaultMavenExecutionRequest(); + } + } + +} diff --git a/maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java b/maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java new file mode 100755 index 0000000000..099337e8b6 --- /dev/null +++ b/maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java @@ -0,0 +1,36 @@ +package org.apache.maven.cli; + +/* + * 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 java.io.PrintStream; + +import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.execution.MavenExecutionRequestPopulationException; +import org.apache.maven.settings.building.SettingsBuildingException; + +/** + * @author Olivier Lamy + * @since + */ +public interface MavenExecutionRequestBuilder +{ + MavenExecutionRequest getMavenExecutionRequest( String[] args, PrintStream printStream ) + throws MavenExecutionRequestPopulationException, SettingsBuildingException, MavenExecutionRequestsBuilderException; +} diff --git a/maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java b/maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java new file mode 100755 index 0000000000..6b0a44aad4 --- /dev/null +++ b/maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java @@ -0,0 +1,33 @@ +package org.apache.maven.cli; + +/* + * 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. + */ + +/** + * @author Olivier Lamy + * @since + */ +public class MavenExecutionRequestsBuilderException + extends Exception +{ + public MavenExecutionRequestsBuilderException(String message, Throwable exception) + { + super( message, exception ); + } +} diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java new file mode 100755 index 0000000000..f1ce57b00f --- /dev/null +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java @@ -0,0 +1,118 @@ +/* + * The MIT License + * + * Copyright (c) 2004-2009, Sun Microsystems, Inc., + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package org.jvnet.hudson.maven3.launcher; + +import org.apache.maven.Maven; +import org.apache.maven.cli.MavenExecutionRequestBuilder; +import org.apache.maven.cli.MavenLoggerManager; +import org.apache.maven.cli.PrintStreamLogger; +import org.apache.maven.execution.ExecutionListener; +import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.execution.MavenExecutionResult; +import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult; + +/** + * @author olamy + * + */ +public class Maven3Launcher +{ + + private static HudsonMavenExecutionResult hudsonMavenExecutionResult; + + private static ExecutionListener mavenExecutionListener; + + public static ExecutionListener getMavenExecutionListener() + { + return mavenExecutionListener; + } + + public static void setMavenExecutionListener( ExecutionListener listener ) + { + mavenExecutionListener = listener; + } + + public static HudsonMavenExecutionResult getMavenExecutionResult() + { + return hudsonMavenExecutionResult; + } + + public static void setMavenExecutionResult( HudsonMavenExecutionResult result ) + { + hudsonMavenExecutionResult = result; + } + + public static int main( String[] args ) + throws Exception + { + ClassLoader orig = Thread.currentThread().getContextClassLoader(); + try + { + + ClassRealm containerRealm = (ClassRealm) Thread.currentThread().getContextClassLoader(); + + ContainerConfiguration cc = new DefaultContainerConfiguration().setName( "maven" ) + .setRealm( containerRealm ); + + DefaultPlexusContainer container = new DefaultPlexusContainer( cc ); + MavenLoggerManager mavenLoggerManager = new MavenLoggerManager( new PrintStreamLogger( System.out ) ); + container.setLoggerManager( mavenLoggerManager ); + + Maven maven = (Maven) container.lookup( "org.apache.maven.Maven", "default" ); + MavenExecutionRequest request = getMavenExecutionRequest( args, container ); + + hudsonMavenExecutionResult = new HudsonMavenExecutionResult( maven.execute( request ) ); + System.out.println("---- mavenExecutionResult ----"); + System.out.println( "mavenExecutionResult.getMavenProjectInfos().size() " + hudsonMavenExecutionResult.getMavenProjectInfos().size() ); + System.out.println("---- mavenExecutionResult ----"); + + // we don't care about cli mavenExecutionResult will be study in the the plugin + return 0;// cli.doMain( args, null ); + } + catch ( ComponentLookupException e ) + { + throw new Exception( e.getMessage(), e ); + } + finally + { + Thread.currentThread().setContextClassLoader( orig ); + } + } + + private static MavenExecutionRequest getMavenExecutionRequest( String[] args, DefaultPlexusContainer container ) + throws Exception + { + MavenExecutionRequestBuilder mavenExecutionRequestBuilder = container + .lookup( MavenExecutionRequestBuilder.class ); + MavenExecutionRequest request = mavenExecutionRequestBuilder.getMavenExecutionRequest( args, System.out ); + if ( mavenExecutionListener != null ) + { + request.setExecutionListener( mavenExecutionListener ); + } + return request; + } + +} diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java new file mode 100755 index 0000000000..e7c4d24830 --- /dev/null +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java @@ -0,0 +1,61 @@ +/** + * + */ +package org.jvnet.hudson.maven3.listeners; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.apache.maven.execution.BuildSummary; +import org.apache.maven.execution.MavenExecutionResult; +import org.apache.maven.project.MavenProject; + +/** + * @author Olivier Lamy + * @since + */ +public class HudsonMavenExecutionResult implements Serializable +{ + List throwables = new ArrayList(); + + List mavenProjectInfos = new ArrayList(); + + public HudsonMavenExecutionResult(MavenExecutionResult mavenExecutionResult) + { + if (mavenExecutionResult == null) + { + return; + } + throwables = mavenExecutionResult.getExceptions(); + List mavenProjects = mavenExecutionResult.getTopologicallySortedProjects(); + for (MavenProject mavenProject : mavenProjects) + { + MavenProjectInfo mavenProjectInfo = new MavenProjectInfo( mavenProject ); + mavenProjectInfos.add( mavenProjectInfo ); + BuildSummary buildSummary = mavenExecutionResult.getBuildSummary( mavenProject ); + mavenProjectInfo.setBuildTime( buildSummary.getTime() ); + + } + } + + public List getThrowables() + { + return throwables; + } + + public void setThrowables( List throwables ) + { + this.throwables = throwables; + } + + public List getMavenProjectInfos() + { + return mavenProjectInfos; + } + + public void setMavenProjectInfos( List mavenProjectInfos ) + { + this.mavenProjectInfos = mavenProjectInfos; + } +} diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java new file mode 100755 index 0000000000..401ef433ff --- /dev/null +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java @@ -0,0 +1,50 @@ +/** + * + */ +package org.jvnet.hudson.maven3.listeners; + +import java.io.Serializable; +import java.util.List; + +import org.apache.maven.project.ProjectBuildingResult; + +/** + * @author olamy + * created 9 août 2010 + * @since + * @version $Id$ + */ +public class MavenProjectBuildResult implements Serializable +{ + private MavenProjectInfo mavenProjectInfo; + + public MavenProjectBuildResult() + { + // no op + } + + public MavenProjectBuildResult( ProjectBuildingResult projectBuildingResult ) + { + // no op + this.mavenProjectInfo = new MavenProjectInfo( projectBuildingResult.getProject() ); + } + + public MavenProjectInfo getMavenProjectInfo() + { + return mavenProjectInfo; + } + + public void setMavenProjectInfo( MavenProjectInfo mavenProjectInfo ) + { + this.mavenProjectInfo = mavenProjectInfo; + } + + @Override + public String toString() + { + return mavenProjectInfo == null ? "null mavenProjectInfo" : this.mavenProjectInfo.toString(); + } + + + +} diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java new file mode 100755 index 0000000000..5b6fd1823f --- /dev/null +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java @@ -0,0 +1,119 @@ +/* + * The MIT License + * + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Olivier Lamy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jvnet.hudson.maven3.listeners; + +import java.io.Serializable; + +import org.apache.maven.project.MavenProject; + +/** + * @author olamy + * created 9 août 2010 + * @since + * @version $Id$ + */ +public class MavenProjectInfo implements Serializable +{ + + private String displayName; + + private String groupId; + + private String artifactId; + + private String version; + + private long buildTime; + + public MavenProjectInfo() + { + // no-op + } + + public MavenProjectInfo(MavenProject mavenProject) + { + this.displayName = mavenProject.getName(); + this.groupId= mavenProject.getGroupId(); + this.artifactId = mavenProject.getArtifactId(); + this.version = mavenProject.getVersion(); + } + + public long getBuildTime() + { + return buildTime; + } + + public void setBuildTime( long buildTime ) + { + this.buildTime = buildTime; + } + + public String getDisplayName() + { + return displayName; + } + + public void setDisplayName( String displayName ) + { + this.displayName = displayName; + } + + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public String getArtifactId() + { + return artifactId; + } + + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } + + public String getVersion() + { + return version; + } + + public void setVersion( String version ) + { + this.version = version; + } + + @Override + public String toString() + { + return groupId + ":" + artifactId + ":" + version; + } + + +} diff --git a/pom.xml b/pom.xml index d4423b8c93..48969c6c53 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,8 @@ THE SOFTWARE. ui-samples-plugin maven-agent maven-interceptor + maven3-agent + maven3-listener war test cli @@ -197,7 +199,9 @@ THE SOFTWARE. + org.apache.maven.plugins maven-enforcer-plugin + 1.0-beta-1 @@ -248,10 +252,55 @@ THE SOFTWARE. true
+ + + + + org.apache.maven + maven-core + 3.0 + + + org.apache.maven + maven-compat + 3.0 + + + org.apache.maven + maven-aether-provider + 3.0 + + + org.apache.maven + maven-embedder + 3.0 + + + org.sonatype.sisu + sisu-inject-plexus + 1.4.2 + + + org.codehaus.plexus + plexus-classworlds + 2.2.3 + + + org.apache.ant + ant + 1.8.0 + + + junit + junit + 4.8.1 + + + - 2.0.9 - 2.0.4 + 3.0 + UTF-8 @@ -348,6 +397,37 @@ THE SOFTWARE. + + m2e + + target + + + + m2e.version + + + + ${m2BuildDirectory} + + + org.maven.ide.eclipse + lifecycle-mapping + 0.10.0 + + customizable + + + + + + org.apache.maven.plugins:maven-resources-plugin:: + + + + + + diff --git a/remoting/src/main/java/hudson/remoting/UserRequest.java b/remoting/src/main/java/hudson/remoting/UserRequest.java index 693796171a..a95221fbd0 100644 --- a/remoting/src/main/java/hudson/remoting/UserRequest.java +++ b/remoting/src/main/java/hudson/remoting/UserRequest.java @@ -108,7 +108,9 @@ final class UserRequest extends Request Date: Thu, 4 Nov 2010 23:43:50 +0000 Subject: [PATCH 0003/2361] add FIXME for other maven 3 switch build to do. git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36654 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/maven/MavenBuild.java | 74 ++++++++++++++----- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenBuild.java index c3eb1458d8..6f847feff9 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuild.java @@ -30,6 +30,7 @@ import hudson.slaves.WorkspaceList; import hudson.slaves.WorkspaceList.Lease; import hudson.maven.agent.AbortException; import hudson.model.BuildListener; +import hudson.model.Computer; import hudson.model.Result; import hudson.model.Run; import hudson.model.Environment; @@ -40,8 +41,10 @@ import hudson.remoting.Channel; import hudson.scm.ChangeLogSet; import hudson.scm.ChangeLogSet.Entry; import hudson.tasks.BuildWrapper; +import hudson.tasks.Maven.MavenInstallation; import hudson.util.ArgumentListBuilder; import org.apache.maven.BuildFailureException; +import org.apache.maven.artifact.versioning.ComparableVersion; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; import org.apache.maven.lifecycle.LifecycleExecutionException; @@ -522,8 +525,31 @@ public class MavenBuild extends AbstractMavenBuild { EnvVars envVars = getEnvironment(listener); // buildEnvironments should be set up first - ProcessCache.MavenProcess process = mavenProcessCache.get(launcher.getChannel(), listener, - new MavenProcessFactory(getParent().getParent(),launcher,envVars,null)); + MavenInstallation mvn = getProject().getParent().getMaven(); + + mvn = mvn.forEnvironment(envVars).forNode(Computer.currentComputer().getNode(), listener); + + String mavenVersion = getModuleRoot().act( new MavenVersionCallable( mvn.getHome() )); + + ProcessCache.MavenProcess process = null; + + boolean maven3orLater = new ComparableVersion (mavenVersion).compareTo( new ComparableVersion ("3.0") ) >= 0; + + if ( maven3orLater ) + { + process = + MavenBuild.mavenProcessCache.get( launcher.getChannel(), listener, + new Maven3ProcessFactory( getParent().getParent(), launcher, + envVars, null ) ); + } + else + { + process = + MavenBuild.mavenProcessCache.get( launcher.getChannel(), listener, + new MavenProcessFactory( getParent().getParent(), launcher, + envVars, null ) ); + } + ArgumentListBuilder margs = new ArgumentListBuilder("-N","-B"); if(mms.usesPrivateRepository()) @@ -538,25 +564,33 @@ public class MavenBuild extends AbstractMavenBuild { systemProps.put("hudson.build.number",String.valueOf(getNumber())); boolean normalExit = false; - try { - Result r = process.call(new Builder( - listener,new ProxyImpl(), - reporters.toArray(new MavenReporter[reporters.size()]), margs.toList(), systemProps)); - normalExit = true; - return r; - } finally { - if(normalExit) process.recycle(); - else process.discard(); - - // tear down in reverse order - boolean failed=false; - for( int i=buildEnvironments.size()-1; i>=0; i-- ) { - if (!buildEnvironments.get(i).tearDown(MavenBuild.this,listener)) { - failed=true; - } + if (maven3orLater) + { + // FIXME here for maven 3 builds + return Result.ABORTED; + } + else + { + try { + Result r = process.call(new Builder( + listener,new ProxyImpl(), + reporters.toArray(new MavenReporter[reporters.size()]), margs.toList(), systemProps)); + normalExit = true; + return r; + } finally { + if(normalExit) process.recycle(); + else process.discard(); + + // tear down in reverse order + boolean failed=false; + for( int i=buildEnvironments.size()-1; i>=0; i-- ) { + if (!buildEnvironments.get(i).tearDown(MavenBuild.this,listener)) { + failed=true; + } + } + // WARNING The return in the finally clause will trump any return before + if (failed) return Result.FAILURE; } - // WARNING The return in the finally clause will trump any return before - if (failed) return Result.FAILURE; } } -- GitLab From 3a3a39c1ca460d003b1dcb9af12413324697a023 Mon Sep 17 00:00:00 2001 From: olamy Date: Fri, 5 Nov 2010 18:58:54 +0000 Subject: [PATCH 0004/2361] [HUDSON-4988] push some stuff to work in other laptop. git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36677 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/maven/Maven3Builder.java | 164 ++++++++++++++++-- .../main/java/hudson/maven/MavenBuilder.java | 24 ++- .../hudson/maven/MavenModuleSetBuild.java | 4 +- .../maven3/launcher/Maven3Launcher.java | 6 +- .../listeners/HudsonMavenBuildHelper.java | 75 ++++++++ 5 files changed, 243 insertions(+), 30 deletions(-) create mode 100644 maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index a9ec111025..b9936e029d 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -23,6 +23,7 @@ */ package hudson.maven; +import hudson.maven.MavenBuild.ProxyImpl2; import hudson.model.BuildListener; import hudson.model.Hudson; import hudson.model.Result; @@ -37,15 +38,28 @@ import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.text.NumberFormat; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import org.apache.maven.execution.AbstractExecutionListener; import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.ExecutionListener; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.MavenPluginManager; +import org.apache.maven.plugin.Mojo; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.PluginConfigurationException; +import org.apache.maven.plugin.PluginContainerException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.jvnet.hudson.maven3.agent.Maven3Main; import org.jvnet.hudson.maven3.launcher.Maven3Launcher; +import org.jvnet.hudson.maven3.listeners.HudsonMavenBuildHelper; import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult; /** @@ -68,8 +82,24 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal HudsonMavenExecutionResult mavenExecutionResult; - protected Maven3Builder(BuildListener listener, List goals, Map systemProps) { + private final Map proxies; + private final Map> reporters = new HashMap>(); + private final Map> executedMojos = new HashMap>(); + private long mojoStartTime; + private Collection modules; + private MavenBuildProxy2 lastProxy; + + protected Maven3Builder(BuildListener listener,Map proxies, Collection modules, List goals, Map systemProps) { super( listener, goals, systemProps ); + this.proxies = new HashMap(proxies); + for (Entry e : this.proxies.entrySet()) + e.setValue(new FilterImpl(e.getValue())); + + for (MavenModule m : modules) + { + reporters.put(m.getModuleName(),m.createReporters()); + } + this.modules = modules; } public Result call() @@ -92,6 +122,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal listener.getLogger().println(formatArgs(goals)); + int r = Maven3Main.launch( goals.toArray(new String[goals.size()])); // now check the completion status of async ops @@ -167,43 +198,100 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal return Hudson.getInstance().getPluginManager().uberClassLoader; } + private class FilterImpl extends MavenBuildProxy2.Filter implements Serializable { + public FilterImpl(MavenBuildProxy2 core) { + super(core); + } + + @Override + public void executeAsync(final BuildCallable program) throws IOException { + futures.add(Channel.current().callAsync(new AsyncInvoker(core,program))); + } + + private static final long serialVersionUID = 1L; + } private static final class MavenExecutionListener extends AbstractExecutionListener implements Serializable, ExecutionListener { private final Maven3Builder maven3Builder; + + private ExpressionEvaluator expressionEvaluator; + + private MavenSession mavenSession; + + private MavenPluginManager mavenPluginManager; /** * Number of total nanoseconds {@link Maven3Builder} spent. */ long overheadTime; - - public MavenExecutionListener(Maven3Builder listener) { - this.maven3Builder = listener; + + + private final Map proxies; + + private final Map> reporters = new HashMap>(); + + public MavenExecutionListener(Maven3Builder maven3Builder) { + this.maven3Builder = maven3Builder; + expressionEvaluator = HudsonMavenBuildHelper.getEvaluator(); + mavenPluginManager = HudsonMavenBuildHelper.getMavenPluginManager(); + this.proxies = new HashMap(maven3Builder.proxies); + for (Entry e : this.proxies.entrySet()) + { + e.setValue(maven3Builder.new FilterImpl(e.getValue())); + } + for (MavenModule m : maven3Builder.modules) + { + reporters.put(m.getModuleName(),m.createReporters()); + } + } + + private MavenBuildProxy2 getMavenBuildProxy2(MavenProject mavenProject) + { + for (Entry entry : proxies.entrySet()) + { + if (entry.getKey().compareTo( new ModuleName( mavenProject ) ) == 0) + { + return entry.getValue(); + } + } + return null; + } + + private Mojo getMojo(MojoExecution mojoExecution) + { + try + { + return mavenPluginManager.getConfiguredMojo( Mojo.class, mavenSession, mojoExecution ); + } + catch ( PluginContainerException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + catch ( PluginConfigurationException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } } + /** * @see org.apache.maven.execution.ExecutionListener#projectDiscoveryStarted(org.apache.maven.execution.ExecutionEvent) */ - public void projectDiscoveryStarted( ExecutionEvent event ) - { - - } + public void projectDiscoveryStarted( ExecutionEvent event ) { } /** * @see org.apache.maven.execution.ExecutionListener#sessionStarted(org.apache.maven.execution.ExecutionEvent) */ public void sessionStarted( ExecutionEvent event ) { - + this.mavenSession = event.getSession(); } /** * @see org.apache.maven.execution.ExecutionListener#sessionEnded(org.apache.maven.execution.ExecutionEvent) */ - public void sessionEnded( ExecutionEvent event ) - { - - } + public void sessionEnded( ExecutionEvent event ) { } /** * @see org.apache.maven.execution.ExecutionListener#projectSkipped(org.apache.maven.execution.ExecutionEvent) @@ -221,6 +309,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal maven3Builder.listener.getLogger().println( "projectStarted in MavenExecutionListener " + event.getProject().getGroupId() + ":" + event.getProject().getArtifactId() ); + } /** @@ -253,6 +342,32 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal public void mojoStarted( ExecutionEvent event ) { maven3Builder.listener.getLogger().println("mojoStarted " + event.getMojoExecution().getArtifactId()); + MavenProject mavenProject = event.getProject(); + XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ); + + Mojo mojo = getMojo( event.getMojoExecution() ); + + MojoInfo mojoInfo = new MojoInfo( event.getMojoExecution(), null, xmlPlexusConfiguration, expressionEvaluator ); + + List mavenReporters = reporters.get( mavenProject.getArtifactId() ); + if (mavenReporters != null) + { + for (MavenReporter mavenReporter : mavenReporters) + { + try + { + mavenReporter.preExecute( getMavenBuildProxy2( mavenProject ), mavenProject, mojoInfo, maven3Builder.listener); + } + catch ( InterruptedException e ) + { + e.printStackTrace(); + } + catch ( IOException e ) + { + e.printStackTrace(); + } + } + } } /** @@ -261,6 +376,19 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal public void mojoSucceeded( ExecutionEvent event ) { maven3Builder.listener.getLogger().println("mojoSucceeded " + event.getMojoExecution().getArtifactId()); + + //maven3Builder.proxies + + MavenProject mavenProject = event.getProject(); + + List mavenReporters = maven3Builder.reporters.get( mavenProject.getArtifactId() ); + if (mavenReporters != null) + { + for (MavenReporter mavenReporter : mavenReporters) + { + //mavenReporter.end( build, launcher, listener ) + } + } } /** @@ -319,6 +447,16 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal } + public ExpressionEvaluator getExpressionEvaluator() + { + return expressionEvaluator; + } + public void setExpressionEvaluator( ExpressionEvaluator expressionEvaluator ) + { + this.expressionEvaluator = expressionEvaluator; + } + + } public static boolean markAsSuccess; diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java index 0ff3223544..ea677769d3 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java @@ -1,7 +1,8 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, + * Olivier Lamy * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -214,19 +215,17 @@ public abstract class MavenBuilder extends AbstractMavenBuilder implements Deleg throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { - Class pluginManagerInterceptorClazz = - Thread.currentThread().getContextClassLoader().loadClass( "hudson.maven.agent.PluginManagerInterceptor" ); - Method setListenerMethod = - pluginManagerInterceptorClazz.getMethod( "setListener", - new Class[] { Thread.currentThread().getContextClassLoader().loadClass( "hudson.maven.agent.PluginManagerListener" ) } ); + Class pluginManagerInterceptorClazz = Thread.currentThread().getContextClassLoader() + .loadClass( "hudson.maven.agent.PluginManagerInterceptor" ); + Method setListenerMethod = pluginManagerInterceptorClazz.getMethod( "setListener", new Class[] { Thread + .currentThread().getContextClassLoader().loadClass( "hudson.maven.agent.PluginManagerListener" ) } ); setListenerMethod.invoke( null, new Object[] { pluginManagerListener } ); - Class lifecycleInterceptorClazz = - Thread.currentThread().getContextClassLoader().loadClass( "org.apache.maven.lifecycle.LifecycleExecutorInterceptor" ); + Class lifecycleInterceptorClazz = Thread.currentThread().getContextClassLoader() + .loadClass( "org.apache.maven.lifecycle.LifecycleExecutorInterceptor" ); - setListenerMethod = - lifecycleInterceptorClazz.getMethod( "setListener", - new Class[] { Thread.currentThread().getContextClassLoader().loadClass( "org.apache.maven.lifecycle.LifecycleExecutorListener" ) } ); + setListenerMethod = lifecycleInterceptorClazz.getMethod( "setListener", new Class[] { Thread.currentThread() + .getContextClassLoader().loadClass( "org.apache.maven.lifecycle.LifecycleExecutorListener" ) } ); setListenerMethod.invoke( null, new Object[] { pluginManagerListener } ); } @@ -255,8 +254,7 @@ public abstract class MavenBuilder extends AbstractMavenBuilder implements Deleg } catch ( IllegalAccessException e ) { - // TODO Auto-generated catch block - e.printStackTrace(); + throw new RuntimeException( e.getMessage(), e ); } catch ( InvocationTargetException e ) { diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index a19f972609..e79608207b 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -2,7 +2,7 @@ * The MIT License * * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, - * Red Hat, Inc., Victor Glushenkov, Alan Harder + * Red Hat, Inc., Victor Glushenkov, Alan Harder, Olivier Lamy * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -517,7 +517,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild Date: Fri, 5 Nov 2010 22:43:29 +0000 Subject: [PATCH 0005/2361] [HUDSON-4988] cleanup stuff which failed in previous commit. git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36682 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/maven/Maven3Builder.java | 59 +++++++------------ .../hudson/maven/MavenModuleSetBuild.java | 8 ++- .../maven3/launcher/Maven3Launcher.java | 4 +- .../listeners/HudsonMavenBuildHelper.java | 13 +--- 4 files changed, 31 insertions(+), 53 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index b9936e029d..e34cf4f291 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -38,7 +38,6 @@ import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.text.NumberFormat; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -54,6 +53,7 @@ import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginContainerException; +import org.apache.maven.plugin.PluginParameterExpressionEvaluator; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; @@ -86,20 +86,15 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal private final Map> reporters = new HashMap>(); private final Map> executedMojos = new HashMap>(); private long mojoStartTime; - private Collection modules; private MavenBuildProxy2 lastProxy; - protected Maven3Builder(BuildListener listener,Map proxies, Collection modules, List goals, Map systemProps) { + protected Maven3Builder(BuildListener listener,Map proxies, Map> reporters, List goals, Map systemProps) { super( listener, goals, systemProps ); this.proxies = new HashMap(proxies); for (Entry e : this.proxies.entrySet()) e.setValue(new FilterImpl(e.getValue())); - for (MavenModule m : modules) - { - reporters.put(m.getModuleName(),m.createReporters()); - } - this.modules = modules; + this.reporters.putAll( reporters ); } public Result call() @@ -215,13 +210,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal private static final class MavenExecutionListener extends AbstractExecutionListener implements Serializable, ExecutionListener { private final Maven3Builder maven3Builder; - - private ExpressionEvaluator expressionEvaluator; - - private MavenSession mavenSession; - - private MavenPluginManager mavenPluginManager; - + /** * Number of total nanoseconds {@link Maven3Builder} spent. */ @@ -234,17 +223,12 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal public MavenExecutionListener(Maven3Builder maven3Builder) { this.maven3Builder = maven3Builder; - expressionEvaluator = HudsonMavenBuildHelper.getEvaluator(); - mavenPluginManager = HudsonMavenBuildHelper.getMavenPluginManager(); this.proxies = new HashMap(maven3Builder.proxies); for (Entry e : this.proxies.entrySet()) { e.setValue(maven3Builder.new FilterImpl(e.getValue())); } - for (MavenModule m : maven3Builder.modules) - { - reporters.put(m.getModuleName(),m.createReporters()); - } + this.reporters.putAll( new HashMap>(maven3Builder.reporters) ); } private MavenBuildProxy2 getMavenBuildProxy2(MavenProject mavenProject) @@ -259,11 +243,12 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal return null; } - private Mojo getMojo(MojoExecution mojoExecution) + private Mojo getMojo(MojoExecution mojoExecution, MavenSession mavenSession) { try { - return mavenPluginManager.getConfiguredMojo( Mojo.class, mavenSession, mojoExecution ); + return HudsonMavenBuildHelper.getMavenPluginManager().getConfiguredMojo( Mojo.class, mavenSession, + mojoExecution ); } catch ( PluginContainerException e ) { @@ -285,7 +270,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void sessionStarted( ExecutionEvent event ) { - this.mavenSession = event.getSession(); } /** @@ -335,6 +319,11 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal { } + + private ExpressionEvaluator getExpressionEvaluator(MavenSession session, MojoExecution mojoExecution) + { + return new PluginParameterExpressionEvaluator( session, mojoExecution ); + } /** * @see org.apache.maven.execution.ExecutionListener#mojoStarted(org.apache.maven.execution.ExecutionEvent) @@ -345,10 +334,12 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal MavenProject mavenProject = event.getProject(); XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ); - Mojo mojo = getMojo( event.getMojoExecution() ); - - MojoInfo mojoInfo = new MojoInfo( event.getMojoExecution(), null, xmlPlexusConfiguration, expressionEvaluator ); - + Mojo mojo = getMojo( event.getMojoExecution(), event.getSession() ); + + MojoInfo mojoInfo = + new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration, + getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) ); + List mavenReporters = reporters.get( mavenProject.getArtifactId() ); if (mavenReporters != null) { @@ -445,17 +436,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal public void forkedProjectFailed( ExecutionEvent event ) { - } - - public ExpressionEvaluator getExpressionEvaluator() - { - return expressionEvaluator; - } - public void setExpressionEvaluator( ExpressionEvaluator expressionEvaluator ) - { - this.expressionEvaluator = expressionEvaluator; - } - + } } diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index e79608207b..6da92d72d9 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -517,7 +517,13 @@ public class MavenModuleSetBuild extends AbstractMavenBuild> reporters = new HashMap>(project.sortedActiveModules.size()); + for (MavenModule mavenModule : project.sortedActiveModules) + { + reporters.put( mavenModule.getModuleName(), mavenModule.createReporters() ); + } + Maven3Builder maven3Builder = new Maven3Builder( slistener, proxies, reporters, margs.toList(), envVars ); MavenProbeAction mpa=null; try { mpa = new MavenProbeAction(project,process.channel); diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java index c8ddf0b17b..1aa7bf1cfb 100755 --- a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java @@ -32,6 +32,7 @@ import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.jvnet.hudson.maven3.listeners.HudsonMavenBuildHelper; import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult; /** @@ -80,8 +81,6 @@ public class Maven3Launcher DefaultPlexusContainer container = new DefaultPlexusContainer( cc ); MavenLoggerManager mavenLoggerManager = new MavenLoggerManager( new PrintStreamLogger( System.out ) ); container.setLoggerManager( mavenLoggerManager ); - - ExpressionEvaluator expressionEvaluator = container.lookup( ExpressionEvaluator.class ); Maven maven = (Maven) container.lookup( "org.apache.maven.Maven", "default" ); MavenExecutionRequest request = getMavenExecutionRequest( args, container ); @@ -107,6 +106,7 @@ public class Maven3Launcher private static MavenExecutionRequest getMavenExecutionRequest( String[] args, DefaultPlexusContainer container ) throws Exception { + HudsonMavenBuildHelper hudsonMavenBuildHelper = container.lookup( HudsonMavenBuildHelper.class ); MavenExecutionRequestBuilder mavenExecutionRequestBuilder = container .lookup( MavenExecutionRequestBuilder.class ); MavenExecutionRequest request = mavenExecutionRequestBuilder.getMavenExecutionRequest( args, System.out ); diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java index c4da6aca11..631823b734 100644 --- a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java @@ -25,8 +25,6 @@ import javax.inject.Inject; import org.apache.maven.plugin.MavenPluginManager; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; @@ -39,9 +37,8 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce public class HudsonMavenBuildHelper implements Initializable { - // must be available in a static way - private static ExpressionEvaluator evaluator; - + // must be available in a static way weird + // and not really good design ! private static MavenPluginManager mavenPluginManager; @Inject @@ -52,7 +49,6 @@ public class HudsonMavenBuildHelper implements Initializable { try { - evaluator = plexusContainer.lookup( ExpressionEvaluator.class ); mavenPluginManager = plexusContainer.lookup( MavenPluginManager.class ); } catch ( ComponentLookupException e ) @@ -61,11 +57,6 @@ public class HudsonMavenBuildHelper implements Initializable } } - - public static ExpressionEvaluator getEvaluator() - { - return evaluator; - } public static MavenPluginManager getMavenPluginManager() { -- GitLab From b3b902a50ab8f4aa337e73c50a5cb022df033e74 Mon Sep 17 00:00:00 2001 From: olamy Date: Sat, 6 Nov 2010 08:59:13 +0000 Subject: [PATCH 0006/2361] [HUDSON-4988] implements more MavenReporter call. still work in progress .... git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36695 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/maven/Maven3Builder.java | 147 ++++++++++++++++-- 1 file changed, 132 insertions(+), 15 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index e34cf4f291..9ddeddb818 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -243,6 +243,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal return null; } + // FIXME some reporters need the real mojo ?? so tricky to do ! private Mojo getMojo(MojoExecution mojoExecution, MavenSession mavenSession) { try @@ -260,6 +261,17 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal } } + + private ExpressionEvaluator getExpressionEvaluator(MavenSession session, MojoExecution mojoExecution) + { + return new PluginParameterExpressionEvaluator( session, mojoExecution ); + } + + private List getMavenReporters(MavenProject mavenProject) + { + return reporters.get( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ) ); + } + /** * @see org.apache.maven.execution.ExecutionListener#projectDiscoveryStarted(org.apache.maven.execution.ExecutionEvent) */ @@ -282,7 +294,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void projectSkipped( ExecutionEvent event ) { - + MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( event.getProject() ); + } /** @@ -293,6 +306,48 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal maven3Builder.listener.getLogger().println( "projectStarted in MavenExecutionListener " + event.getProject().getGroupId() + ":" + event.getProject().getArtifactId() ); + MavenProject mavenProject = event.getProject(); + List mavenReporters = getMavenReporters( mavenProject ); + + MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); + + if (mavenReporters != null) + { + for (MavenReporter mavenReporter : mavenReporters) + { + try + { + mavenReporter.enterModule( mavenBuildProxy2 ,mavenProject, maven3Builder.listener); + } + catch ( InterruptedException e ) + { + e.printStackTrace(); + } + catch ( IOException e ) + { + e.printStackTrace(); + } + } + } + + if (mavenReporters != null) + { + for (MavenReporter mavenReporter : mavenReporters) + { + try + { + mavenReporter.preBuild( mavenBuildProxy2 ,mavenProject, maven3Builder.listener); + } + catch ( InterruptedException e ) + { + e.printStackTrace(); + } + catch ( IOException e ) + { + e.printStackTrace(); + } + } + } } @@ -301,7 +356,52 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void projectSucceeded( ExecutionEvent event ) { - maven3Builder.listener.getLogger().println("projectSucceeded in adapter" ); + maven3Builder.listener.getLogger().println( "projectSucceeded in MavenExecutionListener " + + event.getProject().getGroupId() + ":" + + event.getProject().getArtifactId() ); + MavenProject mavenProject = event.getProject(); + List mavenReporters = getMavenReporters( mavenProject ); + + MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); + + if ( mavenReporters != null ) + { + for ( MavenReporter mavenReporter : mavenReporters ) + { + try + { + mavenReporter.leaveModule( mavenBuildProxy2, mavenProject, maven3Builder.listener); + } + catch ( InterruptedException e ) + { + e.printStackTrace(); + } + catch ( IOException e ) + { + e.printStackTrace(); + } + } + } + + if ( mavenReporters != null ) + { + for ( MavenReporter mavenReporter : mavenReporters ) + { + try + { + mavenReporter.postBuild( mavenBuildProxy2, mavenProject, maven3Builder.listener); + } + catch ( InterruptedException e ) + { + e.printStackTrace(); + } + catch ( IOException e ) + { + e.printStackTrace(); + } + } + } + } /** @@ -320,11 +420,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal } - private ExpressionEvaluator getExpressionEvaluator(MavenSession session, MojoExecution mojoExecution) - { - return new PluginParameterExpressionEvaluator( session, mojoExecution ); - } - /** * @see org.apache.maven.execution.ExecutionListener#mojoStarted(org.apache.maven.execution.ExecutionEvent) */ @@ -334,20 +429,23 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal MavenProject mavenProject = event.getProject(); XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ); - Mojo mojo = getMojo( event.getMojoExecution(), event.getSession() ); + Mojo mojo = null;//getMojo( event.getMojoExecution(), event.getSession() ); MojoInfo mojoInfo = new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration, getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) ); - List mavenReporters = reporters.get( mavenProject.getArtifactId() ); + List mavenReporters = getMavenReporters( mavenProject ); + + MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); + if (mavenReporters != null) { for (MavenReporter mavenReporter : mavenReporters) { try { - mavenReporter.preExecute( getMavenBuildProxy2( mavenProject ), mavenProject, mojoInfo, maven3Builder.listener); + mavenReporter.preExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener); } catch ( InterruptedException e ) { @@ -367,17 +465,36 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal public void mojoSucceeded( ExecutionEvent event ) { maven3Builder.listener.getLogger().println("mojoSucceeded " + event.getMojoExecution().getArtifactId()); - - //maven3Builder.proxies - MavenProject mavenProject = event.getProject(); + XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ); + + Mojo mojo = null;//getMojo( event.getMojoExecution(), event.getSession() ); + + MojoInfo mojoInfo = + new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration, + getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) ); + + List mavenReporters = getMavenReporters( mavenProject ); + + MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); - List mavenReporters = maven3Builder.reporters.get( mavenProject.getArtifactId() ); if (mavenReporters != null) { for (MavenReporter mavenReporter : mavenReporters) { - //mavenReporter.end( build, launcher, listener ) + try + { + // FIXME exception during mojo execution ? + mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, null); + } + catch ( InterruptedException e ) + { + e.printStackTrace(); + } + catch ( IOException e ) + { + e.printStackTrace(); + } } } } -- GitLab From eb00ae107dfa4bc8dceff13ce27a0d748ad762e3 Mon Sep 17 00:00:00 2001 From: olamy Date: Sat, 6 Nov 2010 09:02:11 +0000 Subject: [PATCH 0007/2361] fix comment git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36696 71c3de6d-444a-0410-be80-ed276b4c234a --- maven-plugin/src/main/java/hudson/maven/Maven3Builder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index 9ddeddb818..cc3ad8b6aa 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -243,7 +243,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal return null; } - // FIXME some reporters need the real mojo ?? so tricky to do ! + // FIXME MojoInfo need the real mojo ?? + // so tricky to do need to use MavenPluginManager on the current Maven Build private Mojo getMojo(MojoExecution mojoExecution, MavenSession mavenSession) { try -- GitLab From 25a6bded8c652f8e74cb573a4688a64c9e28f5cc Mon Sep 17 00:00:00 2001 From: olamy Date: Sat, 6 Nov 2010 21:56:37 +0000 Subject: [PATCH 0008/2361] call end for all MavenReporter. git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36722 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/maven/Maven3Builder.java | 44 ++++++++++++++++--- .../hudson/maven/MavenModuleSetBuild.java | 2 +- .../listeners/HudsonMavenExecutionResult.java | 15 ++++--- .../java/hudson/remoting/UserRequest.java | 2 - 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index cc3ad8b6aa..4e662f4483 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -23,6 +23,7 @@ */ package hudson.maven; +import hudson.Launcher; import hudson.maven.MavenBuild.ProxyImpl2; import hudson.model.BuildListener; import hudson.model.Hudson; @@ -83,6 +84,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal HudsonMavenExecutionResult mavenExecutionResult; private final Map proxies; + private final Map sourceProxies; private final Map> reporters = new HashMap>(); private final Map> executedMojos = new HashMap>(); private long mojoStartTime; @@ -90,6 +92,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal protected Maven3Builder(BuildListener listener,Map proxies, Map> reporters, List goals, Map systemProps) { super( listener, goals, systemProps ); + sourceProxies = new HashMap(proxies); this.proxies = new HashMap(proxies); for (Entry e : this.proxies.entrySet()) e.setValue(new FilterImpl(e.getValue())); @@ -157,15 +160,25 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal mavenExecutionResult = Maven3Launcher.getMavenExecutionResult(); + + //FIXME handle + //mavenExecutionResult.getThrowables() PrintStream logger = listener.getLogger(); logger.println("Maven3Builder classLoaderDebug"); logger.println("getClass().getClassLoader(): " + getClass().getClassLoader()); - if(r==0) { + if(r==0 && mavenExecutionResult.getThrowables().isEmpty()) { logger.print( "r==0" ); markAsSuccess = true; } + if (!mavenExecutionResult.getThrowables().isEmpty()) { + logger.println( "mavenExecutionResult.throwables not empty"); + for(Throwable throwable : mavenExecutionResult.getThrowables()) { + throwable.printStackTrace( logger ); + } + markAsSuccess = false; + } if(markAsSuccess) { // FIXME message @@ -192,6 +205,23 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal public ClassLoader getClassLoader() { return Hudson.getInstance().getPluginManager().uberClassLoader; } + + + /** + * Invoked after the maven has finished running, and in the master, not in the maven process. + */ + void end(Launcher launcher) throws IOException, InterruptedException { + for (Map.Entry e : sourceProxies.entrySet()) { + ProxyImpl2 p = e.getValue(); + for (MavenReporter r : reporters.get(e.getKey())) { + // we'd love to do this when the module build ends, but doing so requires + // we know how many task segments are in the current build. + r.end(p.owner(),launcher,listener); + p.appendLastLog(); + } + p.close(); + } + } private class FilterImpl extends MavenBuildProxy2.Filter implements Serializable { public FilterImpl(MavenBuildProxy2 core) { @@ -262,7 +292,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal } } - private ExpressionEvaluator getExpressionEvaluator(MavenSession session, MojoExecution mojoExecution) { return new PluginParameterExpressionEvaluator( session, mojoExecution ); @@ -276,7 +305,9 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#projectDiscoveryStarted(org.apache.maven.execution.ExecutionEvent) */ - public void projectDiscoveryStarted( ExecutionEvent event ) { } + public void projectDiscoveryStarted( ExecutionEvent event ) + { + } /** * @see org.apache.maven.execution.ExecutionListener#sessionStarted(org.apache.maven.execution.ExecutionEvent) @@ -288,7 +319,10 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#sessionEnded(org.apache.maven.execution.ExecutionEvent) */ - public void sessionEnded( ExecutionEvent event ) { } + public void sessionEnded( ExecutionEvent event ) + { + maven3Builder.listener.getLogger().println( "sessionEnded in MavenExecutionListener " ); + } /** * @see org.apache.maven.execution.ExecutionListener#projectSkipped(org.apache.maven.execution.ExecutionEvent) @@ -431,7 +465,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ); Mojo mojo = null;//getMojo( event.getMojoExecution(), event.getSession() ); - + MojoInfo mojoInfo = new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration, getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) ); diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 6da92d72d9..d3b39a5929 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -531,7 +531,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild mavenProjects = mavenExecutionResult.getTopologicallySortedProjects(); - for (MavenProject mavenProject : mavenProjects) + if (mavenProjects != null) { - MavenProjectInfo mavenProjectInfo = new MavenProjectInfo( mavenProject ); - mavenProjectInfos.add( mavenProjectInfo ); - BuildSummary buildSummary = mavenExecutionResult.getBuildSummary( mavenProject ); - mavenProjectInfo.setBuildTime( buildSummary.getTime() ); - + for (MavenProject mavenProject : mavenProjects) + { + MavenProjectInfo mavenProjectInfo = new MavenProjectInfo( mavenProject ); + mavenProjectInfos.add( mavenProjectInfo ); + BuildSummary buildSummary = mavenExecutionResult.getBuildSummary( mavenProject ); + mavenProjectInfo.setBuildTime( buildSummary.getTime() ); + } } } diff --git a/remoting/src/main/java/hudson/remoting/UserRequest.java b/remoting/src/main/java/hudson/remoting/UserRequest.java index a95221fbd0..693796171a 100644 --- a/remoting/src/main/java/hudson/remoting/UserRequest.java +++ b/remoting/src/main/java/hudson/remoting/UserRequest.java @@ -108,9 +108,7 @@ final class UserRequest extends Request Date: Sat, 6 Nov 2010 22:54:09 +0000 Subject: [PATCH 0009/2361] record ExecutedMojos git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36727 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/maven/Maven3Builder.java | 51 ++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index 4e662f4483..55337b52ff 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -39,17 +39,19 @@ import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.text.NumberFormat; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ExecutionException; import org.apache.maven.execution.AbstractExecutionListener; import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.ExecutionListener; import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.MavenPluginManager; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.PluginConfigurationException; @@ -86,9 +88,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal private final Map proxies; private final Map sourceProxies; private final Map> reporters = new HashMap>(); - private final Map> executedMojos = new HashMap>(); - private long mojoStartTime; - private MavenBuildProxy2 lastProxy; protected Maven3Builder(BuildListener listener,Map proxies, Map> reporters, List goals, Map systemProps) { super( listener, goals, systemProps ); @@ -104,9 +103,10 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal throws IOException { + MavenExecutionListener mavenExecutionListener = new MavenExecutionListener( this ); try { futures = new ArrayList>(); - MavenExecutionListener mavenExecutionListener = new MavenExecutionListener( this ); + Maven3Launcher.setMavenExecutionListener( mavenExecutionListener ); markAsSuccess = false; @@ -167,7 +167,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal logger.println("Maven3Builder classLoaderDebug"); logger.println("getClass().getClassLoader(): " + getClass().getClassLoader()); - if(r==0 && mavenExecutionResult.getThrowables().isEmpty()) { logger.print( "r==0" ); markAsSuccess = true; @@ -249,7 +248,11 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal private final Map proxies; + private final Map> executedMojosPerModule = new ConcurrentHashMap>(); + private final Map> reporters = new HashMap>(); + + private final Map currentMojoStartPerModuleName = new ConcurrentHashMap(); public MavenExecutionListener(Maven3Builder maven3Builder) { this.maven3Builder = maven3Builder; @@ -257,8 +260,11 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal for (Entry e : this.proxies.entrySet()) { e.setValue(maven3Builder.new FilterImpl(e.getValue())); + executedMojosPerModule.put( e.getKey(), new CopyOnWriteArrayList() ); } this.reporters.putAll( new HashMap>(maven3Builder.reporters) ); + + } private MavenBuildProxy2 getMavenBuildProxy2(MavenProject mavenProject) @@ -302,6 +308,19 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal return reporters.get( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ) ); } + private void initMojoStartTime( MavenProject mavenProject) + { + this.currentMojoStartPerModuleName.put( new ModuleName( mavenProject.getGroupId(), + mavenProject.getArtifactId() ), + Long.valueOf( new Date().getTime() ) ); + } + + private Long getMojoStartTime(MavenProject mavenProject) + { + return currentMojoStartPerModuleName.get( new ModuleName( mavenProject.getGroupId(), + mavenProject.getArtifactId() ) ); + } + /** * @see org.apache.maven.execution.ExecutionListener#projectDiscoveryStarted(org.apache.maven.execution.ExecutionEvent) */ @@ -436,6 +455,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal } } } + + mavenBuildProxy2.setExecutedMojos( this.executedMojosPerModule.get( new ModuleName( event.getProject() ) ) ); } @@ -460,7 +481,9 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void mojoStarted( ExecutionEvent event ) { + initMojoStartTime( event.getProject() ); maven3Builder.listener.getLogger().println("mojoStarted " + event.getMojoExecution().getArtifactId()); + MavenProject mavenProject = event.getProject(); XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ); @@ -499,6 +522,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void mojoSucceeded( ExecutionEvent event ) { + Long startTime = getMojoStartTime( event.getProject() ); + Date endTime = new Date(); maven3Builder.listener.getLogger().println("mojoSucceeded " + event.getMojoExecution().getArtifactId()); MavenProject mavenProject = event.getProject(); XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ); @@ -509,6 +534,20 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration, getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) ); + try + { + ExecutedMojo executedMojo = + new ExecutedMojo( mojoInfo, startTime == null ? 0 : endTime.getTime() - startTime.longValue() ); + this.executedMojosPerModule.get( new ModuleName( mavenProject.getGroupId(), + mavenProject.getArtifactId() ) ).add( executedMojo ); + } + catch ( Exception e ) + { + // ignoring this + maven3Builder.listener.getLogger().println( "ignoring exception during new ExecutedMojo " + + e.getMessage() ); + } + List mavenReporters = getMavenReporters( mavenProject ); MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); -- GitLab From e6e2ce165c095b749c8af6c89986326f0f9d4930 Mon Sep 17 00:00:00 2001 From: olamy Date: Sat, 6 Nov 2010 22:56:32 +0000 Subject: [PATCH 0010/2361] [HUDSON-4988] reccord ExecutedMojos after each mojo execution end. git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36728 71c3de6d-444a-0410-be80-ed276b4c234a --- maven-plugin/src/main/java/hudson/maven/Maven3Builder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index 55337b52ff..0523772d58 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -455,8 +455,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal } } } - - mavenBuildProxy2.setExecutedMojos( this.executedMojosPerModule.get( new ModuleName( event.getProject() ) ) ); } @@ -540,6 +538,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal new ExecutedMojo( mojoInfo, startTime == null ? 0 : endTime.getTime() - startTime.longValue() ); this.executedMojosPerModule.get( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ) ).add( executedMojo ); + } catch ( Exception e ) { @@ -552,6 +551,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); + mavenBuildProxy2.setExecutedMojos( this.executedMojosPerModule.get( new ModuleName( event.getProject() ) ) ); + if (mavenReporters != null) { for (MavenReporter mavenReporter : mavenReporters) -- GitLab From 5f8ff476d89c54bf3685b686e52118ee9ebd1ac8 Mon Sep 17 00:00:00 2001 From: olamy Date: Sun, 7 Nov 2010 13:49:46 +0000 Subject: [PATCH 0011/2361] [HUDSON-4988] mark maven module as finished and recording build time. git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36742 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/maven/Maven3Builder.java | 76 ++++++++++++++++--- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index 0523772d58..ebd38082b6 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -305,7 +305,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal private List getMavenReporters(MavenProject mavenProject) { - return reporters.get( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ) ); + return reporters.get( new ModuleName( mavenProject ) ); } private void initMojoStartTime( MavenProject mavenProject) @@ -364,6 +364,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal List mavenReporters = getMavenReporters( mavenProject ); MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); + mavenBuildProxy2.start(); + if (mavenReporters != null) { @@ -417,7 +419,9 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal List mavenReporters = getMavenReporters( mavenProject ); MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); - + mavenBuildProxy2.end(); + mavenBuildProxy2.setResult( Result.SUCCESS ); + if ( mavenReporters != null ) { for ( MavenReporter mavenReporter : mavenReporters ) @@ -464,6 +468,9 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal public void projectFailed( ExecutionEvent event ) { maven3Builder.listener.getLogger().println("projectFailed" ); + MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( event.getProject() ); + mavenBuildProxy2.end(); + mavenBuildProxy2.setResult( Result.SUCCESS ); } /** @@ -471,7 +478,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void mojoSkipped( ExecutionEvent event ) { - + // TODO ? } /** @@ -559,7 +566,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal { try { - // FIXME exception during mojo execution ? mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, null); } catch ( InterruptedException e ) @@ -580,6 +586,57 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal public void mojoFailed( ExecutionEvent event ) { maven3Builder.listener.getLogger().println("mojoFailed " + event.getMojoExecution().getArtifactId()); + Long startTime = getMojoStartTime( event.getProject() ); + Date endTime = new Date(); + MavenProject mavenProject = event.getProject(); + XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ); + + Mojo mojo = null;//getMojo( event.getMojoExecution(), event.getSession() ); + + MojoInfo mojoInfo = + new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration, + getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) ); + + try + { + ExecutedMojo executedMojo = + new ExecutedMojo( mojoInfo, startTime == null ? 0 : endTime.getTime() - startTime.longValue() ); + this.executedMojosPerModule.get( new ModuleName( mavenProject.getGroupId(), + mavenProject.getArtifactId() ) ).add( executedMojo ); + + } + catch ( Exception e ) + { + // ignoring this + maven3Builder.listener.getLogger().println( "ignoring exception during new ExecutedMojo " + + e.getMessage() ); + } + + List mavenReporters = getMavenReporters( mavenProject ); + + MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); + + mavenBuildProxy2.setExecutedMojos( this.executedMojosPerModule.get( new ModuleName( event.getProject() ) ) ); + + if (mavenReporters != null) + { + for (MavenReporter mavenReporter : mavenReporters) + { + try + { + // FIXME get exception during mojo execution ? + mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, null ); + } + catch ( InterruptedException e ) + { + e.printStackTrace(); + } + catch ( IOException e ) + { + e.printStackTrace(); + } + } + } } /** @@ -587,7 +644,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void forkStarted( ExecutionEvent event ) { - + // TODO ! } /** @@ -595,7 +652,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void forkSucceeded( ExecutionEvent event ) { - + // TODO ! } /** @@ -603,6 +660,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void forkFailed( ExecutionEvent event ) { + // TODO ! } @@ -611,7 +669,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void forkedProjectStarted( ExecutionEvent event ) { - + // TODO ! } /** @@ -619,7 +677,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void forkedProjectSucceeded( ExecutionEvent event ) { - + // TODO ! } /** @@ -627,7 +685,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal */ public void forkedProjectFailed( ExecutionEvent event ) { - + // TODO ! } } -- GitLab From 8b9ca32f329219fd43fbf1efa8911ed833171d0f Mon Sep 17 00:00:00 2001 From: olamy Date: Sun, 7 Nov 2010 13:52:24 +0000 Subject: [PATCH 0012/2361] [HUDSON-4988] fix mark maven module as finished and recording build time. record skipped project too git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36743 71c3de6d-444a-0410-be80-ed276b4c234a --- maven-plugin/src/main/java/hudson/maven/Maven3Builder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index ebd38082b6..b8a8dd21bb 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -349,7 +349,9 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal public void projectSkipped( ExecutionEvent event ) { MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( event.getProject() ); - + maven3Builder.listener.getLogger().println("projectSkipped" ); + mavenBuildProxy2.end(); + mavenBuildProxy2.setResult( Result.ABORTED ); } /** @@ -470,7 +472,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal maven3Builder.listener.getLogger().println("projectFailed" ); MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( event.getProject() ); mavenBuildProxy2.end(); - mavenBuildProxy2.setResult( Result.SUCCESS ); + mavenBuildProxy2.setResult( Result.FAILURE ); } /** -- GitLab From e5cd97b93a86d4e2205b36788c0e6f5fbc226570 Mon Sep 17 00:00:00 2001 From: olamy Date: Tue, 9 Nov 2010 15:49:29 +0000 Subject: [PATCH 0013/2361] cleanup unused stuff git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36789 71c3de6d-444a-0410-be80-ed276b4c234a --- .../src/main/java/hudson/maven/MavenComputerListener.java | 5 ----- .../resources/org/jvnet/hudson/maven3/agent/classworlds.conf | 1 - 2 files changed, 6 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index 63796a2dc8..1886884a4a 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -38,10 +38,8 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; -import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Zip; -import org.codehaus.plexus.classworlds.ClassWorld; import org.jvnet.hudson.maven3.agent.Maven3Main; import org.jvnet.hudson.maven3.launcher.Maven3Launcher; @@ -60,9 +58,6 @@ public class MavenComputerListener extends ComputerListener { copyJar(logger, root, Maven3Launcher.class, "maven3-listener"); copyJar(logger, root, PluginManagerInterceptor.class, "maven-interceptor"); copyJar(logger, root, Maven21Interceptor.class, "maven2.1-interceptor"); - // FIXME not needed - copyJar(logger, root, ClassWorld.class, "plexus-classworld"); - copyJar(logger, root, AntClassLoader.class, "maven-plugin-ant"); } /** diff --git a/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf b/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf index e2d3b6a041..f4675ae49a 100755 --- a/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf +++ b/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf @@ -1,7 +1,6 @@ # # mostly copied as-is from $MAVEN_HOME/bin/m2.conf # -#main is org.apache.maven.cli.MavenCli from plexus.core.maven main is org.jvnet.hudson.maven3.launcher.Maven3Launcher from plexus.core set maven.home default ${user.home}/m2 -- GitLab From 7d5b8be103f5310fc6e717c1f1b85ab3894cce45 Mon Sep 17 00:00:00 2001 From: olamy Date: Tue, 9 Nov 2010 18:26:24 +0000 Subject: [PATCH 0014/2361] enable debugging tru a system property git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36793 71c3de6d-444a-0410-be80-ed276b4c234a --- maven-plugin/src/main/java/hudson/maven/MavenUtil.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java index aec778555b..366096c43a 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java @@ -159,7 +159,7 @@ public class MavenUtil { "\nSee https://hudson.dev.java.net/cannot-create-.m2.html"); if (privateRepository!=null) - mavenRequest.setLocalRepositoryPath( privateRepository); + mavenRequest.setLocalRepositoryPath( privateRepository ); if (profiles != null) { @@ -183,8 +183,6 @@ public class MavenUtil { // TODO check this MaskingClassLoader with maven 3 artifacts MavenEmbedder maven = new MavenEmbedder( new MaskingClassLoader(cl), mavenRequest ); - - { Enumeration e = cl.getResources("META-INF/plexus/components.xml"); while (e.hasMoreElements()) { @@ -192,9 +190,6 @@ public class MavenUtil { LOGGER.fine("components.xml from "+url); } } - - - return maven; } @@ -325,7 +320,7 @@ public class MavenUtil { /** * If set to true, maximize the logging level of Maven embedder. */ - public static boolean debugMavenEmbedder = false; + public static boolean debugMavenEmbedder = Boolean.getBoolean( "debugMavenEmbedder" ); private static final Logger LOGGER = Logger.getLogger(MavenUtil.class.getName()); } -- GitLab From 6f6390736e5434278c917735d88e82679576af5f Mon Sep 17 00:00:00 2001 From: olamy Date: Wed, 10 Nov 2010 00:22:54 +0000 Subject: [PATCH 0015/2361] cleanup code from previous tests. git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36806 71c3de6d-444a-0410-be80-ed276b4c234a --- maven-agent/pom.xml | 7 +------ .../main/java/hudson/maven/agent/Main.java | 21 +++++-------------- .../main/java/hudson/maven/MavenBuilder.java | 1 - .../hudson/maven/MavenComputerListener.java | 4 ++++ .../hudson/maven/MavenProcessFactory.java | 2 ++ pom.xml | 2 +- 6 files changed, 13 insertions(+), 24 deletions(-) diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index a3c29b4cdf..1f5619e8e3 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -101,18 +101,13 @@ THE SOFTWARE. 1.1 --> - - org.apache.ant - ant - 1.8.0 - org.apache.maven maven-core 2.0.9 - test + provided classworlds diff --git a/maven-agent/src/main/java/hudson/maven/agent/Main.java b/maven-agent/src/main/java/hudson/maven/agent/Main.java index f6f8837fff..ced74e0b22 100644 --- a/maven-agent/src/main/java/hudson/maven/agent/Main.java +++ b/maven-agent/src/main/java/hudson/maven/agent/Main.java @@ -46,6 +46,7 @@ import java.util.Set; import org.apache.tools.ant.AntClassLoader; import org.codehaus.classworlds.ClassWorldAdapter; import org.codehaus.plexus.classworlds.ClassWorld; +import org.codehaus.plexus.classworlds.ClassWorldListener; import org.codehaus.plexus.classworlds.launcher.ConfigurationException; import org.codehaus.plexus.classworlds.launcher.Launcher; import org.codehaus.plexus.classworlds.realm.ClassRealm; @@ -118,7 +119,7 @@ public class Main { // load the default realms launcher = new Launcher(); - launcher.setSystemClassLoader(Main.class.getClassLoader()); + //launcher.setSystemClassLoader(Main.class.getClassLoader()); configureLauncher( m2Home, remotingJar, interceptorJar, interceptorOverrideJar, is206OrLater ); @@ -133,8 +134,7 @@ public class Main { // create a realm for loading remoting subsystem. // this needs to be able to see maven. - System.out.print( "Main classLoader " + Main.class.getClassLoader() ); - //test en changeant le parent en plexus.core.maven ? + System.out.println( "Main classLoader " + Main.class.getClassLoader() ); ClassRealm remoting = launcher.getWorld().newRealm( "hudson-remoting", launcher.getWorld().getClassRealm( "plexus.core" ) ); remoting.importFrom( "plexus.core.maven", "org.apache.maven" ); //remoting.setParentClassLoader( launcher.getWorld().getClassRealm( "plexus.core.maven" ) ); @@ -278,23 +278,12 @@ public class Main { Set builtinRealms = new HashSet(world.getRealms()); URLClassLoader orig = (URLClassLoader) Thread.currentThread().getContextClassLoader(); System.out.println("orig " + orig.toString()); - Enumeration urls = orig.findResources( "META-INF/plexus/components.xml" ); - while(urls.hasMoreElements()) - { - System.out.println(" url " + urls.nextElement()); - } + try { launcher.setAppMain( "org.apache.maven.cli.MavenCli", "plexus.core.maven" ); ClassRealm newCl = launcher.getMainRealm(); - System.out.println("urls " + Arrays.asList( newCl.getURLs() ) ); - urls = newCl.findResources( "META-INF/plexus/components.xml" ); - while(urls.hasMoreElements()) - { - System.out.println(" url " + urls.nextElement()); - } - System.out.println("launcher cl " + newCl.toString()); - //Thread.currentThread().setContextClassLoader( newCl ); + Thread.currentThread().setContextClassLoader( newCl ); Method mainMethod = launcher.getMainClass().getMethod( "main", new Class[]{String[].class, org.codehaus.classworlds.ClassWorld.class} ); //launcher.launch(args); diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java index ea677769d3..6383b3da18 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java @@ -135,7 +135,6 @@ public abstract class MavenBuilder extends AbstractMavenBuilder implements Deleg System.out.println("MavenBuilder in call " + Thread.currentThread().getContextClassLoader()); futures = new ArrayList>(); Adapter a = new Adapter(this); - // FIXME are we using maven 2 or 3 callSetListenerWithReflectOnInterceptors( a ); /* diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index 1886884a4a..c63f7ffbbc 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -38,8 +38,10 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Zip; +import org.codehaus.plexus.classworlds.ClassWorld; import org.jvnet.hudson.maven3.agent.Maven3Main; import org.jvnet.hudson.maven3.launcher.Maven3Launcher; @@ -58,6 +60,8 @@ public class MavenComputerListener extends ComputerListener { copyJar(logger, root, Maven3Launcher.class, "maven3-listener"); copyJar(logger, root, PluginManagerInterceptor.class, "maven-interceptor"); copyJar(logger, root, Maven21Interceptor.class, "maven2.1-interceptor"); + copyJar(logger, root, ClassWorld.class, "plexus-classworld"); + copyJar(logger, root, AntClassLoader.class, "maven-plugin-ant"); } /** diff --git a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java index cea89cbb49..b2091a8152 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java @@ -70,6 +70,8 @@ import java.nio.charset.UnsupportedCharsetException; import java.util.Arrays; import java.util.logging.Logger; +import javax.inject.Inject; + import org.apache.tools.ant.AntClassLoader; import org.codehaus.plexus.classworlds.ClassWorld; diff --git a/pom.xml b/pom.xml index 48969c6c53..5cd88d76c7 100644 --- a/pom.xml +++ b/pom.xml @@ -283,7 +283,7 @@ THE SOFTWARE. org.codehaus.plexus plexus-classworlds - 2.2.3 + 2.3 org.apache.ant -- GitLab From a2d656bd30c71710088fd2fee836ff7a848c160f Mon Sep 17 00:00:00 2001 From: olamy Date: Wed, 10 Nov 2010 09:36:45 +0000 Subject: [PATCH 0016/2361] oups ! fix compilation issue. git-svn-id: https://hudson.dev.java.net/svn/hudson/branches/main-maven3-support@36812 71c3de6d-444a-0410-be80-ed276b4c234a --- maven-agent/src/main/java/hudson/maven/agent/Main.java | 1 - 1 file changed, 1 deletion(-) diff --git a/maven-agent/src/main/java/hudson/maven/agent/Main.java b/maven-agent/src/main/java/hudson/maven/agent/Main.java index ced74e0b22..00f58503c8 100644 --- a/maven-agent/src/main/java/hudson/maven/agent/Main.java +++ b/maven-agent/src/main/java/hudson/maven/agent/Main.java @@ -46,7 +46,6 @@ import java.util.Set; import org.apache.tools.ant.AntClassLoader; import org.codehaus.classworlds.ClassWorldAdapter; import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.ClassWorldListener; import org.codehaus.plexus.classworlds.launcher.ConfigurationException; import org.codehaus.plexus.classworlds.launcher.Launcher; import org.codehaus.plexus.classworlds.realm.ClassRealm; -- GitLab From bdb4df1f0f743310c80e320dfe9218a219cc5aa3 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 6 Dec 2010 21:23:20 +0100 Subject: [PATCH 0017/2361] test karma with .gitignore modification --- .gitignore | 4 ++++ pom.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d9916aad36..b81a3bd984 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ work *.iml *.iws *.ipr +.classpath +.project +.settings +build diff --git a/pom.xml b/pom.xml index 5cd88d76c7..1791a292d3 100644 --- a/pom.xml +++ b/pom.xml @@ -413,7 +413,7 @@ THE SOFTWARE. org.maven.ide.eclipse lifecycle-mapping - 0.10.0 + 0.12.0 customizable -- GitLab From b4bbafcc4f6943a89b75a06d6ee7182501b4d84c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 6 Dec 2010 22:04:23 +0100 Subject: [PATCH 0018/2361] add build directory to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9931b39311..70c430e088 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ work .settings .classpath .project +build war/images/16x16 war/images/24x24 -- GitLab From 70bce80328cb2b5783360f9b4bb5c652e324858b Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 6 Dec 2010 22:30:48 +0100 Subject: [PATCH 0019/2361] name import remove unused code --- .../main/java/hudson/maven/agent/Main.java | 12 ---- .../java/hudson/maven/MavenModuleSet.java | 58 +++++++++++++++---- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/maven-agent/src/main/java/hudson/maven/agent/Main.java b/maven-agent/src/main/java/hudson/maven/agent/Main.java index 00f58503c8..92601cdc69 100644 --- a/maven-agent/src/main/java/hudson/maven/agent/Main.java +++ b/maven-agent/src/main/java/hudson/maven/agent/Main.java @@ -315,18 +315,6 @@ public class Main { return launcher.getExitCode(); } - private static org.codehaus.classworlds.ClassWorld convertType(ClassWorld classWorld) - throws org.codehaus.classworlds.DuplicateRealmException - { - org.codehaus.classworlds.ClassWorld old = new org.codehaus.classworlds.ClassWorld(); - for (Iterator ite = classWorld.getRealms().iterator();ite.hasNext();) - { - ClassRealm realm = (ClassRealm) ite.next(); - old.newRealm( realm.getId(), realm ); - } - return old; - } - static class ChildFistClassCloader extends AntClassLoader { ChildFistClassCloader (ClassLoader parent) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java index 0084d2fd8f..eff5ffcda7 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java @@ -23,34 +23,70 @@ */ package hudson.maven; -import hudson.*; -import hudson.model.*; +import static hudson.Util.fixEmpty; +import static hudson.model.ItemGroupMixIn.loadChildren; +import hudson.CopyOnWrite; +import hudson.Extension; +import hudson.FilePath; +import hudson.Indenter; +import hudson.Util; +import hudson.model.AbstractProject; +import hudson.model.Action; +import hudson.model.BuildableItemWithBuildWrappers; +import hudson.model.DependencyGraph; +import hudson.model.Descriptor; import hudson.model.Descriptor.FormException; +import hudson.model.Executor; +import hudson.model.Hudson; +import hudson.model.Item; +import hudson.model.ItemGroup; +import hudson.model.Job; import hudson.model.Queue; import hudson.model.Queue.Task; +import hudson.model.ResourceActivity; +import hudson.model.SCMedItem; +import hudson.model.Saveable; +import hudson.model.TopLevelItem; import hudson.search.CollectionSearchIndex; import hudson.search.SearchIndexBuilder; -import hudson.tasks.*; +import hudson.tasks.BuildStep; +import hudson.tasks.BuildStepDescriptor; +import hudson.tasks.BuildWrapper; +import hudson.tasks.BuildWrappers; +import hudson.tasks.Fingerprinter; +import hudson.tasks.JavadocArchiver; +import hudson.tasks.Mailer; +import hudson.tasks.Maven; import hudson.tasks.Maven.MavenInstallation; +import hudson.tasks.Publisher; import hudson.tasks.junit.JUnitResultArchiver; import hudson.util.CopyOnWriteMap; import hudson.util.DescribableList; import hudson.util.FormValidation; import hudson.util.Function1; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.Stack; + +import javax.servlet.ServletException; + import net.sf.json.JSONObject; + import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.export.Exported; -import javax.servlet.ServletException; -import java.io.File; -import java.io.IOException; -import java.util.*; - -import static hudson.Util.fixEmpty; -import static hudson.model.ItemGroupMixIn.loadChildren; - /** * Group of {@link MavenModule}s. * -- GitLab From 25e35de7ccd4cf1eedeb0284b737882435437ece Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 9 Dec 2010 22:03:55 +0100 Subject: [PATCH 0020/2361] upgrade maven version to 3.0.1 --- .../main/java/hudson/maven/MavenModuleSetBuild.java | 11 +++++++++-- pom.xml | 11 ++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 1524dc98b4..d60a9a399a 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -55,15 +55,14 @@ import hudson.tasks.MailSender; import hudson.tasks.Maven.MavenInstallation; import hudson.util.ArgumentListBuilder; import hudson.util.IOUtils; +import hudson.util.MaskingClassLoader; import hudson.util.StreamTaskListener; import java.io.File; import java.io.IOException; import java.io.InterruptedIOException; import java.io.PrintStream; -import java.io.PrintWriter; import java.io.Serializable; -import java.io.StringWriter; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -899,8 +898,16 @@ public class MavenModuleSetBuild extends AbstractMavenBuild org.apache.maven maven-core - 3.0 + ${mavenVersion} org.apache.maven maven-compat - 3.0 + ${mavenVersion} org.apache.maven maven-aether-provider - 3.0 + ${mavenVersion} org.apache.maven maven-embedder - 3.0 + ${mavenVersion} org.sonatype.sisu @@ -298,7 +298,8 @@ THE SOFTWARE. - 3.0 + 3.0.1 + ${mavenVersion} -- GitLab From 435c7e09249c93d33113109cafad82d752add576 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 9 Dec 2010 22:13:11 +0100 Subject: [PATCH 0021/2361] set aether stuff versions in the pom not to be dependant on transitive stuff --- maven-plugin/pom.xml | 28 +++++++++++++++++++++++++++- pom.xml | 27 ++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 2ff4d22e88..debac4a694 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -88,7 +88,33 @@ THE SOFTWARE. org.apache.maven maven-core - + + + org.sonatype.aether + aether-api + + + org.sonatype.aether + aether-impl + + + org.sonatype.aether + aether-spi + + + org.sonatype.aether + aether-util + + + org.sonatype.aether + aether-connector-wagon + + + org.codehaus.plexus + plexus-container-default + + + org.apache.maven.reporting maven-reporting-api diff --git a/pom.xml b/pom.xml index 560d22c5e6..3574788686 100644 --- a/pom.xml +++ b/pom.xml @@ -274,6 +274,31 @@ THE SOFTWARE. maven-embedder ${mavenVersion} + + org.sonatype.aether + aether-api + ${aetherVersion} + + + org.sonatype.aether + aether-impl + ${aetherVersion} + + + org.sonatype.aether + aether-spi + ${aetherVersion} + + + org.sonatype.aether + aether-util + ${aetherVersion} + + + org.sonatype.aether + aether-connector-wagon + ${aetherVersion} + org.sonatype.sisu sisu-inject-plexus @@ -300,7 +325,7 @@ THE SOFTWARE. 3.0.1 ${mavenVersion} - + 1.8 UTF-8 -- GitLab From 478c0c4398dddad97d13629e24a03c5ae41b5c44 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 9 Dec 2010 23:08:21 +0100 Subject: [PATCH 0022/2361] fix some license headers --- .../hudson/maven/MavenModuleSetBuild.java | 17 ++++--- .../jvnet/hudson/maven3/agent/Maven3Main.java | 2 +- .../maven3/launcher/Maven3Launcher.java | 38 ++++++++-------- .../listeners/HudsonMavenBuildHelper.java | 38 ++++++++-------- .../listeners/HudsonMavenExecutionResult.java | 23 ++++++++-- .../listeners/MavenProjectBuildResult.java | 27 ++++++++--- .../maven3/listeners/MavenProjectInfo.java | 45 +++++++++---------- 7 files changed, 111 insertions(+), 79 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index d60a9a399a..a2838fc73f 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -535,15 +535,20 @@ public class MavenModuleSetBuild extends AbstractMavenBuild= 0; - if (maven3orLater) + if ( maven3orLater ) { LOGGER.info( "using maven 3 " + mavenVersion ); - process = MavenBuild.mavenProcessCache.get(launcher.getChannel(), slistener, - new Maven3ProcessFactory(project,launcher,envVars,pom.getParent())); - } else + process = + MavenBuild.mavenProcessCache.get( launcher.getChannel(), slistener, + new Maven3ProcessFactory( project, launcher, envVars, + pom.getParent() ) ); + } + else { - process = MavenBuild.mavenProcessCache.get(launcher.getChannel(), slistener, - new MavenProcessFactory(project,launcher,envVars,pom.getParent())); + process = + MavenBuild.mavenProcessCache.get( launcher.getChannel(), slistener, + new MavenProcessFactory( project, launcher, envVars, + pom.getParent() ) ); } ArgumentListBuilder margs = new ArgumentListBuilder().add("-B").add("-f", pom.getRemote()); if(project.usesPrivateRepository()) diff --git a/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java b/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java index b90b305003..1e8df7dfcf 100755 --- a/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java +++ b/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Olivier Lamy * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java index 1aa7bf1cfb..1213d5ed33 100755 --- a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java @@ -1,24 +1,24 @@ +package org.jvnet.hudson.maven3.launcher; + /* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Olivier Lamy - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - * associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or - * substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * Olivier Lamy + * 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. */ -package org.jvnet.hudson.maven3.launcher; import org.apache.maven.Maven; import org.apache.maven.cli.MavenExecutionRequestBuilder; diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java index 631823b734..a95ac32269 100644 --- a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java @@ -1,24 +1,24 @@ +package org.jvnet.hudson.maven3.listeners; + /* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Olivier Lamy - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - * associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or - * substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * Olivier Lamy + * 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. */ -package org.jvnet.hudson.maven3.listeners; import javax.inject.Inject; diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java index 821bf23015..69af0bd0eb 100755 --- a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java @@ -1,8 +1,25 @@ -/** - * - */ package org.jvnet.hudson.maven3.listeners; +/* + * Olivier Lamy + * 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 java.io.Serializable; import java.util.ArrayList; import java.util.List; diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java index 401ef433ff..4ce9571f56 100755 --- a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java @@ -1,18 +1,33 @@ -/** - * - */ package org.jvnet.hudson.maven3.listeners; +/* + * Olivier Lamy + * 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 java.io.Serializable; import java.util.List; import org.apache.maven.project.ProjectBuildingResult; /** - * @author olamy - * created 9 août 2010 + * @author Olivier Lamy * @since - * @version $Id$ */ public class MavenProjectBuildResult implements Serializable { diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java index 5b6fd1823f..2d26f8cf1a 100755 --- a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java @@ -1,37 +1,32 @@ +package org.jvnet.hudson.maven3.listeners; + /* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Olivier Lamy - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. + * Olivier Lamy + * 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. */ -package org.jvnet.hudson.maven3.listeners; import java.io.Serializable; import org.apache.maven.project.MavenProject; /** - * @author olamy - * created 9 août 2010 + * @author Olivier Lamy * @since - * @version $Id$ */ public class MavenProjectInfo implements Serializable { -- GitLab From e78bd45c83354bf1d5acc69867adfd44d30137d3 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 10 Dec 2010 12:56:27 -0500 Subject: [PATCH 0023/2361] [FIXED #HUDSON-5655] - " (from WhateverTest)" gratuitously appended to test result detail pages Regression related to HUDSON-2988 (special display of suites). --- .../main/resources/hudson/tasks/junit/CaseResult/index.jelly | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/hudson/tasks/junit/CaseResult/index.jelly b/core/src/main/resources/hudson/tasks/junit/CaseResult/index.jelly index 11d978d2c9..32083a6c83 100644 --- a/core/src/main/resources/hudson/tasks/junit/CaseResult/index.jelly +++ b/core/src/main/resources/hudson/tasks/junit/CaseResult/index.jelly @@ -35,8 +35,8 @@ THE SOFTWARE. - - (from ) + + (from )

-- GitLab From e878b35b25f0c1034335ff8bfd70c6483b2bfed4 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 10 Dec 2010 13:06:13 -0500 Subject: [PATCH 0024/2361] [HUDSON-5655] Noting e78bd45c83354bf1d5ac retroactively. (Was confused by 'changelog' branch which in fact seems to be dead. Certainly updating the file right here in master is easier.) --- changelog.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.html b/changelog.html index 55b2519092..3eb880052f 100644 --- a/changelog.html +++ b/changelog.html @@ -40,7 +40,9 @@ Upcoming changes -- GitLab From fa9d4cc61aab086013267d3fc7cd76585a0aaa92 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 10 Dec 2010 15:19:17 -0800 Subject: [PATCH 0025/2361] allow the build display name to be set by the user. --- core/src/main/java/hudson/model/Run.java | 46 ++++++++++++++++++- .../hudson/model/AbstractBuild/tasks.jelly | 1 + .../hudson/model/ExternalRun/sidepanel.jelly | 1 + .../hudson/model/Run/configure.jelly | 46 +++++++++++++++++++ 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 core/src/main/resources/hudson/model/Run/configure.jelly diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 1617d06076..f35f5e7c54 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -40,6 +40,7 @@ import hudson.console.AnnotatedLargeText; import hudson.console.ConsoleNote; import hudson.matrix.MatrixBuild; import hudson.matrix.MatrixRun; +import hudson.model.Descriptor.FormException; import hudson.model.listeners.RunListener; import hudson.model.listeners.SaveableListener; import hudson.search.SearchIndexBuilder; @@ -47,11 +48,14 @@ import hudson.security.ACL; import hudson.security.AccessControlled; import hudson.security.Permission; import hudson.security.PermissionGroup; +import hudson.tasks.BuildTrigger; import hudson.tasks.LogRotator; import hudson.tasks.Mailer; import hudson.tasks.BuildWrapper; import hudson.tasks.BuildStep; +import hudson.tasks.Publisher; import hudson.tasks.test.AbstractTestResultAction; +import hudson.util.DescribableList; import hudson.util.FlushProofOutputStream; import hudson.util.IOException2; import hudson.util.LogTaskListener; @@ -93,9 +97,12 @@ import java.util.zip.GZIPInputStream; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; +import net.sf.json.JSONObject; import org.apache.commons.io.input.NullInputStream; import org.apache.commons.io.IOUtils; import org.apache.commons.jelly.XMLOutput; +import org.kohsuke.stapler.HttpResponse; +import org.kohsuke.stapler.HttpResponses; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @@ -168,6 +175,13 @@ public abstract class Run ,RunT extends Run,RunT extends Run,RunT extends Run + \ No newline at end of file diff --git a/core/src/main/resources/hudson/model/ExternalRun/sidepanel.jelly b/core/src/main/resources/hudson/model/ExternalRun/sidepanel.jelly index 2747d2d7a2..e7c6edcd58 100644 --- a/core/src/main/resources/hudson/model/ExternalRun/sidepanel.jelly +++ b/core/src/main/resources/hudson/model/ExternalRun/sidepanel.jelly @@ -35,6 +35,7 @@ THE SOFTWARE. + diff --git a/core/src/main/resources/hudson/model/Run/configure.jelly b/core/src/main/resources/hudson/model/Run/configure.jelly new file mode 100644 index 0000000000..b7f17c5837 --- /dev/null +++ b/core/src/main/resources/hudson/model/Run/configure.jelly @@ -0,0 +1,46 @@ + + + + + + +
${%LOADING}
+ + + + + + + + + + + + + + +
+
+
-- GitLab From 847aefdef8b58c98df65d19487016b31a20f229d Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 10 Dec 2010 15:30:10 -0800 Subject: [PATCH 0026/2361] should parse ~/.profile --- changelog.html | 2 ++ debian/debian/hudson.init | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.html b/changelog.html index 3eb880052f..196bee3c3b 100644 --- a/changelog.html +++ b/changelog.html @@ -43,6 +43,8 @@ Upcoming changes
  • " (from WhateverTest)" gratuitously appended to test result detail pages. (issue 5655) +
  • + Debian package init script now honors ~/.profile. diff --git a/debian/debian/hudson.init b/debian/debian/hudson.init index 45a2e2879a..0491f905a0 100644 --- a/debian/debian/hudson.init +++ b/debian/debian/hudson.init @@ -104,7 +104,7 @@ do_start() # --user in daemon doesn't prepare environment variables like HOME, USER, LOGNAME or USERNAME, # so we let su do so for us now - $SU $HUDSON_USER --shell=/bin/bash -c "$DAEMON $DAEMON_ARGS -- $JAVA $JAVA_ARGS -jar $HUDSON_WAR $HUDSON_ARGS" || return 2 + $SU -l $HUDSON_USER --shell=/bin/bash -c "$DAEMON $DAEMON_ARGS -- $JAVA $JAVA_ARGS -jar $HUDSON_WAR $HUDSON_ARGS" || return 2 } -- GitLab From ad27bab4e74178aa86a973acb20d6c0747aad894 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 10 Dec 2010 15:39:27 -0800 Subject: [PATCH 0027/2361] [FIXED HUDSON-53 HUDSON-4884] build displayName is now modifiable to arbitrary text. --- changelog.html | 4 ++++ core/src/main/java/hudson/tasks/MailSender.java | 2 +- .../main/resources/hudson/model/AbstractBuild/changes.jelly | 4 ++-- .../src/main/resources/hudson/model/AbstractBuild/index.jelly | 4 ++-- .../main/resources/hudson/model/ExternalRun/sidepanel.jelly | 4 ++-- .../main/resources/hudson/model/ParametersAction/index.jelly | 2 +- .../hudson/model/PermalinkProjectAction/Permalink/link.jelly | 4 ++-- .../model/PermalinkProjectAction/Permalink/link.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_da.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_de.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_es.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_fi.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_fr.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_it.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_ja.properties | 2 +- .../PermalinkProjectAction/Permalink/link_nb_NO.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_nl.properties | 2 +- .../PermalinkProjectAction/Permalink/link_pt_BR.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_ru.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_sl.properties | 2 +- .../PermalinkProjectAction/Permalink/link_sv_SE.properties | 2 +- .../model/PermalinkProjectAction/Permalink/link_tr.properties | 2 +- .../PermalinkProjectAction/Permalink/link_zh_CN.properties | 2 +- .../src/main/resources/hudson/model/Run/artifacts-index.jelly | 2 +- core/src/main/resources/hudson/model/Run/confirmDelete.jelly | 4 ++-- core/src/main/resources/hudson/model/Run/console.jelly | 2 +- .../hudson/scm/AbstractScmTagAction/inProgress.jelly | 4 ++-- .../resources/hudson/views/LastFailureColumn/column.jelly | 4 ++-- .../main/resources/hudson/views/LastStableColumn/column.jelly | 2 +- .../resources/hudson/views/LastSuccessColumn/column.jelly | 4 ++-- .../main/resources/hudson/widgets/HistoryWidget/entry.jelly | 2 +- core/src/main/resources/lib/hudson/buildListTable.jelly | 2 +- .../resources/hudson/maven/MavenBuild/executedMojos.jelly | 4 ++-- 33 files changed, 45 insertions(+), 41 deletions(-) diff --git a/changelog.html b/changelog.html index 196bee3c3b..083f97cf56 100644 --- a/changelog.html +++ b/changelog.html @@ -45,6 +45,10 @@ Upcoming changes (issue 5655)
  • Debian package init script now honors ~/.profile. +
  • + Build names (e.g., "#123") can be now modified by users/plugins to arbitrary text. + (issue 53, + issue 4884) diff --git a/core/src/main/java/hudson/tasks/MailSender.java b/core/src/main/java/hudson/tasks/MailSender.java index 0d861774c3..155a99f01c 100644 --- a/core/src/main/java/hudson/tasks/MailSender.java +++ b/core/src/main/java/hudson/tasks/MailSender.java @@ -393,7 +393,7 @@ public class MailSender { } private String getSubject(AbstractBuild build, String caption) { - return caption + ' ' + build.getProject().getFullDisplayName() + " #" + build.getNumber(); + return caption + ' ' + build.getFullDisplayName(); } /** diff --git a/core/src/main/resources/hudson/model/AbstractBuild/changes.jelly b/core/src/main/resources/hudson/model/AbstractBuild/changes.jelly index 9f27ef0c53..ad4a0098ae 100644 --- a/core/src/main/resources/hudson/model/AbstractBuild/changes.jelly +++ b/core/src/main/resources/hudson/model/AbstractBuild/changes.jelly @@ -26,11 +26,11 @@ THE SOFTWARE. Displays the console output --> - + ${%Changes} - \ No newline at end of file + diff --git a/core/src/main/resources/hudson/model/AbstractBuild/index.jelly b/core/src/main/resources/hudson/model/AbstractBuild/index.jelly index c66658b7ad..db2146573c 100644 --- a/core/src/main/resources/hudson/model/AbstractBuild/index.jelly +++ b/core/src/main/resources/hudson/model/AbstractBuild/index.jelly @@ -24,7 +24,7 @@ THE SOFTWARE. --> - +
    @@ -47,7 +47,7 @@ THE SOFTWARE.
    - ${%Build} #${it.number} + ${%Build} ${it.displayName} () diff --git a/core/src/main/resources/hudson/model/ExternalRun/sidepanel.jelly b/core/src/main/resources/hudson/model/ExternalRun/sidepanel.jelly index e7c6edcd58..206f770981 100644 --- a/core/src/main/resources/hudson/model/ExternalRun/sidepanel.jelly +++ b/core/src/main/resources/hudson/model/ExternalRun/sidepanel.jelly @@ -26,7 +26,7 @@ THE SOFTWARE. Side panel for the build view. --> - + @@ -44,4 +44,4 @@ THE SOFTWARE. - \ No newline at end of file +
    diff --git a/core/src/main/resources/hudson/model/ParametersAction/index.jelly b/core/src/main/resources/hudson/model/ParametersAction/index.jelly index 007d6d12a2..b163b8f3aa 100644 --- a/core/src/main/resources/hudson/model/ParametersAction/index.jelly +++ b/core/src/main/resources/hudson/model/ParametersAction/index.jelly @@ -34,7 +34,7 @@ THE SOFTWARE. -

    ${%Build} #${build.number}

    +

    ${%Build} ${build.displayName}

  • - ${%format(it.displayName,b.number,b.timestampString)} + ${%format(it.displayName,b.displayName,b.timestampString)}
  • - \ No newline at end of file + diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link.properties index e283bf8b8d..7472ceddaa 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} ago \ No newline at end of file +format={0} ({1}), {2} ago diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_da.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_da.properties index bb7491113e..54cc8b3d6a 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_da.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_da.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} siden +format={0} ({1}), {2} siden diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_de.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_de.properties index 53641a6f88..754d70e282 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_de.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_de.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), vor {2} +format={0} ({1}), vor {2} diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_es.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_es.properties index 337133b497..0b0157934a 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_es.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_es.properties @@ -20,5 +20,5 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format="{0} (#{1}), hace {2}" +format="{0} ({1}), hace {2}" diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_fi.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_fi.properties index 9584df3862..4a6b5846bd 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_fi.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_fi.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} sitten +format={0} ({1}), {2} sitten diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_fr.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_fr.properties index fd98fe54ad..f061756de8 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_fr.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_fr.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), il y a {2} +format={0} ({1}), il y a {2} diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_it.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_it.properties index 2b2b972de3..5f609250cd 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_it.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_it.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} fa +format={0} ({1}), {2} fa diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_ja.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_ja.properties index 01dd2de143..cdd0546a62 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_ja.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_ja.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} \ No newline at end of file +format={0} ({1}), {2} diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_nb_NO.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_nb_NO.properties index 4d117d9e34..3bf3a32871 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_nb_NO.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_nb_NO.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} siden +format={0} ({1}), {2} siden diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_nl.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_nl.properties index 17fe161c10..a8a7540bee 100755 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_nl.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_nl.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), sinds {2} +format={0} ({1}), sinds {2} diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_pt_BR.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_pt_BR.properties index 0e5a0b8754..7e0665bbd4 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_pt_BR.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_pt_BR.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} atr\u00e1s +format={0} ({1}), {2} atr\u00e1s diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_ru.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_ru.properties index 1a442c391e..8938df9ee6 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_ru.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_ru.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} \u043d\u0430\u0437\u0430\u0434 +format={0} ({1}), {2} \u043d\u0430\u0437\u0430\u0434 diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_sl.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_sl.properties index 3b18d344fc..1c6a44c9c4 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_sl.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_sl.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format="{0} (#{1}), prej {2}" +format="{0} ({1}), prej {2}" diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_sv_SE.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_sv_SE.properties index def0997554..c404ec56c6 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_sv_SE.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_sv_SE.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} sedan +format={0} ({1}), {2} sedan diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_tr.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_tr.properties index 15176b8aa4..ad3fa8b603 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_tr.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_tr.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0} (#{1}), {2} \u00f6nce +format={0} ({1}), {2} \u00f6nce diff --git a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_zh_CN.properties b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_zh_CN.properties index 7a8f739008..94705be936 100644 --- a/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_zh_CN.properties +++ b/core/src/main/resources/hudson/model/PermalinkProjectAction/Permalink/link_zh_CN.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -format={0}(#{1}),{2}\u524D +format={0}({1}),{2}\u524D diff --git a/core/src/main/resources/hudson/model/Run/artifacts-index.jelly b/core/src/main/resources/hudson/model/Run/artifacts-index.jelly index 6baa53e5b9..eafb2f00eb 100644 --- a/core/src/main/resources/hudson/model/Run/artifacts-index.jelly +++ b/core/src/main/resources/hudson/model/Run/artifacts-index.jelly @@ -24,7 +24,7 @@ THE SOFTWARE. - + diff --git a/core/src/main/resources/hudson/model/Run/confirmDelete.jelly b/core/src/main/resources/hudson/model/Run/confirmDelete.jelly index b864d0e056..5db6153372 100644 --- a/core/src/main/resources/hudson/model/Run/confirmDelete.jelly +++ b/core/src/main/resources/hudson/model/Run/confirmDelete.jelly @@ -24,7 +24,7 @@ THE SOFTWARE. - + @@ -39,4 +39,4 @@ THE SOFTWARE. - \ No newline at end of file + diff --git a/core/src/main/resources/hudson/model/Run/console.jelly b/core/src/main/resources/hudson/model/Run/console.jelly index 266e54a284..327ad26c54 100644 --- a/core/src/main/resources/hudson/model/Run/console.jelly +++ b/core/src/main/resources/hudson/model/Run/console.jelly @@ -26,7 +26,7 @@ THE SOFTWARE. Displays the console output --> - + diff --git a/core/src/main/resources/hudson/scm/AbstractScmTagAction/inProgress.jelly b/core/src/main/resources/hudson/scm/AbstractScmTagAction/inProgress.jelly index 0ed31cd750..e20a434047 100644 --- a/core/src/main/resources/hudson/scm/AbstractScmTagAction/inProgress.jelly +++ b/core/src/main/resources/hudson/scm/AbstractScmTagAction/inProgress.jelly @@ -26,7 +26,7 @@ THE SOFTWARE. -

    Build #${it.build.number}

    +

    Build ${it.build.displayName}

    ${%Tagging is in progress:}

    @@ -34,4 +34,4 @@ THE SOFTWARE.
    - \ No newline at end of file + diff --git a/core/src/main/resources/hudson/views/LastFailureColumn/column.jelly b/core/src/main/resources/hudson/views/LastFailureColumn/column.jelly index deb4565c8e..9509766244 100644 --- a/core/src/main/resources/hudson/views/LastFailureColumn/column.jelly +++ b/core/src/main/resources/hudson/views/LastFailureColumn/column.jelly @@ -27,11 +27,11 @@ THE SOFTWARE. ${lfBuild.timestampString} - (#${lfBuild.number}) + (${lfBuild.displayName}) ${%N/A} - \ No newline at end of file + diff --git a/core/src/main/resources/hudson/views/LastStableColumn/column.jelly b/core/src/main/resources/hudson/views/LastStableColumn/column.jelly index b6159cb9d0..93d252b36f 100644 --- a/core/src/main/resources/hudson/views/LastStableColumn/column.jelly +++ b/core/src/main/resources/hudson/views/LastStableColumn/column.jelly @@ -28,7 +28,7 @@ THE SOFTWARE. ${lstBuild.timestampString} - (#${lstBuild.number}) + (${lstBuild.displayName}) ${%N/A} diff --git a/core/src/main/resources/hudson/views/LastSuccessColumn/column.jelly b/core/src/main/resources/hudson/views/LastSuccessColumn/column.jelly index 1bf4eb94e8..b6c3032ddb 100644 --- a/core/src/main/resources/hudson/views/LastSuccessColumn/column.jelly +++ b/core/src/main/resources/hudson/views/LastSuccessColumn/column.jelly @@ -27,11 +27,11 @@ THE SOFTWARE. ${lsBuild.timestampString} - (#${lsBuild.number}) + (${lsBuild.displayName}) ${%N/A} - \ No newline at end of file + diff --git a/core/src/main/resources/hudson/widgets/HistoryWidget/entry.jelly b/core/src/main/resources/hudson/widgets/HistoryWidget/entry.jelly index c27fa1aae2..2637129274 100644 --- a/core/src/main/resources/hudson/widgets/HistoryWidget/entry.jelly +++ b/core/src/main/resources/hudson/widgets/HistoryWidget/entry.jelly @@ -31,7 +31,7 @@ THE SOFTWARE. ${build.iconColor.description} - #${build.number} + ${build.displayName} diff --git a/core/src/main/resources/lib/hudson/buildListTable.jelly b/core/src/main/resources/lib/hudson/buildListTable.jelly index d4c0e0067c..67b600522f 100644 --- a/core/src/main/resources/lib/hudson/buildListTable.jelly +++ b/core/src/main/resources/lib/hudson/buildListTable.jelly @@ -54,7 +54,7 @@ THE SOFTWARE. ${b.parent.fullDisplayName} - #${b.number} + ${b.displayName} ${b.timestampString} diff --git a/maven-plugin/src/main/resources/hudson/maven/MavenBuild/executedMojos.jelly b/maven-plugin/src/main/resources/hudson/maven/MavenBuild/executedMojos.jelly index 77399f9e10..94d8967f6f 100644 --- a/maven-plugin/src/main/resources/hudson/maven/MavenBuild/executedMojos.jelly +++ b/maven-plugin/src/main/resources/hudson/maven/MavenBuild/executedMojos.jelly @@ -23,7 +23,7 @@ THE SOFTWARE. --> - +

    ${%Executed Mojos}

    @@ -78,4 +78,4 @@ THE SOFTWARE.
    - \ No newline at end of file + -- GitLab From ed1c36911cb0954bf0d750d97051be512761dd5e Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 10 Dec 2010 16:03:54 -0800 Subject: [PATCH 0028/2361] fixed help text and reverting the text back to default. --- core/src/main/java/hudson/model/Run.java | 6 +++++- core/src/main/resources/hudson/model/Run/configure.jelly | 4 ++-- war/src/main/webapp/help/run-config/description.html | 4 ++++ war/src/main/webapp/help/run-config/displayName.html | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 war/src/main/webapp/help/run-config/description.html create mode 100644 war/src/main/webapp/help/run-config/displayName.html diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index f35f5e7c54..e01b6c4a42 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -619,6 +619,10 @@ public abstract class Run ,RunT extends Run,RunT extends Run
    ${%LOADING}
    - + - + diff --git a/war/src/main/webapp/help/run-config/description.html b/war/src/main/webapp/help/run-config/description.html new file mode 100644 index 0000000000..fa13152bd8 --- /dev/null +++ b/war/src/main/webapp/help/run-config/description.html @@ -0,0 +1,4 @@ +
    + This description is placed on the build top page so that visitors can + know what this build did. You can use any HTML tags here. +
    \ No newline at end of file diff --git a/war/src/main/webapp/help/run-config/displayName.html b/war/src/main/webapp/help/run-config/displayName.html new file mode 100644 index 0000000000..9076598ab6 --- /dev/null +++ b/war/src/main/webapp/help/run-config/displayName.html @@ -0,0 +1,4 @@ +
    + If set, this text is used instead of the default "#NNN" to point to this build. Leave this empty + to use the default. +
    \ No newline at end of file -- GitLab From d1543575e2b4bcb0938a2bc88df589c462b227ef Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 10 Dec 2010 23:50:17 -0800 Subject: [PATCH 0029/2361] [FIXED HUDSON-8244] turns out Process.getErrorStream() needs to be explicitly closed even when stderr is redirected to stdout. --- changelog.html | 3 +++ core/src/main/java/hudson/Proc.java | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/changelog.html b/changelog.html index 083f97cf56..5482f2169f 100644 --- a/changelog.html +++ b/changelog.html @@ -43,6 +43,9 @@ Upcoming changes
  • " (from WhateverTest)" gratuitously appended to test result detail pages. (issue 5655) +
  • + Fixed a pipe leak to child processes. + (issue 8244)
  • Debian package init script now honors ~/.profile.
  • diff --git a/core/src/main/java/hudson/Proc.java b/core/src/main/java/hudson/Proc.java index 73679ac8ad..25726c3833 100644 --- a/core/src/main/java/hudson/Proc.java +++ b/core/src/main/java/hudson/Proc.java @@ -200,6 +200,10 @@ public abstract class Proc { copier2 = new StreamCopyThread(name+": stderr copier", proc.getErrorStream(), err); copier2.start(); } else { + // while this is not discussed in javadoc, even with ProcessBuilder.redirectErrorStream(true), + // Process.getErrorStream() still returns a distinct reader end of a pipe that needs to be closed. + // this is according to the source code of JVM + proc.getErrorStream().close(); copier2 = null; } } -- GitLab From 0fcf658c746911e6364c05b97b5dd58486072265 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 11 Dec 2010 09:31:18 +0100 Subject: [PATCH 0030/2361] [HUDSON-4988] Maven 3 support in maven-plugin fixing missing wagon providers --- .../main/java/hudson/maven/agent/Main.java | 6 ++ maven-plugin/pom.xml | 13 ++++ .../main/java/hudson/maven/ExecutedMojo.java | 2 +- .../main/java/hudson/maven/Maven3Builder.java | 10 +-- .../main/java/hudson/maven/MavenBuild.java | 2 +- .../hudson/maven/MavenModuleSetBuild.java | 3 + .../src/main/java/hudson/maven/MavenUtil.java | 69 ++++++++++--------- .../listeners/HudsonMavenBuildHelper.java | 11 ++- pom.xml | 17 +++++ 9 files changed, 89 insertions(+), 44 deletions(-) diff --git a/maven-agent/src/main/java/hudson/maven/agent/Main.java b/maven-agent/src/main/java/hudson/maven/agent/Main.java index 92601cdc69..c5de0a83d9 100644 --- a/maven-agent/src/main/java/hudson/maven/agent/Main.java +++ b/maven-agent/src/main/java/hudson/maven/agent/Main.java @@ -278,6 +278,12 @@ public class Main { URLClassLoader orig = (URLClassLoader) Thread.currentThread().getContextClassLoader(); System.out.println("orig " + orig.toString()); + URL cl = orig.getResource( "org/apache/maven/plugin/PluginManager.class" ); + if (cl != null) + { + System.out.println("cl " + cl.toString()); + } + // org.apache.maven.plugin.PluginManager try { launcher.setAppMain( "org.apache.maven.cli.MavenCli", "plexus.core.maven" ); diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index debac4a694..703c12619e 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -115,6 +115,19 @@ THE SOFTWARE. + + org.apache.maven.wagon + wagon-http-lightweight + + + org.apache.maven.wagon + wagon-file + + + + org.apache.maven.wagon + wagon-provider-api + org.apache.maven.reporting maven-reporting-api diff --git a/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java b/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java index 5b62c57146..4c306e7b23 100644 --- a/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java +++ b/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java @@ -80,7 +80,7 @@ public final class ExecutedMojo implements Serializable { */ public final String digest; - ExecutedMojo(MojoInfo mojo, long duration) throws IOException, InterruptedException { + public ExecutedMojo(MojoInfo mojo, long duration) throws IOException, InterruptedException { this.groupId = mojo.pluginName.groupId; this.artifactId = mojo.pluginName.artifactId; this.version = mojo.pluginName.version; diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index b8a8dd21bb..6bc6fe10e9 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -54,15 +54,12 @@ import org.apache.maven.execution.ExecutionListener; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.plugin.PluginConfigurationException; -import org.apache.maven.plugin.PluginContainerException; import org.apache.maven.plugin.PluginParameterExpressionEvaluator; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.jvnet.hudson.maven3.agent.Maven3Main; import org.jvnet.hudson.maven3.launcher.Maven3Launcher; -import org.jvnet.hudson.maven3.listeners.HudsonMavenBuildHelper; import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult; /** @@ -279,10 +276,13 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal return null; } + // FIME really used somewhere ??? // FIXME MojoInfo need the real mojo ?? - // so tricky to do need to use MavenPluginManager on the current Maven Build + // so tricky to do. need to use MavenPluginManager on the current Maven Build private Mojo getMojo(MojoExecution mojoExecution, MavenSession mavenSession) { + return null; + /* try { return HudsonMavenBuildHelper.getMavenPluginManager().getConfiguredMojo( Mojo.class, mavenSession, @@ -295,7 +295,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal catch ( PluginConfigurationException e ) { throw new RuntimeException( e.getMessage(), e ); - } + }*/ } private ExpressionEvaluator getExpressionEvaluator(MavenSession session, MojoExecution mojoExecution) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenBuild.java index f14b8336d2..e3b5df1fa4 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuild.java @@ -410,7 +410,7 @@ public class MavenBuild extends AbstractMavenBuild { } } - class ProxyImpl2 extends ProxyImpl implements MavenBuildProxy2 { + public class ProxyImpl2 extends ProxyImpl implements MavenBuildProxy2 { private final SplittableBuildListener listener; long startTime; private final OutputStream log; diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index a2838fc73f..18f93f0a43 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -597,6 +597,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild relPath = new HashMap(); MavenUtil.resolveModules(embedder,mp,getRootPath(rootPOMRelPrefix),relPath,listener,nonRecursive); diff --git a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java index 366096c43a..df42277bc2 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java @@ -210,38 +210,45 @@ public class MavenUtil { * errors will be reported to the listener and the exception thrown. * @throws MavenEmbedderException */ - public static void resolveModules(MavenEmbedder embedder, MavenProject project, - String rel, Map relativePathInfo, - BuildListener listener, boolean nonRecursive) throws ProjectBuildingException, - AbortException, MavenEmbedderException { - + public static void resolveModules( MavenEmbedder embedder, MavenProject project, String rel, + Map relativePathInfo, BuildListener listener, + boolean nonRecursive ) + throws ProjectBuildingException, AbortException, MavenEmbedderException + { + File basedir = project.getFile().getParentFile(); - relativePathInfo.put(project,rel); - - if (!nonRecursive) { - List modules = new ArrayList(); - - for (String modulePath : (List) project.getModules()) { - if (Util.fixEmptyAndTrim(modulePath)!=null) { - File moduleFile = new File(basedir, modulePath); - if (moduleFile.exists() && moduleFile.isDirectory()) { - moduleFile = new File(basedir, modulePath + "/pom.xml"); - } - if(!moduleFile.exists()) - throw new AbortException(moduleFile+" is referenced from "+project.getFile()+" but it doesn't exist"); - - String relativePath = rel; - if(relativePath.length()>0) relativePath+='/'; - relativePath+=modulePath; - - MavenProject child = embedder.readProject(moduleFile); - resolveModules(embedder,child,relativePath,relativePathInfo,listener,nonRecursive); - modules.add(child); - } - } - - project.setCollectedProjects(modules); - } + relativePathInfo.put( project, rel ); + + if ( !nonRecursive ) + { + List modules = new ArrayList(); + + for ( String modulePath : (List) project.getModules() ) + { + if ( Util.fixEmptyAndTrim( modulePath ) != null ) + { + File moduleFile = new File( basedir, modulePath ); + if ( moduleFile.exists() && moduleFile.isDirectory() ) + { + moduleFile = new File( basedir, modulePath + "/pom.xml" ); + } + if ( !moduleFile.exists() ) + throw new AbortException( moduleFile + " is referenced from " + project.getFile() + + " but it doesn't exist" ); + + String relativePath = rel; + if ( relativePath.length() > 0 ) + relativePath += '/'; + relativePath += modulePath; + + MavenProject child = embedder.readProject( moduleFile ); + resolveModules( embedder, child, relativePath, relativePathInfo, listener, nonRecursive ); + modules.add( child ); + } + } + + project.setCollectedProjects( modules ); + } } /** diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java index a95ac32269..3d4d77636f 100644 --- a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java +++ b/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java @@ -22,10 +22,8 @@ package org.jvnet.hudson.maven3.listeners; import javax.inject.Inject; -import org.apache.maven.plugin.MavenPluginManager; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; @@ -39,7 +37,7 @@ public class HudsonMavenBuildHelper implements Initializable // must be available in a static way weird // and not really good design ! - private static MavenPluginManager mavenPluginManager; + //private static MavenPluginManager mavenPluginManager; @Inject private PlexusContainer plexusContainer; @@ -47,6 +45,7 @@ public class HudsonMavenBuildHelper implements Initializable public void initialize() throws InitializationException { + /* try { mavenPluginManager = plexusContainer.lookup( MavenPluginManager.class ); @@ -55,12 +54,12 @@ public class HudsonMavenBuildHelper implements Initializable { throw new InitializationException(e.getMessage(), e); } - + */ } - public static MavenPluginManager getMavenPluginManager() + /*public static MavenPluginManager getMavenPluginManager() { return mavenPluginManager; - } + }*/ } diff --git a/pom.xml b/pom.xml index 3574788686..9f6a29a54d 100644 --- a/pom.xml +++ b/pom.xml @@ -299,6 +299,22 @@ THE SOFTWARE. aether-connector-wagon ${aetherVersion} + + org.apache.maven.wagon + wagon-http-lightweight + ${wagonVersion} + + + org.apache.maven.wagon + wagon-file + ${wagonVersion} + + + + org.apache.maven.wagon + wagon-provider-api + ${wagonVersion} + org.sonatype.sisu sisu-inject-plexus @@ -326,6 +342,7 @@ THE SOFTWARE. 3.0.1 ${mavenVersion} 1.8 + 1.0-beta-6 UTF-8 -- GitLab From 5d1ea36856efe3ad474cfb18eeaee3963c646f6c Mon Sep 17 00:00:00 2001 From: Seiji Sogabe Date: Sun, 12 Dec 2010 01:29:54 +0900 Subject: [PATCH 0031/2361] Added Japanese localization.(DisplayName, Description) --- .../hudson/model/AbstractBuild/tasks_ja.properties | 14 ++++++++------ .../model/ExternalRun/sidepanel_ja.properties | 14 ++++++++------ .../webapp/help/project-config/description_ja.html | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/core/src/main/resources/hudson/model/AbstractBuild/tasks_ja.properties b/core/src/main/resources/hudson/model/AbstractBuild/tasks_ja.properties index 92b0a2fb1b..413ceee9fc 100644 --- a/core/src/main/resources/hudson/model/AbstractBuild/tasks_ja.properties +++ b/core/src/main/resources/hudson/model/AbstractBuild/tasks_ja.properties @@ -1,6 +1,6 @@ # The MIT License # -# Copyright (c) 2004-2009, Sun Microsystems, Inc.,Seiji Sogabe +# Copyright (c) 2004-2010, Sun Microsystems, Inc.,Seiji Sogabe # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,10 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -Back\ to\ Project=\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3078\u623B\u308B -Status=\u72B6\u614B -Changes=\u5909\u66F4 -Console\ Output=\u30B3\u30F3\u30BD\u30FC\u30EB\u51FA\u529B -raw=\u672A\u52A0\u5DE5 +Back\ to\ Project=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3078\u623b\u308b +Status=\u72b6\u614b +Changes=\u5909\u66f4 +Console\ Output=\u30b3\u30f3\u30bd\u30fc\u30eb\u51fa\u529b +raw=\u672a\u52a0\u5de5 +Configure=\u8a2d\u5b9a +View\ Configuration=\u8a2d\u5b9a\u306e\u53c2\u7167 \ No newline at end of file diff --git a/core/src/main/resources/hudson/model/ExternalRun/sidepanel_ja.properties b/core/src/main/resources/hudson/model/ExternalRun/sidepanel_ja.properties index 7d2b8a1111..8d55ead108 100644 --- a/core/src/main/resources/hudson/model/ExternalRun/sidepanel_ja.properties +++ b/core/src/main/resources/hudson/model/ExternalRun/sidepanel_ja.properties @@ -1,6 +1,6 @@ # The MIT License # -# Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe +# Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,10 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -Back\ to\ Job=\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3078\u623B\u308B -Console\ Output=\u30B3\u30F3\u30BD\u30FC\u30EB\u51FA\u529Bt -Artifacts=\u6210\u679C\u7269 -Previous\ Run=\u524D\u306E\u5B9F\u884C -Next\ Run=\u6B21\u306E\u5B9F\u884C +Back\ to\ Job=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3078\u623b\u308b +Console\ Output=\u30b3\u30f3\u30bd\u30fc\u30eb\u51fa\u529bt +Artifacts=\u6210\u679c\u7269 +Previous\ Run=\u524d\u306e\u5b9f\u884c +Next\ Run=\u6b21\u306e\u5b9f\u884c +Configure=\u8a2d\u5b9a +View\ Configuration=\u8a2d\u5b9a\u306e\u53c2\u7167 diff --git a/war/src/main/webapp/help/project-config/description_ja.html b/war/src/main/webapp/help/project-config/description_ja.html index afd463ac5b..14374e390b 100644 --- a/war/src/main/webapp/help/project-config/description_ja.html +++ b/war/src/main/webapp/help/project-config/description_ja.html @@ -1,4 +1,4 @@ 
    - この説明は、 このジョブが何に関係しているか訪問者が知ることができるように、プロジェクト・トップページに置かれます。 - ここでどんなHTMLタグを使用することができます。 + この説明は、 このジョブの目的がわかるように、プロジェクト・トップページに置かれます。 + ここではどんなHTMLタグでも記述することができます。
    \ No newline at end of file -- GitLab From 5b0cff8d512af343b5153b6f2dd06563427e2dce Mon Sep 17 00:00:00 2001 From: Seiji Sogabe Date: Sun, 12 Dec 2010 01:40:07 +0900 Subject: [PATCH 0032/2361] again. --- .../hudson/model/Run/configure_ja.properties | 26 +++++++++++++++++++ .../help/run-config/description_ja.html | 4 +++ .../help/run-config/displayName_ja.html | 3 +++ 3 files changed, 33 insertions(+) create mode 100644 core/src/main/resources/hudson/model/Run/configure_ja.properties create mode 100644 war/src/main/webapp/help/run-config/description_ja.html create mode 100644 war/src/main/webapp/help/run-config/displayName_ja.html diff --git a/core/src/main/resources/hudson/model/Run/configure_ja.properties b/core/src/main/resources/hudson/model/Run/configure_ja.properties new file mode 100644 index 0000000000..2ce335a25d --- /dev/null +++ b/core/src/main/resources/hudson/model/Run/configure_ja.properties @@ -0,0 +1,26 @@ +# The MIT License +# +# Copyright (c) 2010, CloudBees, Inc., Seiji Sogabe +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +LOADING=\u30ed\u30fc\u30c9\u4e2d +DisplayName=\u8868\u793a\u540d +Description=\u8aac\u660e +Save=\u4fdd\u5b58 \ No newline at end of file diff --git a/war/src/main/webapp/help/run-config/description_ja.html b/war/src/main/webapp/help/run-config/description_ja.html new file mode 100644 index 0000000000..b7054a855a --- /dev/null +++ b/war/src/main/webapp/help/run-config/description_ja.html @@ -0,0 +1,4 @@ +
    + このビルドが何を実行したのかわかるように、ビルドのトップ画面に表示されます。 + ここには、どんなHTMLタグでも記述することができます。 +
    \ No newline at end of file diff --git a/war/src/main/webapp/help/run-config/displayName_ja.html b/war/src/main/webapp/help/run-config/displayName_ja.html new file mode 100644 index 0000000000..8930fb5e5b --- /dev/null +++ b/war/src/main/webapp/help/run-config/displayName_ja.html @@ -0,0 +1,3 @@ +
    + デフォルトの"#NNN"のかわりに、このテキストがビルドを表します。設定しないとデフォルト("#NNN")を使用します。 +
    \ No newline at end of file -- GitLab From 5f5c26c59dc261e302f3cf9013ccc3cedbf08c40 Mon Sep 17 00:00:00 2001 From: Seiji Sogabe Date: Sun, 12 Dec 2010 01:41:12 +0900 Subject: [PATCH 0033/2361] fixed Non-ASCII garbled. --- core/src/main/java/hudson/model/Run.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index e01b6c4a42..d205f1ed3d 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -1835,6 +1835,7 @@ public abstract class Run ,RunT extends Run Date: Sat, 11 Dec 2010 12:06:27 -0800 Subject: [PATCH 0034/2361] indentation change --- core/src/main/resources/hudson/model/View/index.jelly | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/resources/hudson/model/View/index.jelly b/core/src/main/resources/hudson/model/View/index.jelly index 7b53bbec7f..f0899c139d 100644 --- a/core/src/main/resources/hudson/model/View/index.jelly +++ b/core/src/main/resources/hudson/model/View/index.jelly @@ -26,7 +26,7 @@ THE SOFTWARE. - + @@ -41,10 +41,10 @@ THE SOFTWARE. - + -- GitLab From 980aeaba34c4754712a6dc37b5871ae83ec5651a Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 11 Dec 2010 22:51:43 +0100 Subject: [PATCH 0035/2361] [HUDSON-4988] Maven 3 support in maven-plugin remove stuff which class AbstractMethodError for maven2 builds --- .../main/java/hudson/maven/agent/Main.java | 113 +- .../maven/agent/DefaultPluginManager.java | 1546 ----------------- .../maven/agent/PluginManagerInterceptor.java | 11 +- .../hudson/maven/MavenComputerListener.java | 5 +- 4 files changed, 66 insertions(+), 1609 deletions(-) delete mode 100644 maven-interceptor/src/main/java/hudson/maven/agent/DefaultPluginManager.java diff --git a/maven-agent/src/main/java/hudson/maven/agent/Main.java b/maven-agent/src/main/java/hudson/maven/agent/Main.java index c5de0a83d9..f3cf593115 100644 --- a/maven-agent/src/main/java/hudson/maven/agent/Main.java +++ b/maven-agent/src/main/java/hudson/maven/agent/Main.java @@ -43,6 +43,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.apache.maven.plugin.DefaultPluginManager; import org.apache.tools.ant.AntClassLoader; import org.codehaus.classworlds.ClassWorldAdapter; import org.codehaus.plexus.classworlds.ClassWorld; @@ -195,6 +196,62 @@ public class Main { launcher.configure(Main.class.getResourceAsStream(is206OrLater?"classworlds-2.0.6.conf":"classworlds.conf")); } + /** + * Called by the code in remoting to launch. + * @throws org.codehaus.classworlds.DuplicateRealmException + * @throws IllegalArgumentException + */ + public static int launch(String[] args) + throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException, IllegalArgumentException { + + ClassWorld world = launcher.getWorld(); + + Set builtinRealms = new HashSet(world.getRealms()); + URLClassLoader orig = (URLClassLoader) Thread.currentThread().getContextClassLoader(); + System.out.println("orig " + orig.toString()); + + + try { + launcher.setAppMain( "org.apache.maven.cli.MavenCli", "plexus.core.maven" ); + ClassRealm newCl = launcher.getMainRealm(); + Thread.currentThread().setContextClassLoader( newCl ); + Method mainMethod = launcher.getMainClass().getMethod( "main", new Class[]{String[].class, org.codehaus.classworlds.ClassWorld.class} ); + //launcher.launch(args); + + mainMethod.invoke( null,new Object[]{args,ClassWorldAdapter.getInstance( launcher.getWorld() )} ); + //} catch (org.codehaus.classworlds.DuplicateRealmException e) { + // throw new RuntimeException( e.getMessage(), e); + } catch (NoSuchRealmException e) { + throw new RuntimeException( e.getMessage(), e); + } finally { + Thread.currentThread().setContextClassLoader( orig ); + // delete all realms created by Maven + // this is because Maven creates a child realm for each plugin it loads, + // and the realm id doesn't include the version. + // so unless we discard all the realms multiple invocations + // that use different versions of the same plugin will fail to work correctly. + Set all = new HashSet(world.getRealms()); + all.removeAll(builtinRealms); + for (Iterator itr = all.iterator(); itr.hasNext();) { + ClassRealm cr = (ClassRealm) itr.next(); + try + { + world.disposeRealm(cr.getId()); + } + catch ( NoSuchRealmException e ) + { + throw new RuntimeException( e.getMessage(), e); + } + } + } + return launcher.getExitCode(); + } + + + //--------------- + // olamy tests + // TODO remove + //--------------- /** * with various classLoader hierarchy stuff * @throws MalformedURLException @@ -263,63 +320,7 @@ public class Main { } } - - /** - * Called by the code in remoting to launch. - * @throws org.codehaus.classworlds.DuplicateRealmException - * @throws IllegalArgumentException - */ - public static int launch(String[] args) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException, IllegalArgumentException { - - ClassWorld world = launcher.getWorld(); - - Set builtinRealms = new HashSet(world.getRealms()); - URLClassLoader orig = (URLClassLoader) Thread.currentThread().getContextClassLoader(); - System.out.println("orig " + orig.toString()); - - URL cl = orig.getResource( "org/apache/maven/plugin/PluginManager.class" ); - if (cl != null) - { - System.out.println("cl " + cl.toString()); - } - // org.apache.maven.plugin.PluginManager - try { - launcher.setAppMain( "org.apache.maven.cli.MavenCli", "plexus.core.maven" ); - ClassRealm newCl = launcher.getMainRealm(); - Thread.currentThread().setContextClassLoader( newCl ); - Method mainMethod = launcher.getMainClass().getMethod( "main", new Class[]{String[].class, org.codehaus.classworlds.ClassWorld.class} ); - //launcher.launch(args); - - mainMethod.invoke( null,new Object[]{args,ClassWorldAdapter.getInstance( launcher.getWorld() )} ); - //} catch (org.codehaus.classworlds.DuplicateRealmException e) { - // throw new RuntimeException( e.getMessage(), e); - } catch (NoSuchRealmException e) { - throw new RuntimeException( e.getMessage(), e); - } finally { - Thread.currentThread().setContextClassLoader( orig ); - // delete all realms created by Maven - // this is because Maven creates a child realm for each plugin it loads, - // and the realm id doesn't include the version. - // so unless we discard all the realms multiple invocations - // that use different versions of the same plugin will fail to work correctly. - Set all = new HashSet(world.getRealms()); - all.removeAll(builtinRealms); - for (Iterator itr = all.iterator(); itr.hasNext();) { - ClassRealm cr = (ClassRealm) itr.next(); - try - { - world.disposeRealm(cr.getId()); - } - catch ( NoSuchRealmException e ) - { - throw new RuntimeException( e.getMessage(), e); - } - } - } - return launcher.getExitCode(); - } static class ChildFistClassCloader extends AntClassLoader { diff --git a/maven-interceptor/src/main/java/hudson/maven/agent/DefaultPluginManager.java b/maven-interceptor/src/main/java/hudson/maven/agent/DefaultPluginManager.java deleted file mode 100644 index 2bbc34d261..0000000000 --- a/maven-interceptor/src/main/java/hudson/maven/agent/DefaultPluginManager.java +++ /dev/null @@ -1,1546 +0,0 @@ - -package hudson.maven.agent; - -/* - * 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 java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.maven.MavenArtifactFilterManager; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.metadata.ResolutionGroup; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; -import org.apache.maven.artifact.resolver.filter.ArtifactFilter; -import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.execution.RuntimeInformation; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.ReportPlugin; -import org.apache.maven.monitor.event.EventDispatcher; -import org.apache.maven.monitor.event.MavenEvents; -import org.apache.maven.monitor.logging.DefaultLog; -import org.apache.maven.plugin.ContextEnabled; -import org.apache.maven.plugin.DebugConfigurationListener; -import org.apache.maven.plugin.InvalidPluginException; -import org.apache.maven.plugin.MavenPluginCollector; -import org.apache.maven.plugin.Mojo; -import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.PluginConfigurationException; -import org.apache.maven.plugin.PluginManager; -import org.apache.maven.plugin.PluginManagerException; -import org.apache.maven.plugin.PluginMappingManager; -import org.apache.maven.plugin.PluginNotFoundException; -import org.apache.maven.plugin.PluginParameterException; -import org.apache.maven.plugin.PluginParameterExpressionEvaluator; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.plugin.descriptor.Parameter; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.version.PluginVersionManager; -import org.apache.maven.plugin.version.PluginVersionNotFoundException; -import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.project.ProjectBuildingException; -import org.apache.maven.project.artifact.InvalidDependencyVersionException; -import org.apache.maven.project.artifact.MavenMetadataSource; -import org.apache.maven.project.path.PathTranslator; -import org.apache.maven.reporting.MavenReport; -import org.apache.maven.settings.Settings; -import org.codehaus.classworlds.ClassRealm; -import org.codehaus.classworlds.NoSuchRealmException; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.PlexusContainerException; -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ComponentConfigurator; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - * olamy : code removed in maven 3 so imported sources - * from maven 2.0.9 tag : /maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java - * really hackhish ! - * @author olamy - * - */ -public class DefaultPluginManager - extends AbstractLogEnabled - implements PluginManager, Initializable, Contextualizable -{ - protected PlexusContainer container; - - protected PluginDescriptorBuilder pluginDescriptorBuilder; - - protected ArtifactFilter artifactFilter; - - private Log mojoLogger; - - private Map resolvedCoreArtifactFiles = new HashMap(); - - // component requirements - protected PathTranslator pathTranslator; - - protected MavenPluginCollector pluginCollector; - - protected PluginVersionManager pluginVersionManager; - - protected ArtifactFactory artifactFactory; - - protected ArtifactResolver artifactResolver; - - protected ArtifactMetadataSource artifactMetadataSource; - - protected RuntimeInformation runtimeInformation; - - protected MavenProjectBuilder mavenProjectBuilder; - - protected PluginMappingManager pluginMappingManager; - - // END component requirements - - public DefaultPluginManager() - { - pluginDescriptorBuilder = new PluginDescriptorBuilder(); - } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - public PluginDescriptor getPluginDescriptorForPrefix( String prefix ) - { - return pluginCollector.getPluginDescriptorForPrefix( prefix ); - } - - public Plugin getPluginDefinitionForPrefix( String prefix, - MavenSession session, - MavenProject project ) - { - // TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other - // use for the mapping manager in here - return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(), - project.getPluginArtifactRepositories(), - session.getLocalRepository() ); - } - - public PluginDescriptor verifyPlugin( Plugin plugin, - MavenProject project, - Settings settings, - ArtifactRepository localRepository ) - throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, - InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, - PluginVersionNotFoundException - { - // TODO: this should be possibly outside - // All version-resolution logic has been moved to DefaultPluginVersionManager. - if ( plugin.getVersion() == null ) - { - String version = pluginVersionManager.resolvePluginVersion( plugin.getGroupId(), plugin.getArtifactId(), - project, settings, localRepository ); - plugin.setVersion( version ); - } - - return verifyVersionedPlugin( plugin, project, localRepository ); - } - - private PluginDescriptor verifyVersionedPlugin( Plugin plugin, - MavenProject project, - ArtifactRepository localRepository ) - throws PluginVersionResolutionException, ArtifactNotFoundException, ArtifactResolutionException, - InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException - { - // TODO: this might result in an artifact "RELEASE" being resolved continuously - // FIXME: need to find out how a plugin gets marked as 'installed' - // and no ChildContainer exists. The check for that below fixes - // the 'Can't find plexus container for plugin: xxx' error. - try - { - VersionRange versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() ); - - List remoteRepositories = new ArrayList(); - remoteRepositories.addAll( project.getPluginArtifactRepositories() ); - remoteRepositories.addAll( project.getRemoteArtifactRepositories() ); - - checkRequiredMavenVersion( plugin, localRepository, remoteRepositories ); - - Artifact pluginArtifact = - artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); - - pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact ); - - artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository ); - - PlexusContainer pluginContainer = container.getChildContainer( plugin.getKey() ); - - File pluginFile = pluginArtifact.getFile(); - - if ( !pluginCollector.isPluginInstalled( plugin ) || ( pluginContainer == null ) ) - { - addPlugin( plugin, pluginArtifact, project, localRepository ); - } - else if ( pluginFile.lastModified() > pluginContainer.getCreationDate().getTime() ) - { - getLogger().info( - "Reloading plugin container for: " + plugin.getKey() + ". The plugin artifact has changed." ); - - pluginContainer.dispose(); - - pluginCollector.flushPluginDescriptor( plugin ); - - addPlugin( plugin, pluginArtifact, project, localRepository ); - } - - project.addPlugin( plugin ); - } - catch ( ArtifactNotFoundException e ) - { - String groupId = plugin.getGroupId(); - String artifactId = plugin.getArtifactId(); - String version = plugin.getVersion(); - - if ( ( groupId == null ) || ( artifactId == null ) || ( version == null ) ) - { - throw new PluginNotFoundException( e ); - } - else if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) && - version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) ) - { - throw new PluginNotFoundException( e ); - } - else - { - throw e; - } - } - - return pluginCollector.getPluginDescriptor( plugin ); - } - - /** - * @todo would be better to store this in the plugin descriptor, but then it won't be available to the version - * manager which executes before the plugin is instantiated - */ - private void checkRequiredMavenVersion( Plugin plugin, - ArtifactRepository localRepository, - List remoteRepositories ) - throws PluginVersionResolutionException, InvalidPluginException - { - try - { - Artifact artifact = artifactFactory.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(), - plugin.getVersion() ); - MavenProject project = - mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository, false ); - // if we don't have the required Maven version, then ignore an update - if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven() != null ) ) - { - DefaultArtifactVersion requiredVersion = - new DefaultArtifactVersion( project.getPrerequisites().getMaven() ); - if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 ) - { - throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(), - "Plugin requires Maven version " + requiredVersion ); - } - } - } - catch ( ProjectBuildingException e ) - { - throw new InvalidPluginException( - "Unable to build project for plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); - } - } - - protected void addPlugin( Plugin plugin, - Artifact pluginArtifact, - MavenProject project, - ArtifactRepository localRepository ) - throws PluginManagerException, InvalidPluginException - { - PlexusContainer child; - - try - { - child = container.createChildContainer( plugin.getKey(), - Collections.singletonList( pluginArtifact.getFile() ), - Collections.EMPTY_MAP, - Collections.singletonList( pluginCollector ) ); - try - { - child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.Xpp3Dom" ); - child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull" ); - - // MNG-2878 - child.getContainerRealm().importFrom( "plexus.core", "/default-report.xml" ); - } - catch ( NoSuchRealmException e ) - { - // won't happen - } - } - catch ( PlexusContainerException e ) - { - throw new PluginManagerException( - "Failed to create plugin container for plugin '" + plugin + "': " + e.getMessage(), e ); - } - - // this plugin's descriptor should have been discovered in the child creation, so we should be able to - // circle around and set the artifacts and class realm - PluginDescriptor addedPlugin = pluginCollector.getPluginDescriptor( plugin ); - - if ( addedPlugin == null ) - { - throw new IllegalStateException( "The PluginDescriptor for the plugin " + plugin + " was not found." ); - } - - addedPlugin.setClassRealm( child.getContainerRealm() ); - - // we're only setting the plugin's artifact itself as the artifact list, to allow it to be retrieved - // later when the plugin is first invoked. Retrieving this artifact will in turn allow us to - // transitively resolve its dependencies, and add them to the plugin container... - addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) ); - - try - { - // the only Plugin instance which will have dependencies is the one specified in the project. - // We need to look for a Plugin instance there, in case the instance we're using didn't come from - // the project. - Plugin projectPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getKey() ); - - if ( projectPlugin == null ) - { - projectPlugin = plugin; - } - - Set artifacts = MavenMetadataSource.createArtifacts( artifactFactory, projectPlugin.getDependencies(), null, - null, project ); - -// Set artifacts = -// MavenMetadataSource.createArtifacts( artifactFactory, plugin.getDependencies(), null, null, project ); - - addedPlugin.setIntroducedDependencyArtifacts( artifacts ); - } - catch ( InvalidDependencyVersionException e ) - { - throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(), e ); - } - } - - // ---------------------------------------------------------------------- - // Mojo execution - // ---------------------------------------------------------------------- - - public void executeMojo( MavenProject project, - MojoExecution mojoExecution, - MavenSession session ) - throws ArtifactResolutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException, - InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException - { - MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); - - // NOTE: I'm putting these checks in here, since this is the central point of access for - // anything that wants to execute a mojo. - if ( mojoDescriptor.isProjectRequired() && !session.isUsingPOMsFromFilesystem() ) - { - throw new MojoExecutionException( "Cannot execute mojo: " + mojoDescriptor.getGoal() + - ". It requires a project with an existing pom.xml, but the build is not using one." ); - } - - if ( mojoDescriptor.isOnlineRequired() && session.getSettings().isOffline() ) - { - // TODO: Should we error out, or simply warn and skip?? - throw new MojoExecutionException( "Mojo: " + mojoDescriptor.getGoal() + - " requires online mode for execution. Maven is currently offline." ); - } - - if ( mojoDescriptor.isDependencyResolutionRequired() != null ) - { - Collection projects; - - if ( mojoDescriptor.isAggregator() ) - { - projects = session.getSortedProjects(); - } - else - { - projects = Collections.singleton( project ); - } - - for ( Iterator i = projects.iterator(); i.hasNext(); ) - { - MavenProject p = (MavenProject) i.next(); - - resolveTransitiveDependencies( session, artifactResolver, - mojoDescriptor.isDependencyResolutionRequired(), artifactFactory, p, mojoDescriptor.isAggregator() ); - } - - downloadDependencies( project, session, artifactResolver ); - } - - String goalName = mojoDescriptor.getFullGoalName(); - - Mojo plugin; - - PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); - String goalId = mojoDescriptor.getGoal(); - String groupId = pluginDescriptor.getGroupId(); - String artifactId = pluginDescriptor.getArtifactId(); - String executionId = mojoExecution.getExecutionId(); - Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId ); - Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId ); - dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom ); - if ( mojoExecution.getConfiguration() != null ) - { - dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); - } - - plugin = getConfiguredMojo( session, dom, project, false, mojoExecution ); - - // Event monitoring. - String event = MavenEvents.MOJO_EXECUTION; - EventDispatcher dispatcher = session.getEventDispatcher(); - - String goalExecId = goalName; - - if ( mojoExecution.getExecutionId() != null ) - { - goalExecId += " {execution: " + mojoExecution.getExecutionId() + "}"; - } - - dispatcher.dispatchStart( event, goalExecId ); - - ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - - try - { - Thread.currentThread().setContextClassLoader( - mojoDescriptor.getPluginDescriptor().getClassRealm().getClassLoader() ); - - plugin.execute(); - - dispatcher.dispatchEnd( event, goalExecId ); - } - catch ( MojoExecutionException e ) - { - session.getEventDispatcher().dispatchError( event, goalExecId, e ); - - throw e; - } - catch ( MojoFailureException e ) - { - session.getEventDispatcher().dispatchError( event, goalExecId, e ); - - throw e; - } - catch ( LinkageError e ) - { - if ( getLogger().isFatalErrorEnabled() ) - { - getLogger().fatalError( - plugin.getClass().getName() + "#execute() caused a linkage error (" - + e.getClass().getName() + ") and may be out-of-date. Check the realms:" ); - - ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm(); - StringBuffer sb = new StringBuffer(); - sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' ); - for ( int i = 0; i < pluginRealm.getConstituents().length; i++ ) - { - sb.append( "urls[" + i + "] = " + pluginRealm.getConstituents()[i] ); - if ( i != ( pluginRealm.getConstituents().length - 1 ) ) - { - sb.append( '\n' ); - } - } - getLogger().fatalError( sb.toString() ); - - ClassRealm containerRealm = container.getContainerRealm(); - sb = new StringBuffer(); - sb.append( "Container realm = " + containerRealm.getId() ).append( '\n' ); - for ( int i = 0; i < containerRealm.getConstituents().length; i++ ) - { - sb.append( "urls[" + i + "] = " + containerRealm.getConstituents()[i] ); - if ( i != ( containerRealm.getConstituents().length - 1 ) ) - { - sb.append( '\n' ); - } - } - getLogger().fatalError( sb.toString() ); - } - - session.getEventDispatcher().dispatchError( event, goalExecId, e ); - - throw e; - } - finally - { - - Thread.currentThread().setContextClassLoader( oldClassLoader ); - - try - { - PlexusContainer pluginContainer = getPluginContainer( mojoDescriptor.getPluginDescriptor() ); - - pluginContainer.release( plugin ); - } - catch ( ComponentLifecycleException e ) - { - if ( getLogger().isErrorEnabled() ) - { - getLogger().error( "Error releasing plugin - ignoring.", e ); - } - } - } - } - - public MavenReport getReport( MavenProject project, - MojoExecution mojoExecution, - MavenSession session ) - throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException, - ArtifactResolutionException - { - MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); - PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor(); - Xpp3Dom dom = project.getReportConfiguration( descriptor.getGroupId(), descriptor.getArtifactId(), - mojoExecution.getExecutionId() ); - if ( mojoExecution.getConfiguration() != null ) - { - dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); - } - - return (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution ); - } - - public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, - MavenProject project, - MavenSession session ) - throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException, - InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, - PluginVersionNotFoundException - { - String version = reportPlugin.getVersion(); - - if ( version == null ) - { - version = pluginVersionManager.resolveReportPluginVersion( reportPlugin.getGroupId(), - reportPlugin.getArtifactId(), project, - session.getSettings(), - session.getLocalRepository() ); - reportPlugin.setVersion( version ); - } - - Plugin forLookup = new Plugin(); - - forLookup.setGroupId( reportPlugin.getGroupId() ); - forLookup.setArtifactId( reportPlugin.getArtifactId() ); - forLookup.setVersion( version ); - - return verifyVersionedPlugin( forLookup, project, session.getLocalRepository() ); - } - - private PlexusContainer getPluginContainer( PluginDescriptor pluginDescriptor ) - throws PluginManagerException - { - String pluginKey = pluginDescriptor.getPluginLookupKey(); - - PlexusContainer pluginContainer = container.getChildContainer( pluginKey ); - - if ( pluginContainer == null ) - { - throw new PluginManagerException( "Cannot find Plexus container for plugin: " + pluginKey ); - } - - return pluginContainer; - } - - private Mojo getConfiguredMojo( MavenSession session, - Xpp3Dom dom, - MavenProject project, - boolean report, - MojoExecution mojoExecution ) - throws PluginConfigurationException, ArtifactNotFoundException, PluginManagerException, - ArtifactResolutionException - { - MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); - - PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); - - PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); - - // if this is the first time this plugin has been used, the plugin's container will only - // contain the plugin's artifact in isolation; we need to finish resolving the plugin's - // dependencies, and add them to the container. - ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session ); - - Mojo plugin; - try - { - plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() ); - if ( report && !( plugin instanceof MavenReport ) ) - { - // TODO: the mojoDescriptor should actually capture this information so we don't get this far - return null; - } - } - catch ( ComponentLookupException e ) - { - throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getRoleHint() + - "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'", e ); - } - - if ( plugin instanceof ContextEnabled ) - { - Map pluginContext = session.getPluginContext( pluginDescriptor, project ); - - ( (ContextEnabled) plugin ).setPluginContext( pluginContext ); - } - - plugin.setLog( mojoLogger ); - - XmlPlexusConfiguration pomConfiguration; - if ( dom == null ) - { - pomConfiguration = new XmlPlexusConfiguration( "configuration" ); - } - else - { - pomConfiguration = new XmlPlexusConfiguration( dom ); - } - - // Validate against non-editable (@readonly) parameters, to make sure users aren't trying to - // override in the POM. - validatePomConfiguration( mojoDescriptor, pomConfiguration ); - - PlexusConfiguration mergedConfiguration = mergeMojoConfiguration( pomConfiguration, mojoDescriptor ); - - // TODO: plexus changes to make this more like the component descriptor so this can be used instead - // PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration, - // mojoDescriptor.getConfiguration() ); - - ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution, - pathTranslator, getLogger(), - project, - session.getExecutionProperties() ); - - PlexusConfiguration extractedMojoConfiguration = - extractMojoConfiguration( mergedConfiguration, mojoDescriptor ); - - checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator ); - - populatePluginFields( plugin, mojoDescriptor, extractedMojoConfiguration, pluginContainer, - expressionEvaluator ); - return plugin; - } - - private void ensurePluginContainerIsComplete( PluginDescriptor pluginDescriptor, - PlexusContainer pluginContainer, - MavenProject project, - MavenSession session ) - throws ArtifactNotFoundException, PluginManagerException, ArtifactResolutionException - { - // if the plugin's already been used once, don't re-do this step... - // otherwise, we have to finish resolving the plugin's classpath and start the container. - if ( ( pluginDescriptor.getArtifacts() != null ) && ( pluginDescriptor.getArtifacts().size() == 1 ) ) - { - Artifact pluginArtifact = (Artifact) pluginDescriptor.getArtifacts().get( 0 ); - - ArtifactRepository localRepository = session.getLocalRepository(); - - ResolutionGroup resolutionGroup; - try - { - resolutionGroup = artifactMetadataSource.retrieve( pluginArtifact, localRepository, - project.getPluginArtifactRepositories() ); - } - catch ( ArtifactMetadataRetrievalException e ) - { - throw new ArtifactResolutionException( "Unable to download metadata from repository for plugin '" + - pluginArtifact.getId() + "': " + e.getMessage(), pluginArtifact, e ); - } - - checkPlexusUtils( resolutionGroup, artifactFactory ); - - // [jdcasey; 20-March-2008]: - // This is meant to eliminate the introduction of duplicated artifacts. - // Since much of the reasoning for reversing the order of introduction of - // plugin dependencies rests on the notion that we need to be able to - // introduce upgraded versions of plugin dependencies on a case-by-case - // basis, we need to remove the original version prior to artifact - // resolution. This is consistent with recent thinking on duplicated - // dependency specifications within a POM, where that case should - // throw a model validation exception. - // - // Here, we just want to remove any chance that the ArtifactCollector - // could make a bad choice, and use the old version in spite of our - // explicit preference otherwise. - - // First, we're going to accumulate plugin dependencies in an ordered map, - // keyed by dependencyConflictId (the ordered map is meant to preserve relative - // ordering of the dependencies that do make the cut). - Map dependencyMap = new LinkedHashMap(); - - // Next, we need to accumulate all dependencies in a List, to make it - // simpler to iterate through them all and add them to the map. - List all = new ArrayList(); - - // plugin-level dependencies from the consuming POM override dependencies - // from the plugin's own POM. - all.addAll( pluginDescriptor.getIntroducedDependencyArtifacts() ); - - // add in the deps from the plugin POM now. - all.addAll( resolutionGroup.getArtifacts() ); - - for ( Iterator it = all.iterator(); it.hasNext(); ) - { - Artifact artifact = (Artifact) it.next(); - String conflictId = artifact.getDependencyConflictId(); - - // if the map already contains this dependencyConflictId, it constitutes an - // overridden dependency. Don't use the old one (we know it's old from the - // order in which dependencies were added to this list). - if ( !dependencyMap.containsKey( conflictId ) ) - { - dependencyMap.put( conflictId, artifact ); - } - } - - // Create an ordered set of dependencies from the ordered map we used above, to feed into the resolver. - Set dependencies = new LinkedHashSet( dependencyMap.values() ); - - if ( getLogger().isDebugEnabled() ) - { - // list all dependencies to be used by this plugin (first-level deps, not transitive ones). - getLogger().debug( "Plugin dependencies for:\n\n" + pluginDescriptor.getId() - + "\n\nare:\n\n" - + StringUtils.join( dependencies.iterator(), "\n" ) + "\n\n" ); - } - - List repositories = new ArrayList(); - repositories.addAll( resolutionGroup.getResolutionRepositories() ); - repositories.addAll( project.getRemoteArtifactRepositories() ); - - /* get plugin managed versions */ - Map pluginManagedDependencies = new HashMap(); - try - { - MavenProject pluginProject = - mavenProjectBuilder.buildFromRepository( pluginArtifact, project.getRemoteArtifactRepositories(), - localRepository ); - if ( pluginProject != null ) - { - pluginManagedDependencies = pluginProject.getManagedVersionMap(); - } - } - catch ( ProjectBuildingException e ) - { - // this can't happen, it would have blowed up at artifactMetadataSource.retrieve() - } - - ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact, - pluginManagedDependencies, - localRepository, repositories, - artifactMetadataSource, - artifactFilter ); - - Set resolved = result.getArtifacts(); - - for ( Iterator it = resolved.iterator(); it.hasNext(); ) - { - Artifact artifact = (Artifact) it.next(); - - if ( !artifact.equals( pluginArtifact ) ) - { - artifact = project.replaceWithActiveArtifact( artifact ); - - try - { - pluginContainer.addJarResource( artifact.getFile() ); - } - catch ( PlexusContainerException e ) - { - throw new PluginManagerException( "Error adding plugin dependency '" + - artifact.getDependencyConflictId() + "' into plugin manager: " + e.getMessage(), e ); - } - } - } - - pluginDescriptor.setClassRealm( pluginContainer.getContainerRealm() ); - - List unresolved = new ArrayList( dependencies ); - - unresolved.removeAll( resolved ); - - if ( getLogger().isDebugEnabled() ) - { - // list all artifacts that were filtered out during the resolution process. - // these are already present in the core container. - getLogger().debug( " The following artifacts were filtered out for plugin: " - + pluginDescriptor.getId() - + " because they're already in the core of Maven:\n\n" - + StringUtils.join( unresolved.iterator(), "\n" ) - + "\n\nThese will use the artifact files already in the core ClassRealm instead, to allow them to be included in PluginDescriptor.getArtifacts().\n\n" ); - } - - // Grab a file for all filtered artifacts, even if it means resolving them. This - // is necessary in order to present a full complement of a plugin's transitive - // dependencies to anyone who calls PluginDescriptor.getArtifacts(). - resolveCoreArtifacts( unresolved, localRepository, resolutionGroup.getResolutionRepositories() ); - - // Re-join resolved and filtered-but-now-resolved artifacts. - // NOTE: The process of filtering then re-adding some artifacts will - // result in different ordering within the PluginDescriptor.getArtifacts() - // List than should have happened if none had been filtered. All filtered - // artifacts will be listed last... - List allResolved = new ArrayList( resolved.size() + unresolved.size() ); - - allResolved.addAll( resolved ); - allResolved.addAll( unresolved ); - - pluginDescriptor.setArtifacts( allResolved ); - } - } - - public static void checkPlexusUtils( ResolutionGroup resolutionGroup, ArtifactFactory artifactFactory ) - { - // ---------------------------------------------------------------------------- - // If the plugin already declares a dependency on plexus-utils then we're all - // set as the plugin author is aware of its use. If we don't have a dependency - // on plexus-utils then we must protect users from stupid plugin authors who - // did not declare a direct dependency on plexus-utils because the version - // Maven uses is hidden from downstream use. We will also bump up any - // anything below 1.1 to 1.1 as this mimics the behaviour in 2.0.5 where - // plexus-utils 1.1 was being forced into use. - // ---------------------------------------------------------------------------- - - VersionRange vr = null; - - try - { - vr = VersionRange.createFromVersionSpec( "[1.1,)" ); - } - catch ( InvalidVersionSpecificationException e ) - { - // Won't happen - } - - boolean plexusUtilsPresent = false; - - for ( Iterator i = resolutionGroup.getArtifacts().iterator(); i.hasNext(); ) - { - Artifact a = (Artifact) i.next(); - - if ( a.getArtifactId().equals( "plexus-utils" ) && - vr.containsVersion( new DefaultArtifactVersion( a.getVersion() ) ) ) - { - plexusUtilsPresent = true; - - break; - } - } - - if ( !plexusUtilsPresent ) - { - // We will add plexus-utils as every plugin was getting this anyway from Maven itself. We will set the - // version to the latest version we know that works as of the 2.0.6 release. We set the scope to runtime - // as this is what's implicitly happening in 2.0.6. - - resolutionGroup.getArtifacts().add( artifactFactory.createArtifact( "org.codehaus.plexus", - "plexus-utils", "1.1", - Artifact.SCOPE_RUNTIME, "jar" ) ); - } - } - - private void resolveCoreArtifacts( List unresolved, - ArtifactRepository localRepository, - List resolutionRepositories ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - for ( Iterator it = unresolved.iterator(); it.hasNext(); ) - { - Artifact artifact = (Artifact) it.next(); - - File artifactFile = (File) resolvedCoreArtifactFiles.get( artifact.getId() ); - - if ( artifactFile == null ) - { - String resource = - "/META-INF/maven/" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/pom.xml"; - - URL resourceUrl = container.getContainerRealm().getResource( resource ); - - if ( resourceUrl == null ) - { - artifactResolver.resolve( artifact, resolutionRepositories, localRepository ); - - artifactFile = artifact.getFile(); - } - else - { - String artifactPath = resourceUrl.getPath(); - - if ( artifactPath.startsWith( "file:" ) ) - { - artifactPath = artifactPath.substring( "file:".length() ); - } - - artifactPath = artifactPath.substring( 0, artifactPath.length() - resource.length() ); - - if ( artifactPath.endsWith( "/" ) ) - { - artifactPath = artifactPath.substring( 0, artifactPath.length() - 1 ); - } - - if ( artifactPath.endsWith( "!" ) ) - { - artifactPath = artifactPath.substring( 0, artifactPath.length() - 1 ); - } - - artifactFile = new File( artifactPath ).getAbsoluteFile(); - } - - resolvedCoreArtifactFiles.put( artifact.getId(), artifactFile ); - } - - artifact.setFile( artifactFile ); - } - } - - private PlexusConfiguration extractMojoConfiguration( PlexusConfiguration mergedConfiguration, - MojoDescriptor mojoDescriptor ) - { - Map parameterMap = mojoDescriptor.getParameterMap(); - - PlexusConfiguration[] mergedChildren = mergedConfiguration.getChildren(); - - XmlPlexusConfiguration extractedConfiguration = new XmlPlexusConfiguration( "configuration" ); - - for ( int i = 0; i < mergedChildren.length; i++ ) - { - PlexusConfiguration child = mergedChildren[i]; - - if ( parameterMap.containsKey( child.getName() ) ) - { - extractedConfiguration.addChild( copyConfiguration( child ) ); - } - else - { - // TODO: I defy anyone to find these messages in the '-X' output! Do we need a new log level? - // ideally, this would be elevated above the true debug output, but below the default INFO level... - // [BP] (2004-07-18): need to understand the context more but would prefer this could be either WARN or - // removed - shouldn't need DEBUG to diagnose a problem most of the time. - getLogger().debug( "*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" + - mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" ); - } - } - - return extractedConfiguration; - } - - private void checkRequiredParameters( MojoDescriptor goal, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator ) - throws PluginConfigurationException - { - // TODO: this should be built in to the configurator, as we presently double process the expressions - - List parameters = goal.getParameters(); - - if ( parameters == null ) - { - return; - } - - List invalidParameters = new ArrayList(); - - for ( int i = 0; i < parameters.size(); i++ ) - { - Parameter parameter = (Parameter) parameters.get( i ); - - if ( parameter.isRequired() ) - { - // the key for the configuration map we're building. - String key = parameter.getName(); - - Object fieldValue = null; - String expression = null; - PlexusConfiguration value = configuration.getChild( key, false ); - try - { - if ( value != null ) - { - expression = value.getValue( null ); - - fieldValue = expressionEvaluator.evaluate( expression ); - - if ( fieldValue == null ) - { - fieldValue = value.getAttribute( "default-value", null ); - } - } - - if ( ( fieldValue == null ) && StringUtils.isNotEmpty( parameter.getAlias() ) ) - { - value = configuration.getChild( parameter.getAlias(), false ); - if ( value != null ) - { - expression = value.getValue( null ); - fieldValue = expressionEvaluator.evaluate( expression ); - if ( fieldValue == null ) - { - fieldValue = value.getAttribute( "default-value", null ); - } - } - } - } - catch ( ExpressionEvaluationException e ) - { - throw new PluginConfigurationException( goal.getPluginDescriptor(), e.getMessage(), e ); - } - - // only mark as invalid if there are no child nodes - if ( ( fieldValue == null ) && ( ( value == null ) || ( value.getChildCount() == 0 ) ) ) - { - parameter.setExpression( expression ); - invalidParameters.add( parameter ); - } - } - } - - if ( !invalidParameters.isEmpty() ) - { - throw new PluginParameterException( goal, invalidParameters ); - } - } - - private void validatePomConfiguration( MojoDescriptor goal, - PlexusConfiguration pomConfiguration ) - throws PluginConfigurationException - { - List parameters = goal.getParameters(); - - if ( parameters == null ) - { - return; - } - - for ( int i = 0; i < parameters.size(); i++ ) - { - Parameter parameter = (Parameter) parameters.get( i ); - - // the key for the configuration map we're building. - String key = parameter.getName(); - - PlexusConfiguration value = pomConfiguration.getChild( key, false ); - - if ( ( value == null ) && StringUtils.isNotEmpty( parameter.getAlias() ) ) - { - key = parameter.getAlias(); - value = pomConfiguration.getChild( key, false ); - } - - if ( value != null ) - { - // Make sure the parameter is either editable/configurable, or else is NOT specified in the POM - if ( !parameter.isEditable() ) - { - StringBuffer errorMessage = new StringBuffer() - .append( "ERROR: Cannot override read-only parameter: " ); - errorMessage.append( key ); - errorMessage.append( " in goal: " ).append( goal.getFullGoalName() ); - - throw new PluginConfigurationException( goal.getPluginDescriptor(), errorMessage.toString() ); - } - - String deprecated = parameter.getDeprecated(); - if ( StringUtils.isNotEmpty( deprecated ) ) - { - getLogger().warn( "DEPRECATED [" + parameter.getName() + "]: " + deprecated ); - } - } - } - } - - private PlexusConfiguration mergeMojoConfiguration( XmlPlexusConfiguration fromPom, - MojoDescriptor mojoDescriptor ) - { - XmlPlexusConfiguration result = new XmlPlexusConfiguration( fromPom.getName() ); - result.setValue( fromPom.getValue( null ) ); - - if ( mojoDescriptor.getParameters() != null ) - { - PlexusConfiguration fromMojo = mojoDescriptor.getMojoConfiguration(); - - for ( Iterator it = mojoDescriptor.getParameters().iterator(); it.hasNext(); ) - { - Parameter parameter = (Parameter) it.next(); - - String paramName = parameter.getName(); - String alias = parameter.getAlias(); - String implementation = parameter.getImplementation(); - - PlexusConfiguration pomConfig = fromPom.getChild( paramName ); - PlexusConfiguration aliased = null; - - if ( alias != null ) - { - aliased = fromPom.getChild( alias ); - } - - PlexusConfiguration mojoConfig = fromMojo.getChild( paramName, false ); - - // first we'll merge configurations from the aliased and real params. - // TODO: Is this the right thing to do? - if ( aliased != null ) - { - if ( pomConfig == null ) - { - pomConfig = new XmlPlexusConfiguration( paramName ); - } - - pomConfig = buildTopDownMergedConfiguration( pomConfig, aliased ); - } - - PlexusConfiguration toAdd = null; - - if ( pomConfig != null ) - { - pomConfig = buildTopDownMergedConfiguration( pomConfig, mojoConfig ); - - if ( StringUtils.isNotEmpty( pomConfig.getValue( null ) ) || ( pomConfig.getChildCount() > 0 ) ) - { - toAdd = pomConfig; - } - } - - if ( ( toAdd == null ) && ( mojoConfig != null ) ) - { - toAdd = copyConfiguration( mojoConfig ); - } - - if ( toAdd != null ) - { - if ( ( implementation != null ) && ( toAdd.getAttribute( "implementation", null ) == null ) ) - { - - XmlPlexusConfiguration implementationConf = new XmlPlexusConfiguration( paramName ); - - implementationConf.setAttribute( "implementation", parameter.getImplementation() ); - - toAdd = buildTopDownMergedConfiguration( toAdd, implementationConf ); - } - - result.addChild( toAdd ); - } - } - } - return result; - } - - private XmlPlexusConfiguration buildTopDownMergedConfiguration( PlexusConfiguration dominant, - PlexusConfiguration recessive ) - { - XmlPlexusConfiguration result = new XmlPlexusConfiguration( dominant.getName() ); - - String value = dominant.getValue( null ); - - if ( StringUtils.isEmpty( value ) && ( recessive != null ) ) - { - value = recessive.getValue( null ); - } - - if ( StringUtils.isNotEmpty( value ) ) - { - result.setValue( value ); - } - - String[] attributeNames = dominant.getAttributeNames(); - - for ( int i = 0; i < attributeNames.length; i++ ) - { - String attributeValue = dominant.getAttribute( attributeNames[i], null ); - - result.setAttribute( attributeNames[i], attributeValue ); - } - - if ( recessive != null ) - { - attributeNames = recessive.getAttributeNames(); - - for ( int i = 0; i < attributeNames.length; i++ ) - { - String attributeValue = recessive.getAttribute( attributeNames[i], null ); - // TODO: recessive seems to be dominant here? - result.setAttribute( attributeNames[i], attributeValue ); - } - } - - PlexusConfiguration[] children = dominant.getChildren(); - - for ( int i = 0; i < children.length; i++ ) - { - PlexusConfiguration childDom = children[i]; - PlexusConfiguration childRec = recessive == null ? null : recessive.getChild( childDom.getName(), false ); - - if ( childRec != null ) - { - result.addChild( buildTopDownMergedConfiguration( childDom, childRec ) ); - } - else - { // FIXME: copy, or use reference? - result.addChild( copyConfiguration( childDom ) ); - } - } - - return result; - } - - public static PlexusConfiguration copyConfiguration( PlexusConfiguration src ) - { - // TODO: shouldn't be necessary - XmlPlexusConfiguration dom = new XmlPlexusConfiguration( src.getName() ); - dom.setValue( src.getValue( null ) ); - - String[] attributeNames = src.getAttributeNames(); - for ( int i = 0; i < attributeNames.length; i++ ) - { - String attributeName = attributeNames[i]; - dom.setAttribute( attributeName, src.getAttribute( attributeName, null ) ); - } - - PlexusConfiguration[] children = src.getChildren(); - for ( int i = 0; i < children.length; i++ ) - { - dom.addChild( copyConfiguration( children[i] ) ); - } - - return dom; - } - - // ---------------------------------------------------------------------- - // Mojo Parameter Handling - // ---------------------------------------------------------------------- - - private void populatePluginFields( Mojo plugin, - MojoDescriptor mojoDescriptor, - PlexusConfiguration configuration, - PlexusContainer pluginContainer, - ExpressionEvaluator expressionEvaluator ) - throws PluginConfigurationException - { - ComponentConfigurator configurator = null; - - try - { - String configuratorId = mojoDescriptor.getComponentConfigurator(); - - // TODO: could the configuration be passed to lookup and the configurator known to plexus via the descriptor - // so that this meethod could entirely be handled by a plexus lookup? - if ( StringUtils.isNotEmpty( configuratorId ) ) - { - configurator = - (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE, configuratorId ); - } - else - { - configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE ); - } - - ConfigurationListener listener = new DebugConfigurationListener( getLogger() ); - - getLogger().debug( "Configuring mojo '" + mojoDescriptor.getId() + "' -->" ); - configurator.configureComponent( plugin, configuration, expressionEvaluator, - pluginContainer.getContainerRealm(), listener ); - getLogger().debug( "-- end configuration --" ); - } - catch ( ComponentConfigurationException e ) - { - throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), - "Unable to parse the created DOM for plugin configuration", e ); - } - catch ( ComponentLookupException e ) - { - throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), - "Unable to retrieve component configurator for plugin configuration", - e ); - } - catch ( LinkageError e ) - { - if ( getLogger().isFatalErrorEnabled() ) - { - getLogger().fatalError( - configurator.getClass().getName() + "#configureComponent(...) caused a linkage error (" - + e.getClass().getName() + ") and may be out-of-date. Check the realms:" ); - - ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm(); - StringBuffer sb = new StringBuffer(); - sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' ); - for ( int i = 0; i < pluginRealm.getConstituents().length; i++ ) - { - sb.append( "urls[" + i + "] = " + pluginRealm.getConstituents()[i] ); - if ( i != ( pluginRealm.getConstituents().length - 1 ) ) - { - sb.append( '\n' ); - } - } - getLogger().fatalError( sb.toString() ); - - ClassRealm containerRealm = container.getContainerRealm(); - sb = new StringBuffer(); - sb.append( "Container realm = " + containerRealm.getId() ).append( '\n' ); - for ( int i = 0; i < containerRealm.getConstituents().length; i++ ) - { - sb.append( "urls[" + i + "] = " + containerRealm.getConstituents()[i] ); - if ( i != ( containerRealm.getConstituents().length - 1 ) ) - { - sb.append( '\n' ); - } - } - getLogger().fatalError( sb.toString() ); - } - - throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), - e.getClass().getName() + ": " + e.getMessage(), e ); - } - finally - { - if ( configurator != null ) - { - try - { - pluginContainer.release( configurator ); - } - catch ( ComponentLifecycleException e ) - { - getLogger().debug( "Failed to release plugin container - ignoring." ); - } - } - } - } - - public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, - Parameter parameter, - String expression ) - { - StringBuffer message = new StringBuffer(); - - message.append( "The '" ); - message.append( parameter.getName() ); - message.append( "' parameter is required for the execution of the " ); - message.append( mojo.getFullGoalName() ); - message.append( " mojo and cannot be null." ); - if ( expression != null ) - { - message.append( " The retrieval expression was: " ).append( expression ); - } - - return message.toString(); - } - - // ---------------------------------------------------------------------- - // Lifecycle - // ---------------------------------------------------------------------- - - public void contextualize( Context context ) - throws ContextException - { - container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); - - mojoLogger = new DefaultLog( container.getLoggerManager().getLoggerForComponent( Mojo.ROLE ) ); - } - - public void initialize() - { - artifactFilter = MavenArtifactFilterManager.createStandardFilter(); - } - - // ---------------------------------------------------------------------- - // Artifact resolution - // ---------------------------------------------------------------------- - - private void resolveTransitiveDependencies( MavenSession context, - ArtifactResolver artifactResolver, - String scope, - ArtifactFactory artifactFactory, - MavenProject project, boolean isAggregator ) - throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException - { - ArtifactFilter filter = new ScopeArtifactFilter( scope ); - - // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type - Artifact artifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(), - project.getVersion(), project.getPackaging() ); - - // TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same - // check this with yourkit as a hot spot. - // Don't recreate if already created - for effeciency, and because clover plugin adds to it - if ( project.getDependencyArtifacts() == null ) - { - project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) ); - } - - Set resolvedArtifacts; - try - { - ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(), - artifact, - project.getManagedVersionMap(), - context.getLocalRepository(), - project.getRemoteArtifactRepositories(), - artifactMetadataSource, filter ); - resolvedArtifacts = result.getArtifacts(); - } - catch (MultipleArtifactsNotFoundException me) - { - /*only do this if we are an aggregating plugin: MNG-2277 - if the dependency doesn't yet exist but is in the reactor, then - all we can do is warn and skip it. A better fix can be inserted into 2.1*/ - if (isAggregator && checkMissingArtifactsInReactor( context.getSortedProjects(), me.getMissingArtifacts() )) - { - resolvedArtifacts = new HashSet(me.getResolvedArtifacts()); - } - else - { - //we can't find all the artifacts in the reactor so bubble the exception up. - throw me; - } - } - project.setArtifacts( resolvedArtifacts ); - } - - /** - * This method is checking to see if the artifacts that can't be resolved are all - * part of this reactor. This is done to prevent a chicken or egg scenario with - * fresh projects that have a plugin that is an aggregator and requires dependencies. See - * MNG-2277 for more info. - * @param projects the sibling projects in the reactor - * @param missing the artifacts that can't be found - * @return true if ALL missing artifacts are found in the reactor. - */ - private boolean checkMissingArtifactsInReactor(Collection projects, Collection missing) - { - Collection foundInReactor = new HashSet(); - Iterator iter = missing.iterator(); - while (iter.hasNext()) - { - Artifact mArtifact = (Artifact) iter.next(); - Iterator pIter = projects.iterator(); - while (pIter.hasNext()) - { - MavenProject p = (MavenProject) pIter.next(); - if (p.getArtifactId().equals( mArtifact.getArtifactId()) && - p.getGroupId().equals( mArtifact.getGroupId()) && - p.getVersion().equals( mArtifact.getVersion())) - { - //TODO: the packaging could be different, but the exception doesn't contain that info - //most likely it would be produced by the project we just found in the reactor since all - //the other info matches. Assume it's ok. - getLogger().warn( "The dependency: "+ p.getId()+" can't be resolved but has been found in the reactor.\nThis dependency has been excluded from the plugin execution. You should rerun this mojo after executing mvn install.\n" ); - - //found it, move on. - foundInReactor.add( p ); - break; - } - } - } - - //if all of them have been found, we can continue. - return foundInReactor.size() == missing.size(); - } - - - // ---------------------------------------------------------------------- - // Artifact downloading - // ---------------------------------------------------------------------- - - private void downloadDependencies( MavenProject project, - MavenSession context, - ArtifactResolver artifactResolver ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - ArtifactRepository localRepository = context.getLocalRepository(); - List remoteArtifactRepositories = project.getRemoteArtifactRepositories(); - - for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); ) - { - Artifact artifact = (Artifact) it.next(); - - artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository ); - } - } - - public Object getPluginComponent( Plugin plugin, - String role, - String roleHint ) - throws PluginManagerException, ComponentLookupException - { - PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin ); - - PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); - - return pluginContainer.lookup( role, roleHint ); - } - - public Map getPluginComponents( Plugin plugin, - String role ) - throws ComponentLookupException, PluginManagerException - { - PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin ); - - PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); - - return pluginContainer.lookupMap( role ); - } -} \ No newline at end of file diff --git a/maven-interceptor/src/main/java/hudson/maven/agent/PluginManagerInterceptor.java b/maven-interceptor/src/main/java/hudson/maven/agent/PluginManagerInterceptor.java index 94131b9721..b5686ee5cd 100644 --- a/maven-interceptor/src/main/java/hudson/maven/agent/PluginManagerInterceptor.java +++ b/maven-interceptor/src/main/java/hudson/maven/agent/PluginManagerInterceptor.java @@ -23,15 +23,19 @@ */ package hudson.maven.agent; +import java.io.IOException; +import java.lang.reflect.Method; + import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.DefaultPluginManager; +import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginManagerException; -import org.apache.maven.plugin.Mojo; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.reporting.MavenReport; @@ -42,13 +46,10 @@ import org.codehaus.plexus.component.configurator.ComponentConfigurationExceptio import org.codehaus.plexus.component.configurator.ComponentConfigurator; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.configuration.PlexusConfiguration; -import java.io.IOException; -import java.lang.reflect.Method; - /** * Description in META-INF/plexus/components.xml makes it possible to use this instead of the default * plugin manager. diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index c63f7ffbbc..1fa984c22f 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -25,9 +25,9 @@ package hudson.maven; import hudson.Extension; import hudson.FilePath; +import hudson.maven.agent.AbortException; import hudson.maven.agent.Main; import hudson.maven.agent.Maven21Interceptor; -import hudson.maven.agent.PluginManagerInterceptor; import hudson.model.Computer; import hudson.model.TaskListener; import hudson.remoting.Channel; @@ -38,6 +38,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import org.apache.maven.lifecycle.LifecycleExecutorInterceptor; import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Zip; @@ -58,7 +59,7 @@ public class MavenComputerListener extends ComputerListener { copyJar(logger, root, Main.class, "maven-agent"); copyJar(logger, root, Maven3Main.class, "maven3-agent"); copyJar(logger, root, Maven3Launcher.class, "maven3-listener"); - copyJar(logger, root, PluginManagerInterceptor.class, "maven-interceptor"); + copyJar(logger, root, AbortException.class, "maven-interceptor"); copyJar(logger, root, Maven21Interceptor.class, "maven2.1-interceptor"); copyJar(logger, root, ClassWorld.class, "plexus-classworld"); copyJar(logger, root, AntClassLoader.class, "maven-plugin-ant"); -- GitLab From e41af9074743558f2a31985bc65bdb563c796309 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 11 Dec 2010 22:53:20 +0100 Subject: [PATCH 0036/2361] remove uused import --- .../src/main/java/hudson/maven/MavenComputerListener.java | 1 - 1 file changed, 1 deletion(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index 1fa984c22f..bf7dd05f3f 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -38,7 +38,6 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; -import org.apache.maven.lifecycle.LifecycleExecutorInterceptor; import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Zip; -- GitLab From 97594acceb7b16114454df2beace78d065a72769 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 11 Dec 2010 23:02:40 +0100 Subject: [PATCH 0037/2361] rename maven3-listener to maven3-interceptor --- maven-plugin/pom.xml | 2 +- maven3-agent/pom.xml | 2 +- {maven3-listener => maven3-interceptor}/.gitignore | 0 {maven3-listener => maven3-interceptor}/pom.xml | 4 ++-- .../apache/maven/cli/DefaultMavenExecutionRequestBuilder.java | 0 .../org/apache/maven/cli/MavenExecutionRequestBuilder.java | 0 .../maven/cli/MavenExecutionRequestsBuilderException.java | 0 .../java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java | 0 .../jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java | 0 .../hudson/maven3/listeners/HudsonMavenExecutionResult.java | 0 .../hudson/maven3/listeners/MavenProjectBuildResult.java | 0 .../org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java | 0 pom.xml | 2 +- 13 files changed, 5 insertions(+), 5 deletions(-) rename {maven3-listener => maven3-interceptor}/.gitignore (100%) rename {maven3-listener => maven3-interceptor}/pom.xml (94%) rename {maven3-listener => maven3-interceptor}/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java (100%) rename {maven3-listener => maven3-interceptor}/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java (100%) rename {maven3-listener => maven3-interceptor}/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java (100%) rename {maven3-listener => maven3-interceptor}/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java (100%) rename {maven3-listener => maven3-interceptor}/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java (100%) rename {maven3-listener => maven3-interceptor}/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java (100%) rename {maven3-listener => maven3-interceptor}/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java (100%) rename {maven3-listener => maven3-interceptor}/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java (100%) diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 703c12619e..cce3d4a92d 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -77,7 +77,7 @@ THE SOFTWARE. org.jvnet.hudson.main - maven3-listener + maven3-interceptor ${project.version} diff --git a/maven3-agent/pom.xml b/maven3-agent/pom.xml index f32a31bcf8..52d3fac179 100755 --- a/maven3-agent/pom.xml +++ b/maven3-agent/pom.xml @@ -8,7 +8,7 @@ 1.389-SNAPSHOT maven3-agent - maven3-agent + Hudson Maven3 Agent org.jvnet.hudson.main diff --git a/maven3-listener/.gitignore b/maven3-interceptor/.gitignore similarity index 100% rename from maven3-listener/.gitignore rename to maven3-interceptor/.gitignore diff --git a/maven3-listener/pom.xml b/maven3-interceptor/pom.xml similarity index 94% rename from maven3-listener/pom.xml rename to maven3-interceptor/pom.xml index 9b3841e810..42750e23c4 100755 --- a/maven3-listener/pom.xml +++ b/maven3-interceptor/pom.xml @@ -7,8 +7,8 @@ pom 1.389-SNAPSHOT - maven3-listener - maven3-listener + maven3-interceptor + Maven3 Interceptor diff --git a/maven3-listener/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java b/maven3-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java similarity index 100% rename from maven3-listener/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java rename to maven3-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java diff --git a/maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java b/maven3-interceptor/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java similarity index 100% rename from maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java rename to maven3-interceptor/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java diff --git a/maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java b/maven3-interceptor/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java similarity index 100% rename from maven3-listener/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java rename to maven3-interceptor/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java similarity index 100% rename from maven3-listener/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java rename to maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java similarity index 100% rename from maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java rename to maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java similarity index 100% rename from maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java rename to maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java similarity index 100% rename from maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java rename to maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java diff --git a/maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java similarity index 100% rename from maven3-listener/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java rename to maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java diff --git a/pom.xml b/pom.xml index 9f6a29a54d..28b75aeb14 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ THE SOFTWARE. maven-agent maven-interceptor maven3-agent - maven3-listener + maven3-interceptor war test cli -- GitLab From 4c4b1efb7772ef435a1e6d7e16124f4301fa2839 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 11 Dec 2010 23:11:43 +0100 Subject: [PATCH 0038/2361] rename maven3-listener to maven3-interceptor --- .../src/main/java/hudson/maven/Maven3ProcessFactory.java | 2 +- .../src/main/java/hudson/maven/MavenComputerListener.java | 2 +- .../java/org/jvnet/hudson/maven3/agent/Maven3Main.java | 8 ++++---- .../org/jvnet/hudson/maven3/agent/classworlds.conf | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3ProcessFactory.java b/maven-plugin/src/main/java/hudson/maven/Maven3ProcessFactory.java index 429408971c..0ef536963a 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3ProcessFactory.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3ProcessFactory.java @@ -280,7 +280,7 @@ public class Maven3ProcessFactory implements ProcessCache.Factory args.add(isMaster? Which.jarFile(Maven3Launcher.class).getAbsolutePath(): - slaveRoot.child("maven3-listener.jar").getRemote()); + slaveRoot.child("maven3-interceptor.jar").getRemote()); // TCP/IP port to establish the remoting infrastructure args.add(tcpPort); diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index bf7dd05f3f..c9f8fc8ca8 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -57,7 +57,7 @@ public class MavenComputerListener extends ComputerListener { PrintStream logger = listener.getLogger(); copyJar(logger, root, Main.class, "maven-agent"); copyJar(logger, root, Maven3Main.class, "maven3-agent"); - copyJar(logger, root, Maven3Launcher.class, "maven3-listener"); + copyJar(logger, root, Maven3Launcher.class, "maven3-interceptor"); copyJar(logger, root, AbortException.class, "maven-interceptor"); copyJar(logger, root, Maven21Interceptor.class, "maven2.1-interceptor"); copyJar(logger, root, ClassWorld.class, "plexus-classworld"); diff --git a/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java b/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java index 1e8df7dfcf..a9040fd856 100755 --- a/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java +++ b/maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java @@ -71,7 +71,7 @@ public class Maven3Main { * we'll run. * @param remotingJar * Hudson's remoting.jar that we'll load. - * @param listenerJar + * @param interceptorJar * maven-listener.jar that we'll load. * @param tcpPort * TCP socket that the launching Hudson will be listening to. @@ -79,7 +79,7 @@ public class Maven3Main { * @param projectBuildLaunch * launch the projectBuilder and not a mavenExecution */ - public static void main(File m2Home, File remotingJar, File listenerJar, + public static void main(File m2Home, File remotingJar, File interceptorJar, int tcpPort) throws Exception { // Unix master with Windows slave ends up passing path in Unix format, // so convert it to Windows format now so that no one chokes with the @@ -99,8 +99,8 @@ public class Maven3Main { // expose variables used in the classworlds configuration System.setProperty("maven.home", m2Home.getPath()); - System.setProperty("maven3.listener", (listenerJar != null ? listenerJar - : listenerJar).getPath()); + System.setProperty("maven3.interceptor", (interceptorJar != null ? interceptorJar + : interceptorJar).getPath()); // load the default realms launcher = new Launcher(); diff --git a/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf b/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf index f4675ae49a..c2ee229253 100755 --- a/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf +++ b/maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf @@ -6,5 +6,5 @@ main is org.jvnet.hudson.maven3.launcher.Maven3Launcher from plexus.core set maven.home default ${user.home}/m2 [plexus.core] -load ${maven3.listener} +load ${maven3.interceptor} load ${maven.home}/lib/*.jar \ No newline at end of file -- GitLab From 1d8c324dd6bccdd9d493f9ee6d953ca85591db09 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 11 Dec 2010 18:50:58 -0800 Subject: [PATCH 0039/2361] [maven-release-plugin] prepare release hudson-1_389 --- cli/pom.xml | 2 +- core/pom.xml | 2 +- maven-agent/pom.xml | 2 +- maven-interceptor/pom.xml | 2 +- maven-plugin/pom.xml | 2 +- pom.xml | 2 +- remoting/pom.xml | 2 +- test/pom.xml | 2 +- ui-samples-plugin/pom.xml | 2 +- war/pom.xml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 2deea1f357..af1060fa2f 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -4,7 +4,7 @@ pom org.jvnet.hudson.main - 1.389-SNAPSHOT + 1.389 cli Hudson CLI diff --git a/core/pom.xml b/core/pom.xml index c147b4c088..c7a3a047d6 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389-SNAPSHOT + 1.389 ../pom.xml diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index e3448e8440..243d1a61c0 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389-SNAPSHOT + 1.389 ../pom.xml diff --git a/maven-interceptor/pom.xml b/maven-interceptor/pom.xml index 0bad3dce61..91c8b187ea 100644 --- a/maven-interceptor/pom.xml +++ b/maven-interceptor/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389-SNAPSHOT + 1.389 ../pom.xml diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 711bda68a1..a541f4582c 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389-SNAPSHOT + 1.389 maven-plugin diff --git a/pom.xml b/pom.xml index 6e23c7d8ad..c8223f6015 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389-SNAPSHOT + 1.389 pom Hudson main module diff --git a/remoting/pom.xml b/remoting/pom.xml index 29d9b59fcc..893ea86f16 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389-SNAPSHOT + 1.389 ../pom.xml diff --git a/test/pom.xml b/test/pom.xml index b1dcc97405..40fb052e94 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. pom org.jvnet.hudson.main - 1.389-SNAPSHOT + 1.389 4.0.0 org.jvnet.hudson.main diff --git a/ui-samples-plugin/pom.xml b/ui-samples-plugin/pom.xml index e4be200bc8..93a90d5c41 100644 --- a/ui-samples-plugin/pom.xml +++ b/ui-samples-plugin/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389-SNAPSHOT + 1.389 ui-samples-plugin diff --git a/war/pom.xml b/war/pom.xml index 72663f438b..8028c3003f 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389-SNAPSHOT + 1.389 ../pom.xml -- GitLab From c6e3e73da59f7a70c541d362ac03fa8f5a088fa2 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 11 Dec 2010 18:51:06 -0800 Subject: [PATCH 0040/2361] [maven-release-plugin] prepare for next development iteration --- cli/pom.xml | 2 +- core/pom.xml | 2 +- maven-agent/pom.xml | 2 +- maven-interceptor/pom.xml | 2 +- maven-plugin/pom.xml | 2 +- pom.xml | 2 +- remoting/pom.xml | 2 +- test/pom.xml | 2 +- ui-samples-plugin/pom.xml | 2 +- war/pom.xml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index af1060fa2f..763c0276c1 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -4,7 +4,7 @@ pom org.jvnet.hudson.main - 1.389 + 1.390-SNAPSHOT cli Hudson CLI diff --git a/core/pom.xml b/core/pom.xml index c7a3a047d6..9b9776cf67 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389 + 1.390-SNAPSHOT ../pom.xml diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index 243d1a61c0..2fa0a5e4d4 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389 + 1.390-SNAPSHOT ../pom.xml diff --git a/maven-interceptor/pom.xml b/maven-interceptor/pom.xml index 91c8b187ea..feb91a3677 100644 --- a/maven-interceptor/pom.xml +++ b/maven-interceptor/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389 + 1.390-SNAPSHOT ../pom.xml diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index a541f4582c..ad7bb97628 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389 + 1.390-SNAPSHOT maven-plugin diff --git a/pom.xml b/pom.xml index c8223f6015..c2e1fa3205 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389 + 1.390-SNAPSHOT pom Hudson main module diff --git a/remoting/pom.xml b/remoting/pom.xml index 893ea86f16..fb12e455e2 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389 + 1.390-SNAPSHOT ../pom.xml diff --git a/test/pom.xml b/test/pom.xml index 40fb052e94..65d814f522 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. pom org.jvnet.hudson.main - 1.389 + 1.390-SNAPSHOT 4.0.0 org.jvnet.hudson.main diff --git a/ui-samples-plugin/pom.xml b/ui-samples-plugin/pom.xml index 93a90d5c41..2dee2f5082 100644 --- a/ui-samples-plugin/pom.xml +++ b/ui-samples-plugin/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389 + 1.390-SNAPSHOT ui-samples-plugin diff --git a/war/pom.xml b/war/pom.xml index 8028c3003f..ece709b1b1 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.389 + 1.390-SNAPSHOT ../pom.xml -- GitLab From 06198fb6c4d238cd7cbd54315dfdcfac852d3012 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 11 Dec 2010 22:03:49 -0800 Subject: [PATCH 0041/2361] updated changelog for release --- changelog.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/changelog.html b/changelog.html index 55b2519092..606d1f35c0 100644 --- a/changelog.html +++ b/changelog.html @@ -46,7 +46,10 @@ Upcoming changes +

    What's new in 1.389 (2010/12/11)

    • Hide executors for offline nodes to conserve space in Build Executors Status list. @@ -55,7 +58,6 @@ Upcoming changes throw AccessDeniedException if "Authentication Token" is invalid. (hudson-ja)
    -

    What's new in 1.388 (2010/12/04)

    • -- GitLab From 204bad88effc82b711d89d8f9bb12e97a2b92d6c Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 11 Dec 2010 22:04:40 -0800 Subject: [PATCH 0042/2361] released a new plugin parent POM --- plugins/pom.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/pom.xml b/plugins/pom.xml index 2dee0875c6..2c5bbabcf4 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -11,7 +11,7 @@ org.jvnet.hudson.plugins plugin Hudson plugin POM - 1.388 + 1.389 pom @@ -39,7 +39,7 @@ org.jvnet.hudson.main maven-plugin - 1.388 + 1.389 @@ -49,25 +49,25 @@ org.jvnet.hudson.main hudson-war war - 1.388 + 1.389 test org.jvnet.hudson.main hudson-core - 1.388 + 1.389 provided org.jvnet.hudson.main hudson-test-harness - 1.388 + 1.389 test org.jvnet.hudson.main ui-samples-plugin - 1.388 + 1.389 test @@ -98,7 +98,7 @@ org.jvnet.hudson.main maven-plugin - 1.388 + 1.389 -- GitLab From 89f159f441efeef95230b0d0eca0fc46cf752661 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 11 Dec 2010 22:07:29 -0800 Subject: [PATCH 0043/2361] updated changelog as a part of the release --- debian/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/debian/changelog b/debian/debian/changelog index 7b72f4430b..5330740503 100644 --- a/debian/debian/changelog +++ b/debian/debian/changelog @@ -1,3 +1,9 @@ +hudson (1.389) unstable; urgency=low + + * See http://hudson.dev.java.net/changelog.html for more details. + + -- Kohsuke Kawaguchi Sat, 11 Dec 2010 22:05:31 -0800 + hudson (1.388) unstable; urgency=low * See http://hudson.dev.java.net/changelog.html for more details. -- GitLab From cee599c187ab51c38f437fc4b0dafc245c30390d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sun, 12 Dec 2010 09:54:12 +0100 Subject: [PATCH 0044/2361] simplify maven2 agent with using classworld adapter --- maven-agent/pom.xml | 9 +- .../main/java/hudson/maven/agent/Main.java | 234 ++---------------- maven-plugin/pom.xml | 6 + .../main/java/hudson/maven/MavenBuilder.java | 8 + 4 files changed, 49 insertions(+), 208 deletions(-) diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index e2ff5194f3..8c2484dc2c 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -80,10 +80,17 @@ THE SOFTWARE. + org.codehaus.plexus plexus-classworlds - + org.apache.ant ant diff --git a/maven-agent/src/main/java/hudson/maven/agent/Main.java b/maven-agent/src/main/java/hudson/maven/agent/Main.java index f3cf593115..045bf93d94 100644 --- a/maven-agent/src/main/java/hudson/maven/agent/Main.java +++ b/maven-agent/src/main/java/hudson/maven/agent/Main.java @@ -23,37 +23,26 @@ */ package hudson.maven.agent; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; +import org.codehaus.classworlds.ClassRealm; +import org.codehaus.classworlds.ClassWorld; +import org.codehaus.classworlds.ClassWorldAdapter; +import org.codehaus.classworlds.DefaultClassRealm; +import org.codehaus.classworlds.Launcher; +import org.codehaus.classworlds.NoSuchRealmException; + import java.io.File; -import java.io.FilenameFilter; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.MalformedURLException; import java.net.Socket; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Arrays; -import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.apache.maven.plugin.DefaultPluginManager; -import org.apache.tools.ant.AntClassLoader; -import org.codehaus.classworlds.ClassWorldAdapter; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.launcher.ConfigurationException; -import org.codehaus.plexus.classworlds.launcher.Launcher; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; -import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; - - /** * Entry point for launching Maven and Hudson remoting in the same VM, * in the classloader layout that Maven expects. @@ -112,42 +101,29 @@ public class Main { // I don't know how classworlds react to undefined variable, so (interceptorOverrideJar!=null?interceptorOverrideJar:interceptorJar).getPath()); - // FIXME change stuff for 206 earlier ! - boolean is206OrLater = !new File(m2Home,"core").exists(); - - + // load the default realms launcher = new Launcher(); - //launcher.setSystemClassLoader(Main.class.getClassLoader()); - - configureLauncher( m2Home, remotingJar, interceptorJar, interceptorOverrideJar, is206OrLater ); - - System.out.println( "realms size " + launcher.getWorld().getRealms().size() ); - for (Iterator iter = launcher.getWorld().getRealms().iterator();iter.hasNext();) - { - ClassRealm realm = (ClassRealm) iter.next(); - System.out.println( "realm " + realm + " urls " + Arrays.asList( realm.getURLs() ) ); - } - + launcher.setSystemClassLoader(Main.class.getClassLoader()); + launcher.configure(Main.class.getResourceAsStream( + is206OrLater?"classworlds-2.0.6.conf":"classworlds.conf")); + // have it eventually delegate to this class so that this can be visible + + ClassWorldAdapter classWorldAdapter = ClassWorldAdapter.getInstance( launcher.getWorld() ); + // create a realm for loading remoting subsystem. // this needs to be able to see maven. + ClassRealm remoting = new DefaultClassRealm(classWorldAdapter,"hudson-remoting", launcher.getSystemClassLoader()); - System.out.println( "Main classLoader " + Main.class.getClassLoader() ); - ClassRealm remoting = launcher.getWorld().newRealm( "hudson-remoting", launcher.getWorld().getClassRealm( "plexus.core" ) ); - remoting.importFrom( "plexus.core.maven", "org.apache.maven" ); - //remoting.setParentClassLoader( launcher.getWorld().getClassRealm( "plexus.core.maven" ) ); - remoting.addURL(remotingJar.toURI().toURL()); + remoting.setParent(classWorldAdapter.getRealm("plexus.core.maven")); + remoting.addConstituent(remotingJar.toURI().toURL()); final Socket s = new Socket((String)null,tcpPort); - Class remotingLauncher = remoting.loadClass("hudson.remoting.Launcher"); - - Method mainMethod = remotingLauncher.getMethod("main",new Class[]{InputStream.class,OutputStream.class}); - - mainMethod.invoke(null, + remotingLauncher.getMethod("main",new Class[]{InputStream.class,OutputStream.class}).invoke(null, new Object[]{ // do partial close, since socket.getInputStream and getOutputStream doesn't do it by new BufferedInputStream(new FilterInputStream(s.getInputStream()) { @@ -161,7 +137,6 @@ public class Main { } }) }); - System.out.println(" remoting classLoader " + remoting.toString() ); System.exit(0); } @@ -182,49 +157,18 @@ public class Main { } } } - - /** - * old one - * @throws ConfigurationException - * @throws IOException - * @throws NoSuchRealmException - * @throws DuplicateRealmException - */ - private static void configureLauncher(File m2Home, File remotingJar, File interceptorJar, File interceptorOverrideJar, boolean is206OrLater) - throws DuplicateRealmException, NoSuchRealmException, IOException, ConfigurationException { - - launcher.configure(Main.class.getResourceAsStream(is206OrLater?"classworlds-2.0.6.conf":"classworlds.conf")); - } /** * Called by the code in remoting to launch. - * @throws org.codehaus.classworlds.DuplicateRealmException - * @throws IllegalArgumentException + * @throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException */ - public static int launch(String[] args) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException, IllegalArgumentException { - - ClassWorld world = launcher.getWorld(); + public static int launch(String[] args) throws NoSuchMethodException, IllegalAccessException, NoSuchRealmException, InvocationTargetException, ClassNotFoundException, org.codehaus.plexus.classworlds.realm.NoSuchRealmException { + ClassWorld world = ClassWorldAdapter.getInstance( launcher.getWorld() ); Set builtinRealms = new HashSet(world.getRealms()); - URLClassLoader orig = (URLClassLoader) Thread.currentThread().getContextClassLoader(); - System.out.println("orig " + orig.toString()); - - try { - launcher.setAppMain( "org.apache.maven.cli.MavenCli", "plexus.core.maven" ); - ClassRealm newCl = launcher.getMainRealm(); - Thread.currentThread().setContextClassLoader( newCl ); - Method mainMethod = launcher.getMainClass().getMethod( "main", new Class[]{String[].class, org.codehaus.classworlds.ClassWorld.class} ); - //launcher.launch(args); - - mainMethod.invoke( null,new Object[]{args,ClassWorldAdapter.getInstance( launcher.getWorld() )} ); - //} catch (org.codehaus.classworlds.DuplicateRealmException e) { - // throw new RuntimeException( e.getMessage(), e); - } catch (NoSuchRealmException e) { - throw new RuntimeException( e.getMessage(), e); + launcher.launch(args); } finally { - Thread.currentThread().setContextClassLoader( orig ); // delete all realms created by Maven // this is because Maven creates a child realm for each plugin it loads, // and the realm id doesn't include the version. @@ -234,133 +178,9 @@ public class Main { all.removeAll(builtinRealms); for (Iterator itr = all.iterator(); itr.hasNext();) { ClassRealm cr = (ClassRealm) itr.next(); - try - { - world.disposeRealm(cr.getId()); - } - catch ( NoSuchRealmException e ) - { - throw new RuntimeException( e.getMessage(), e); - } + world.disposeRealm(cr.getId()); } } return launcher.getExitCode(); } - - - //--------------- - // olamy tests - // TODO remove - //--------------- - /** - * with various classLoader hierarchy stuff - * @throws MalformedURLException - * @throws DuplicateRealmException - */ - private static void configureLauncher2(File m2Home, File remotingJar, File interceptorJar, File interceptorOverrideJar, boolean is206OrLater) - throws MalformedURLException, DuplicateRealmException { - ClassWorld world = new ClassWorld(); - launcher.setWorld( world ); - ClassRealm plexusCore = world.newRealm( "plexus.core" ); - plexusCore.setParentClassLoader( Main.class.getClassLoader() ); - File mavenCore = new File(m2Home, is206OrLater ? "boot" : "core"); - - String[] coreJars = mavenCore.list( new FilenameFilter() - { - - public boolean accept( File dir, String name ) - { - return name.endsWith( ".jar" ); - } - }); - - for (int i = 0,size = coreJars.length;i${project.groupId} maven-agent ${project.version} + + + classworlds + classworlds + + diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java index 6383b3da18..7802d73fb9 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java @@ -57,6 +57,7 @@ import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReport; +import org.codehaus.classworlds.NoSuchRealmException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; @@ -203,6 +204,13 @@ public abstract class MavenBuilder extends AbstractMavenBuilder implements Deleg throw new IOException2(e); } catch (ClassNotFoundException e) { throw new IOException2(e); + } + catch ( NoSuchRealmException e ) { + throw new IOException2(e); + } + catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e ) + { + throw new IOException2(e); } finally { //PluginManagerInterceptor.setListener(null); //LifecycleExecutorInterceptor.setListener(null); -- GitLab From 2bee4769b7c598da901082badd734ed10f559220 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Dec 2010 00:42:29 +0100 Subject: [PATCH 0045/2361] fix maven2 builds. There are sill issues with maven2 builds and reporters --- maven-agent/pom.xml | 15 +++------ .../main/java/hudson/maven/agent/Main.java | 31 ++++++++++--------- .../hudson/maven/agent/classworlds-2.0.6.conf | 6 +--- .../hudson/maven/agent/classworlds.conf | 6 ++-- maven-interceptor/pom.xml | 16 ++++------ maven-plugin/pom.xml | 6 ++++ .../main/java/hudson/maven/MavenBuilder.java | 5 --- .../hudson/maven/MavenComputerListener.java | 8 +++-- .../hudson/maven/MavenProcessFactory.java | 11 +++---- war/pom.xml | 4 ++- 10 files changed, 50 insertions(+), 58 deletions(-) diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index 8c2484dc2c..2d8c9507a6 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -80,17 +80,19 @@ THE SOFTWARE. - + + org.apache.ant ant @@ -101,13 +103,6 @@ THE SOFTWARE. commons-httpclient 3.1-rc1 - diff --git a/maven-agent/src/main/java/hudson/maven/agent/Main.java b/maven-agent/src/main/java/hudson/maven/agent/Main.java index 045bf93d94..4f05ad04b6 100644 --- a/maven-agent/src/main/java/hudson/maven/agent/Main.java +++ b/maven-agent/src/main/java/hudson/maven/agent/Main.java @@ -23,26 +23,25 @@ */ package hudson.maven.agent; -import org.codehaus.classworlds.ClassRealm; -import org.codehaus.classworlds.ClassWorld; -import org.codehaus.classworlds.ClassWorldAdapter; -import org.codehaus.classworlds.DefaultClassRealm; -import org.codehaus.classworlds.Launcher; -import org.codehaus.classworlds.NoSuchRealmException; - +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.lang.reflect.InvocationTargetException; import java.net.Socket; import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.codehaus.classworlds.ClassRealm; +import org.codehaus.classworlds.ClassWorld; +import org.codehaus.classworlds.DefaultClassRealm; +import org.codehaus.classworlds.Launcher; +import org.codehaus.classworlds.NoSuchRealmException; + /** * Entry point for launching Maven and Hudson remoting in the same VM, * in the classloader layout that Maven expects. @@ -111,13 +110,15 @@ public class Main { // have it eventually delegate to this class so that this can be visible - ClassWorldAdapter classWorldAdapter = ClassWorldAdapter.getInstance( launcher.getWorld() ); + //ClassWorldAdapter classWorldAdapter = ClassWorldAdapter.getInstance( launcher.getWorld() ); // create a realm for loading remoting subsystem. // this needs to be able to see maven. - ClassRealm remoting = new DefaultClassRealm(classWorldAdapter,"hudson-remoting", launcher.getSystemClassLoader()); + //ClassRealm remoting = new DefaultClassRealm(classWorldAdapter,"hudson-remoting", launcher.getSystemClassLoader()); - remoting.setParent(classWorldAdapter.getRealm("plexus.core.maven")); + ClassRealm remoting = new DefaultClassRealm(launcher.getWorld(),"hudson-remoting", launcher.getSystemClassLoader()); + + remoting.setParent(launcher.getWorld().getRealm("plexus.core.maven")); remoting.addConstituent(remotingJar.toURI().toURL()); final Socket s = new Socket((String)null,tcpPort); @@ -162,9 +163,11 @@ public class Main { * Called by the code in remoting to launch. * @throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException */ - public static int launch(String[] args) throws NoSuchMethodException, IllegalAccessException, NoSuchRealmException, InvocationTargetException, ClassNotFoundException, org.codehaus.plexus.classworlds.realm.NoSuchRealmException { - ClassWorld world = ClassWorldAdapter.getInstance( launcher.getWorld() ); + public static int launch(String[] args) throws NoSuchMethodException, IllegalAccessException, NoSuchRealmException, InvocationTargetException, ClassNotFoundException { + //ClassWorld world = ClassWorldAdapter.getInstance( launcher.getWorld() ); + ClassWorld world = launcher.getWorld(); + Set builtinRealms = new HashSet(world.getRealms()); try { launcher.launch(args); diff --git a/maven-agent/src/main/resources/hudson/maven/agent/classworlds-2.0.6.conf b/maven-agent/src/main/resources/hudson/maven/agent/classworlds-2.0.6.conf index d9bb5d8c20..15d3ad352d 100644 --- a/maven-agent/src/main/resources/hudson/maven/agent/classworlds-2.0.6.conf +++ b/maven-agent/src/main/resources/hudson/maven/agent/classworlds-2.0.6.conf @@ -10,8 +10,4 @@ load ${maven.interceptor.override} load ${maven.interceptor} load ${maven.home}/lib/*.jar - -[plexus.core.maven] -load ${maven.interceptor.override} -load ${maven.interceptor} -load ${maven.home}/lib/*.jar +[plexus.core.maven] \ No newline at end of file diff --git a/maven-agent/src/main/resources/hudson/maven/agent/classworlds.conf b/maven-agent/src/main/resources/hudson/maven/agent/classworlds.conf index a34e3b604d..e80abecf8a 100644 --- a/maven-agent/src/main/resources/hudson/maven/agent/classworlds.conf +++ b/maven-agent/src/main/resources/hudson/maven/agent/classworlds.conf @@ -7,11 +7,9 @@ main is org.apache.maven.cli.MavenCli from plexus.core.maven set maven.home default ${user.home}/m2 [plexus.core] -load ${maven.interceptor.override} -load ${maven.interceptor} -load ${maven.home}/lib/*.jar +load ${maven.home}/core/*.jar [plexus.core.maven] load ${maven.interceptor.override} load ${maven.interceptor} -load ${maven.home}/lib/*.jar +load ${maven.home}/lib/*.jar \ No newline at end of file diff --git a/maven-interceptor/pom.xml b/maven-interceptor/pom.xml index 9de4e5c75a..63fa6f6c03 100644 --- a/maven-interceptor/pom.xml +++ b/maven-interceptor/pom.xml @@ -45,18 +45,14 @@ THE SOFTWARE. maven-core 2.0.9 provided - - - classworlds - classworlds - - - + - org.codehaus.plexus - plexus-classworlds - + classworlds + classworlds + 1.1 + + diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 7f20757a70..80166224e5 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -67,6 +67,12 @@ THE SOFTWARE. org.jvnet.hudson.main maven-interceptor ${project.version} + + + classworlds + classworlds + + diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java index 7802d73fb9..021b706e17 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java @@ -29,7 +29,6 @@ import hudson.maven.agent.Main; import hudson.maven.agent.PluginManagerListener; import hudson.maven.reporters.SurefireArchiver; import hudson.model.BuildListener; -import hudson.model.Hudson; import hudson.model.Result; import hudson.remoting.Callable; import hudson.remoting.Channel; @@ -207,10 +206,6 @@ public abstract class MavenBuilder extends AbstractMavenBuilder implements Deleg } catch ( NoSuchRealmException e ) { throw new IOException2(e); - } - catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e ) - { - throw new IOException2(e); } finally { //PluginManagerInterceptor.setListener(null); //LifecycleExecutorInterceptor.setListener(null); diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index c9f8fc8ca8..c0dd3876be 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -29,6 +29,7 @@ import hudson.maven.agent.AbortException; import hudson.maven.agent.Main; import hudson.maven.agent.Maven21Interceptor; import hudson.model.Computer; +import hudson.model.Hudson; import hudson.model.TaskListener; import hudson.remoting.Channel; import hudson.remoting.Which; @@ -38,7 +39,6 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; -import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Zip; import org.codehaus.plexus.classworlds.ClassWorld; @@ -61,7 +61,11 @@ public class MavenComputerListener extends ComputerListener { copyJar(logger, root, AbortException.class, "maven-interceptor"); copyJar(logger, root, Maven21Interceptor.class, "maven2.1-interceptor"); copyJar(logger, root, ClassWorld.class, "plexus-classworld"); - copyJar(logger, root, AntClassLoader.class, "maven-plugin-ant"); + + // copy classworlds 1.1 for maven2 builds + new FilePath( new File( Hudson.getInstance().getRootDir(), "/war/classworlds-1.1.jar" ) ) + .copyTo( root.child( "classworlds-1.1.jar" ) ); + } /** diff --git a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java index b2091a8152..37024940c3 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java @@ -288,17 +288,14 @@ final class MavenProcessFactory implements ProcessCache.Factory { args.addTokenized(getMavenOpts()); - args.add("-cp"); + args.add( "-cp" ); String classPath = ( isMaster ? Which.jarFile( Main.class ).getAbsolutePath() : slaveRoot.child( "maven-agent.jar" ).getRemote() ) + ( launcher.isUnix() ? ":" : ";" ) - + ( isMaster ? Which.jarFile( ClassWorld.class ).getAbsolutePath() - : slaveRoot.child( "plexus-classworld.jar" ).getRemote() ) - + ( launcher.isUnix() ? ":" : ";" ) - + ( isMaster ? Which.jarFile( AntClassLoader.class ).getAbsolutePath() - : slaveRoot.child( "maven-plugin-ant.jar" ).getRemote() ); - args.add(classPath); + + ( isMaster ? new File( Hudson.getInstance().getRootDir(), "/war/classworlds-1.1.jar" ).getAbsolutePath() + : slaveRoot.child( "classworlds-1.1.jar" ).getRemote() ); + args.add( classPath ); //+classWorldsJar); args.add(Main.class.getName()); diff --git a/war/pom.xml b/war/pom.xml index 72663f438b..1c73f627ef 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -120,7 +120,9 @@ THE SOFTWARE. - + + + -- GitLab From 70f69eeb14e334bee24add57fc70da30943fd16e Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Dec 2010 00:44:32 +0100 Subject: [PATCH 0046/2361] pom cleanup --- maven-agent/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index 2d8c9507a6..d378096e33 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -87,12 +87,6 @@ THE SOFTWARE. 1.1 - org.apache.ant ant -- GitLab From c5f1039c83dcadf194c3021a2a56b7208359623d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Dec 2010 12:22:52 +0100 Subject: [PATCH 0047/2361] fix artifactId name due to module rename --- maven3-agent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven3-agent/pom.xml b/maven3-agent/pom.xml index 52d3fac179..d58438db1f 100755 --- a/maven3-agent/pom.xml +++ b/maven3-agent/pom.xml @@ -12,7 +12,7 @@ org.jvnet.hudson.main - maven3-listener + maven3-interceptor provided ${project.version} -- GitLab From c9a3ab6d390f474b77ceb216edb19956139bddd0 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Dec 2010 15:31:34 +0100 Subject: [PATCH 0048/2361] fix MavenEmbedder creation with maven settings configuration to prevent issue during pom Parsing with an empty repo --- .../main/java/hudson/maven/MavenModuleSetBuild.java | 7 +++++-- .../src/main/java/hudson/maven/MavenUtil.java | 13 ++++++++++++- maven3-interceptor/pom.xml | 2 +- war/images/TangoProject-License.url | 2 -- 4 files changed, 18 insertions(+), 6 deletions(-) delete mode 100644 war/images/TangoProject-License.url diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 18f93f0a43..340cb4249d 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -1037,7 +1037,10 @@ public class MavenModuleSetBuild extends AbstractMavenBuild1.389-SNAPSHOT maven3-interceptor - Maven3 Interceptor + Hudson Maven3 Interceptor diff --git a/war/images/TangoProject-License.url b/war/images/TangoProject-License.url deleted file mode 100644 index 80c5fc2b84..0000000000 --- a/war/images/TangoProject-License.url +++ /dev/null @@ -1,2 +0,0 @@ -[InternetShortcut] -URL=http://creativecommons.org/licenses/by-sa/2.5/ -- GitLab From e6d0696606cc44836ad7160079b2c63d3ed85018 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Dec 2010 15:43:26 +0100 Subject: [PATCH 0049/2361] add a class MavenEmbedderRequest to ease new maven parameter addition --- .../hudson/maven/MavenEmbedderRequest.java | 123 ++++++++++++++++++ .../hudson/maven/MavenModuleSetBuild.java | 7 +- .../src/main/java/hudson/maven/MavenUtil.java | 35 ++--- .../DefaultMavenExecutionRequestBuilder.java | 1 - 4 files changed, 146 insertions(+), 20 deletions(-) create mode 100755 maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java diff --git a/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java b/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java new file mode 100755 index 0000000000..fce4e904c3 --- /dev/null +++ b/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java @@ -0,0 +1,123 @@ +/** + * + */ +package hudson.maven; + +/* + * 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 hudson.model.TaskListener; + +import java.io.File; +import java.util.Properties; + +/** + * @author Olivier Lamy + */ +public class MavenEmbedderRequest +{ + private TaskListener listener; + + private File mavenHome; + + private String profiles; + + private Properties systemProperties; + + private String privateRepository; + + private File alternateSettings; + + public MavenEmbedderRequest( TaskListener listener, File mavenHome, String profiles, Properties systemProperties, + String privateRepository, File alternateSettings ) + { + this.listener = listener; + this.mavenHome = mavenHome; + this.profiles = profiles; + this.systemProperties = systemProperties; + this.privateRepository = privateRepository; + this.alternateSettings = alternateSettings; + } + + public TaskListener getListener() + { + return listener; + } + + public MavenEmbedderRequest setListener( TaskListener listener ) + { + this.listener = listener; + return this; + } + + public File getMavenHome() + { + return mavenHome; + } + + public MavenEmbedderRequest setMavenHome( File mavenHome ) + { + this.mavenHome = mavenHome; + return this; + } + + public String getProfiles() + { + return profiles; + } + + public MavenEmbedderRequest setProfiles( String profiles ) + { + this.profiles = profiles; + return this; + } + + public Properties getSystemProperties() + { + return systemProperties; + } + + public MavenEmbedderRequest setSystemProperties( Properties systemProperties ) + { + this.systemProperties = systemProperties; + return this; + } + + public String getPrivateRepository() + { + return privateRepository; + } + + public MavenEmbedderRequest setPrivateRepository( String privateRepository ) + { + this.privateRepository = privateRepository; + return this; + } + + public File getAlternateSettings() + { + return alternateSettings; + } + + public MavenEmbedderRequest setAlternateSettings( File alternateSettings ) + { + this.alternateSettings = alternateSettings; + return this; + } +} diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 340cb4249d..9a705a2934 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -1039,16 +1039,17 @@ public class MavenModuleSetBuild extends AbstractMavenBuild relPath = new HashMap(); diff --git a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java index f2b9409082..77073713bb 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java @@ -107,12 +107,12 @@ public class MavenUtil { systemProperties = ((MavenModuleSet) project).getMavenProperties(); } - return createEmbedder(listener, + return createEmbedder(new MavenEmbedderRequest(listener, m!=null?m.getHomeDir():null, profiles, systemProperties, privateRepository, - settingsLoc); + settingsLoc )); } public static MavenEmbedder createEmbedder(TaskListener listener, File mavenHome, String profiles) throws MavenEmbedderException, IOException { @@ -123,9 +123,12 @@ public class MavenUtil { return createEmbedder(listener,mavenHome,profiles,systemProperties,null); } - public static MavenEmbedder createEmbedder(TaskListener listener, File mavenHome, String profiles, Properties systemProperties, - String privateRepository) throws MavenEmbedderException, IOException { - return createEmbedder(listener,mavenHome,profiles,systemProperties,privateRepository,null); + public static MavenEmbedder createEmbedder( TaskListener listener, File mavenHome, String profiles, + Properties systemProperties, String privateRepository ) + throws MavenEmbedderException, IOException + { + return createEmbedder( new MavenEmbedderRequest( listener, mavenHome, profiles, systemProperties, + privateRepository, null ) ); } /** @@ -145,8 +148,7 @@ public class MavenUtil { * @param alternateSettings * Optional alternate settings.xml file. */ - public static MavenEmbedder createEmbedder(TaskListener listener, File mavenHome, String profiles, Properties systemProperties, - String privateRepository, File alternateSettings) throws MavenEmbedderException, IOException { + public static MavenEmbedder createEmbedder(MavenEmbedderRequest mavenEmbedderRequest) throws MavenEmbedderException, IOException { MavenRequest mavenRequest = new MavenRequest(); @@ -158,18 +160,18 @@ public class MavenUtil { throw new AbortException("Failed to create "+m2Home+ "\nSee https://hudson.dev.java.net/cannot-create-.m2.html"); - if (privateRepository!=null) - mavenRequest.setLocalRepositoryPath( privateRepository ); + if (mavenEmbedderRequest.getPrivateRepository()!=null) + mavenRequest.setLocalRepositoryPath( mavenEmbedderRequest.getPrivateRepository() ); - if (profiles != null) + if (mavenEmbedderRequest.getProfiles() != null) { - mavenRequest.setProfiles(Arrays.asList( StringUtils.split( profiles, "," ) )); + mavenRequest.setProfiles(Arrays.asList( StringUtils.split( mavenEmbedderRequest.getProfiles(), "," ) )); } - if ( alternateSettings != null ) + if ( mavenEmbedderRequest.getAlternateSettings() != null ) { - mavenRequest.setUserSettingsFile( alternateSettings.getAbsolutePath() ); + mavenRequest.setUserSettingsFile( mavenEmbedderRequest.getAlternateSettings().getAbsolutePath() ); } else { @@ -178,15 +180,15 @@ public class MavenUtil { // FIXME configure those !! - mavenRequest.setGlobalSettingsFile( new File( mavenHome, "conf/settings.xml" ).getAbsolutePath() ); + mavenRequest.setGlobalSettingsFile( new File( mavenEmbedderRequest.getMavenHome(), "conf/settings.xml" ).getAbsolutePath() ); // TODO olamy check this sould be userProperties - mavenRequest.setSystemProperties(systemProperties); + mavenRequest.setSystemProperties(mavenEmbedderRequest.getSystemProperties()); EmbedderLoggerImpl logger = - new EmbedderLoggerImpl( listener, debugMavenEmbedder ? org.codehaus.plexus.logging.Logger.LEVEL_DEBUG + new EmbedderLoggerImpl( mavenEmbedderRequest.getListener(), debugMavenEmbedder ? org.codehaus.plexus.logging.Logger.LEVEL_DEBUG : org.codehaus.plexus.logging.Logger.LEVEL_INFO ); mavenRequest.setMavenLoggerManager( logger ); @@ -334,6 +336,7 @@ public class MavenUtil { }; } } + /** * If set to true, maximize the logging level of Maven embedder. diff --git a/maven3-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java b/maven3-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java index 84ac396200..e5aeb73960 100755 --- a/maven3-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java +++ b/maven3-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java @@ -64,7 +64,6 @@ import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity; /** * Most of code is coming from asf svn repo waiting before having available * @author Olivier Lamy - * @since */ @Component( role = MavenExecutionRequestBuilder.class) public class DefaultMavenExecutionRequestBuilder -- GitLab From c529aeb9bf7278aef31a2a41ef401f189e7724fd Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Dec 2010 16:19:16 +0100 Subject: [PATCH 0050/2361] add a transfertListener to display artifacts downloading during pom parsing --- .../hudson/maven/MavenEmbedderRequest.java | 15 +++++ .../hudson/maven/MavenModuleSetBuild.java | 62 +++++++++++++++++-- .../src/main/java/hudson/maven/MavenUtil.java | 7 ++- 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java b/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java index fce4e904c3..4bf2926493 100755 --- a/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java @@ -27,6 +27,8 @@ import hudson.model.TaskListener; import java.io.File; import java.util.Properties; +import org.sonatype.aether.transfer.TransferListener; + /** * @author Olivier Lamy */ @@ -43,6 +45,8 @@ public class MavenEmbedderRequest private String privateRepository; private File alternateSettings; + + private TransferListener transferListener; public MavenEmbedderRequest( TaskListener listener, File mavenHome, String profiles, Properties systemProperties, String privateRepository, File alternateSettings ) @@ -120,4 +124,15 @@ public class MavenEmbedderRequest this.alternateSettings = alternateSettings; return this; } + + public TransferListener getTransferListener() + { + return transferListener; + } + + public MavenEmbedderRequest setTransferListener( TransferListener transferListener ) + { + this.transferListener = transferListener; + return this; + } } diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 9a705a2934..c240cdd185 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -87,6 +87,9 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; +import org.sonatype.aether.transfer.TransferCancelledException; +import org.sonatype.aether.transfer.TransferEvent; +import org.sonatype.aether.transfer.TransferListener; /** * {@link Build} for {@link MavenModuleSet}. @@ -1046,10 +1049,11 @@ public class MavenModuleSetBuild extends AbstractMavenBuild relPath = new HashMap(); @@ -1095,4 +1099,54 @@ public class MavenModuleSetBuild extends AbstractMavenBuild Date: Mon, 13 Dec 2010 21:57:31 +0100 Subject: [PATCH 0051/2361] fix finally call which reset listeners in PluginManagerInterceptor and LifecycleExecutorInterceptor for maven 2 build --- .../main/java/hudson/maven/MavenBuilder.java | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java index 021b706e17..8d7ebe866a 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java @@ -127,15 +127,24 @@ public abstract class MavenBuilder extends AbstractMavenBuilder implements Deleg */ abstract void onReportGenerated(MavenProject project, MavenReportInfo report) throws IOException, InterruptedException, AbortException; + private Class pluginManagerInterceptorClazz; + + private Class lifecycleInterceptorClazz; + /** * This code is executed inside the maven jail process. */ public Result call() throws IOException { + + // hold a ref on correct classloader for finally call as something is changing tccl + // and not restore it ! + ClassLoader mavenJailProcessClassLoader = Thread.currentThread().getContextClassLoader(); + try { - System.out.println("MavenBuilder in call " + Thread.currentThread().getContextClassLoader()); + futures = new ArrayList>(); Adapter a = new Adapter(this); - callSetListenerWithReflectOnInterceptors( a ); + callSetListenerWithReflectOnInterceptors( a, mavenJailProcessClassLoader ); /* PluginManagerInterceptor.setListener(a); @@ -209,34 +218,39 @@ public abstract class MavenBuilder extends AbstractMavenBuilder implements Deleg } finally { //PluginManagerInterceptor.setListener(null); //LifecycleExecutorInterceptor.setListener(null); - callSetListenerWithReflectOnInterceptorsQuietly( null ); + callSetListenerWithReflectOnInterceptorsQuietly( null, mavenJailProcessClassLoader ); } } - private void callSetListenerWithReflectOnInterceptors( PluginManagerListener pluginManagerListener ) + private void callSetListenerWithReflectOnInterceptors( PluginManagerListener pluginManagerListener, ClassLoader cl ) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { - Class pluginManagerInterceptorClazz = Thread.currentThread().getContextClassLoader() - .loadClass( "hudson.maven.agent.PluginManagerInterceptor" ); - Method setListenerMethod = pluginManagerInterceptorClazz.getMethod( "setListener", new Class[] { Thread - .currentThread().getContextClassLoader().loadClass( "hudson.maven.agent.PluginManagerListener" ) } ); + if (pluginManagerInterceptorClazz == null) + { + pluginManagerInterceptorClazz = cl.loadClass( "hudson.maven.agent.PluginManagerInterceptor" ); + } + Method setListenerMethod = + pluginManagerInterceptorClazz.getMethod( "setListener", + new Class[] { cl.loadClass( "hudson.maven.agent.PluginManagerListener" ) } ); setListenerMethod.invoke( null, new Object[] { pluginManagerListener } ); - Class lifecycleInterceptorClazz = Thread.currentThread().getContextClassLoader() - .loadClass( "org.apache.maven.lifecycle.LifecycleExecutorInterceptor" ); - - setListenerMethod = lifecycleInterceptorClazz.getMethod( "setListener", new Class[] { Thread.currentThread() - .getContextClassLoader().loadClass( "org.apache.maven.lifecycle.LifecycleExecutorListener" ) } ); + if (lifecycleInterceptorClazz == null) + { + lifecycleInterceptorClazz = cl.loadClass( "org.apache.maven.lifecycle.LifecycleExecutorInterceptor" ); + } + setListenerMethod = + lifecycleInterceptorClazz.getMethod( "setListener", + new Class[] { cl.loadClass( "org.apache.maven.lifecycle.LifecycleExecutorListener" ) } ); setListenerMethod.invoke( null, new Object[] { pluginManagerListener } ); } - private void callSetListenerWithReflectOnInterceptorsQuietly( PluginManagerListener pluginManagerListener ) + private void callSetListenerWithReflectOnInterceptorsQuietly( PluginManagerListener pluginManagerListener, ClassLoader cl ) { try { - callSetListenerWithReflectOnInterceptors(pluginManagerListener); + callSetListenerWithReflectOnInterceptors(pluginManagerListener, cl); } catch ( SecurityException e ) { -- GitLab From 7f5c02979b3069a2ecff0aa0b747885b35f1fc7a Mon Sep 17 00:00:00 2001 From: rseguy Date: Mon, 13 Dec 2010 22:21:55 +0100 Subject: [PATCH 0052/2361] [FIXED HUDSON-8155] --- core/src/main/java/hudson/FilePath.java | 36 ++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index c64e61f858..606f1b3da9 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -2,7 +2,8 @@ * The MIT License * * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, - * Eric Lefevre-Ardant, Erik Ramfelt, Michael B. Donohue, Alan Harder + * Eric Lefevre-Ardant, Erik Ramfelt, Michael B. Donohue, Alan Harder, + * Manufacture Francaise des Pneumatiques Michelin, Romain Seguy * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -94,6 +95,8 @@ import java.util.zip.GZIPInputStream; import java.util.zip.ZipInputStream; import com.sun.jna.Native; +import java.util.logging.Logger; +import org.apache.tools.ant.taskdefs.Chmod; /** * {@link File} like object with remoting support. @@ -1078,8 +1081,19 @@ public final class FilePath implements Serializable { if(!isUnix() || mask==-1) return; act(new FileCallable() { public Void invoke(File f, VirtualChannel channel) throws IOException { - if(File.separatorChar=='/' && LIBC.chmod(f.getAbsolutePath(),mask)!=0) - throw new IOException("Failed to chmod "+f+" : "+LIBC.strerror(Native.getLastError())); + try { + if(File.separatorChar=='/' && LIBC.chmod(f.getAbsolutePath(),mask)!=0) { + throw new IOException("Failed to chmod "+f+" : "+LIBC.strerror(Native.getLastError())); + } + } catch(UnsatisfiedLinkError e) { // HUDSON-8155: use Ant's chmod task on non-GNU C systems + LOGGER.warning("GNU C Library not available: Using Ant's chmod task instead."); + Chmod chmodTask = new Chmod(); + chmodTask.setProject(new Project()); + chmodTask.setFile(f); + chmodTask.setPerm(Integer.toOctalString(mask)); + chmodTask.execute(); + } + return null; } }); @@ -1551,6 +1565,8 @@ public final class FilePath implements Serializable { * Reads from a tar stream and stores obtained files to the base dir. */ private static void readFromTar(String name, File baseDir, InputStream in) throws IOException { + Chmod chmodTask = null; // HUDSON-8155 + TarInputStream t = new TarInputStream(in); try { TarEntry te; @@ -1569,7 +1585,17 @@ public final class FilePath implements Serializable { try { LIBC.chmod(f.getPath(),mode); } catch (NoClassDefFoundError e) { - // be defensive. see http://www.nabble.com/-3.0.6--Site-copy-problem%3A-hudson.util.IOException2%3A--java.lang.NoClassDefFoundError%3A-Could-not-initialize-class--hudson.util.jna.GNUCLibrary-td23588879.html + // be defensive: see http://hudson.361315.n4.nabble.com/3-0-6-Site-copy-problem-hudson-util-IOException2-java-lang-NoClassDefFoundError-Could-not-initializey-td382337.html + } catch (UnsatisfiedLinkError ule) { + // HUDSON-8155: use Ant's chmod task on non-GNU C systems + if(chmodTask == null) { + LOGGER.warning("GNU C Library not available: Using Ant's chmod task instead."); + chmodTask = new Chmod(); + } + chmodTask.setProject(new Project()); + chmodTask.setFile(f); + chmodTask.setPerm(Integer.toOctalString(mode)); + chmodTask.execute(); } } } @@ -1877,6 +1903,8 @@ public final class FilePath implements Serializable { public static int SIDE_BUFFER_SIZE = 1024; + private static final Logger LOGGER = Logger.getLogger(FilePath.class.getName()); + /** * Adapts {@link FileCallable} to {@link Callable}. */ -- GitLab From 7415fa0478da5a17bafdfce83fca1648752b94db Mon Sep 17 00:00:00 2001 From: rseguy Date: Mon, 13 Dec 2010 22:36:15 +0100 Subject: [PATCH 0053/2361] [FIXED HUDSON-8155] --- changelog.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.html b/changelog.html index 7213bc4051..2fe6364a54 100644 --- a/changelog.html +++ b/changelog.html @@ -52,6 +52,9 @@ Upcoming changes Build names (e.g., "#123") can be now modified by users/plugins to arbitrary text. (issue 53, issue 4884) +
    • + Fixed an issue preventing to copy data on AIX, HP-UX or Linux for S/390. + (issue 8155)
    -- GitLab From 234a390860abfd22798dc4378e0d031a43b9cb07 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Dec 2010 22:45:59 +0100 Subject: [PATCH 0054/2361] fix ExecutedMojo use in a maven2 build --- .../main/java/hudson/maven/ExecutedMojo.java | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java b/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java index 4c306e7b23..be348e4f72 100644 --- a/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java +++ b/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java @@ -23,22 +23,24 @@ */ package hudson.maven; +import static hudson.Util.intern; import hudson.Util; import hudson.model.Hudson; import hudson.remoting.Which; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.kohsuke.stapler.Stapler; +import hudson.util.ReflectionUtils; import java.io.FileInputStream; import java.io.IOException; import java.io.Serializable; -import java.util.Map; +import java.lang.reflect.Method; import java.util.HashMap; -import java.util.logging.Logger; +import java.util.Map; import java.util.logging.Level; +import java.util.logging.Logger; -import static hudson.Util.intern; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.kohsuke.stapler.Stapler; /** * Persisted record of mojo execution. @@ -92,7 +94,7 @@ public final class ExecutedMojo implements Serializable { MojoDescriptor md = mojo.mojoExecution.getMojoDescriptor(); PluginDescriptor pd = md.getPluginDescriptor(); try { - Class clazz = pd.getClassRealm().loadClass(md.getImplementation()); + Class clazz = getMojoClass( md, pd );// pd.getClassRealm().loadClass(md.getImplementation()); digest = Util.getDigestOf(new FileInputStream(Which.jarFile(clazz))); } catch (IllegalArgumentException e) { LOGGER.log(Level.WARNING, "Failed to locate jar for "+md.getImplementation(),e); @@ -101,6 +103,32 @@ public final class ExecutedMojo implements Serializable { } this.digest = digest; } + + private Class getMojoClass(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException + { + try + { + return pd.getClassRealm().loadClass( md.getImplementation() ); + } catch (NoSuchMethodError e) + { + // maybe we are in maven2 build ClassRealm package has changed + return getMojoClassForMaven2( md, pd ); + } + } + + private Class getMojoClassForMaven2(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException + { + + Method method = ReflectionUtils.getPublicMethodNamed( pd.getClass(), "getClassRealm" ); + + org.codehaus.classworlds.ClassRealm cl = + (org.codehaus.classworlds.ClassRealm) ReflectionUtils.invokeMethod( method, pd ); + + Class clazz = cl.loadClass( md.getImplementation() ); + return clazz; + + } + /** * Copy constructor used for interning. -- GitLab From 3d5d53a55de8302ea1d8d9d1014757db91e718b1 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 13 Dec 2010 14:19:26 -0800 Subject: [PATCH 0055/2361] [HUDSON-8155] tweaking the code a bit further so that the warning will be issued only once per VM. --- core/src/main/java/hudson/FilePath.java | 56 ++++++++++++------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 606f1b3da9..2c02287069 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -1081,24 +1081,38 @@ public final class FilePath implements Serializable { if(!isUnix() || mask==-1) return; act(new FileCallable() { public Void invoke(File f, VirtualChannel channel) throws IOException { - try { - if(File.separatorChar=='/' && LIBC.chmod(f.getAbsolutePath(),mask)!=0) { - throw new IOException("Failed to chmod "+f+" : "+LIBC.strerror(Native.getLastError())); - } - } catch(UnsatisfiedLinkError e) { // HUDSON-8155: use Ant's chmod task on non-GNU C systems - LOGGER.warning("GNU C Library not available: Using Ant's chmod task instead."); - Chmod chmodTask = new Chmod(); - chmodTask.setProject(new Project()); - chmodTask.setFile(f); - chmodTask.setPerm(Integer.toOctalString(mask)); - chmodTask.execute(); - } + _chmod(f, mask); return null; } }); } + /** + * Run chmod via libc if we can, otherwise fall back to Ant. + */ + private static void _chmod(File f, int mask) throws IOException { + if (Functions.isWindows()) return; // noop + + try { + if(LIBC.chmod(f.getAbsolutePath(),mask)!=0) { + throw new IOException("Failed to chmod "+f+" : "+LIBC.strerror(Native.getLastError())); + } + } catch(UnsatisfiedLinkError e) { // HUDSON-8155: use Ant's chmod task on non-GNU C systems + if (!CHMOD_WARNED) {// only warn this once to avoid flooding the log + CHMOD_WARNED = true; + LOGGER.warning("GNU C Library not available: Using Ant's chmod task instead."); + } + Chmod chmodTask = new Chmod(); + chmodTask.setProject(new Project()); + chmodTask.setFile(f); + chmodTask.setPerm(Integer.toOctalString(mask)); + chmodTask.execute(); + } + } + + private static boolean CHMOD_WARNED = false; + /** * Gets the file permission bit mask. * @@ -1565,8 +1579,6 @@ public final class FilePath implements Serializable { * Reads from a tar stream and stores obtained files to the base dir. */ private static void readFromTar(String name, File baseDir, InputStream in) throws IOException { - Chmod chmodTask = null; // HUDSON-8155 - TarInputStream t = new TarInputStream(in); try { TarEntry te; @@ -1582,21 +1594,7 @@ public final class FilePath implements Serializable { f.setLastModified(te.getModTime().getTime()); int mode = te.getMode()&0777; if(mode!=0 && !Functions.isWindows()) // be defensive - try { - LIBC.chmod(f.getPath(),mode); - } catch (NoClassDefFoundError e) { - // be defensive: see http://hudson.361315.n4.nabble.com/3-0-6-Site-copy-problem-hudson-util-IOException2-java-lang-NoClassDefFoundError-Could-not-initializey-td382337.html - } catch (UnsatisfiedLinkError ule) { - // HUDSON-8155: use Ant's chmod task on non-GNU C systems - if(chmodTask == null) { - LOGGER.warning("GNU C Library not available: Using Ant's chmod task instead."); - chmodTask = new Chmod(); - } - chmodTask.setProject(new Project()); - chmodTask.setFile(f); - chmodTask.setPerm(Integer.toOctalString(mode)); - chmodTask.execute(); - } + _chmod(f,mode); } } } catch(IOException e) { -- GitLab From c59b6cec128910dce8082bbdbfb51b8dabcd0c87 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Dec 2010 23:27:15 +0100 Subject: [PATCH 0056/2361] fix MojoInfo use in a maven2 build --- .../src/main/java/hudson/maven/MojoInfo.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MojoInfo.java b/maven-plugin/src/main/java/hudson/maven/MojoInfo.java index 06e4ac41f5..9833db4453 100644 --- a/maven-plugin/src/main/java/hudson/maven/MojoInfo.java +++ b/maven-plugin/src/main/java/hudson/maven/MojoInfo.java @@ -25,6 +25,9 @@ package hudson.maven; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.Mojo; +import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.codehaus.classworlds.ClassRealm; +import org.codehaus.classworlds.ClassRealmAdapter; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; @@ -39,6 +42,7 @@ import java.lang.reflect.Proxy; import java.lang.reflect.Method; import hudson.util.InvocationInterceptor; +import hudson.util.ReflectionUtils; /** * Information about Mojo to be executed. This object provides @@ -127,12 +131,25 @@ public class MojoInfo { PlexusConfiguration child = configuration.getChild(configName); if(child==null) return null; // no such config + ClassLoader cl = null; + PluginDescriptor pd = mojoExecution.getMojoDescriptor().getPluginDescriptor(); + // for maven2 builds ClassRealm doesn't extends ClassLoader ! + // so check stuff with reflection + Method method = ReflectionUtils.getPublicMethodNamed( pd.getClass(), "getClassRealm" ); + + if ( ReflectionUtils.invokeMethod( method, pd ) instanceof ClassRealm) + { + ClassRealm cr = (ClassRealm) ReflectionUtils.invokeMethod( method, pd ); + cl = cr.getClassLoader(); + } else { + cl = mojoExecution.getMojoDescriptor().getPluginDescriptor().getClassRealm(); + } ConfigurationConverter converter = converterLookup.lookupConverterForType(type); return type.cast(converter.fromConfiguration(converterLookup,child,type, // the implementation seems to expect the type of the bean for which the configuration is done // in this parameter, but we have no such type. So passing in a dummy Object.class, - mojoExecution.getMojoDescriptor().getPluginDescriptor().getClassRealm(), + cl, expressionEvaluator)); } -- GitLab From afabfbe47fb7a5e8e9b6a8fcaf08bb5f20242e75 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 14 Dec 2010 00:07:45 +0100 Subject: [PATCH 0057/2361] fix MavenProcessFactory creation for maven2 build for master builds --- .../src/main/java/hudson/maven/MavenProcessFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java index 37024940c3..eb23d91a0e 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java @@ -312,7 +312,7 @@ final class MavenProcessFactory implements ProcessCache.Factory { // interceptor.jar args.add(isMaster? - Which.jarFile(PluginManagerInterceptor.class).getAbsolutePath(): + Which.jarFile(AbortException.class).getAbsolutePath(): slaveRoot.child("maven-interceptor.jar").getRemote()); // TCP/IP port to establish the remoting infrastructure -- GitLab From a2b6a606d7f4a94967405c415435a6060f5e53cf Mon Sep 17 00:00:00 2001 From: Tom Huybrechts Date: Tue, 14 Dec 2010 09:48:49 +0100 Subject: [PATCH 0058/2361] - add 'disable project' button on matrix and maven builds - remove it from sub-projects (maven modules and matrix configurations) --- .../hudson/matrix/MatrixProject/index.jelly | 31 ++++++++----- .../resources/hudson/model/Job/index.jelly | 44 ++++++++++--------- .../hudson/maven/MavenModuleSet/index.jelly | 15 ++++++- 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/core/src/main/resources/hudson/matrix/MatrixProject/index.jelly b/core/src/main/resources/hudson/matrix/MatrixProject/index.jelly index 55f0c76ca9..bb6b522255 100644 --- a/core/src/main/resources/hudson/matrix/MatrixProject/index.jelly +++ b/core/src/main/resources/hudson/matrix/MatrixProject/index.jelly @@ -30,16 +30,27 @@ THE SOFTWARE.

    ${%Project} ${it.name}

    - -
    -
    - ${%This project is currently disabled} - - - -
    -
    -
    + + +
    +
    + ${%This project is currently disabled} + + + +
    +
    +
    + +
    +
    + + + +
    +
    +
    +
    diff --git a/core/src/main/resources/hudson/model/Job/index.jelly b/core/src/main/resources/hudson/model/Job/index.jelly index 5c922ba4ec..a976d2eee2 100644 --- a/core/src/main/resources/hudson/model/Job/index.jelly +++ b/core/src/main/resources/hudson/model/Job/index.jelly @@ -29,27 +29,29 @@ THE SOFTWARE.

    ${it.pronoun} ${it.displayName}

    - - -
    -
    - ${%This project is currently disabled} - - - -
    -
    -
    - -
    -
    - - - -
    -
    -
    -
    + + + +
    +
    + ${%This project is currently disabled} + + + +
    +
    +
    + +
    +
    + + + +
    +
    +
    +
    +
    diff --git a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/index.jelly b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/index.jelly index c7b04562e2..0db3522ca3 100644 --- a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/index.jelly +++ b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/index.jelly @@ -30,7 +30,8 @@ THE SOFTWARE.

    ${it.pronoun} ${it.displayName}

    - + +
    ${%This project is currently disabled} @@ -39,7 +40,17 @@ THE SOFTWARE.
    -
    + + +
    +
    + + + +
    +
    +
    + -- GitLab From 070812b6b1332d1f8a2bdb1447cf400339f6d4a7 Mon Sep 17 00:00:00 2001 From: Tom Huybrechts Date: Tue, 14 Dec 2010 09:49:09 +0100 Subject: [PATCH 0059/2361] add .idea directory to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0dac988b55..60537ec592 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ work *.iml *.iws *.ipr +.idea # eclipse project file .settings -- GitLab From 834ca4d97b1cc760ad0e5b7e02956b441f992ff1 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 14 Dec 2010 01:27:12 -0800 Subject: [PATCH 0060/2361] modernized. shouldn't take HttpRequest/Response --- core/src/main/java/hudson/model/Queue.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index 3d821747c6..63b7a78a62 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -92,8 +92,8 @@ import javax.management.timer.Timer; import javax.servlet.ServletException; import org.acegisecurity.AccessDeniedException; -import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.HttpResponse; +import org.kohsuke.stapler.HttpResponses; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; @@ -1251,9 +1251,9 @@ public class Queue extends ResourceController implements Saveable { /** * Called from queue.jelly. */ - public void doCancelQueue( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { + public HttpResponse doCancelQueue() throws IOException, ServletException { Hudson.getInstance().getQueue().cancel(this); - rsp.forwardToPreviousPage(req); + return HttpResponses.forwardToPreviousPage(); } /** -- GitLab From 7e498c6a93bd0cc9bd2f99d17f0c918b7b3adb7d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 14 Dec 2010 16:18:01 +0100 Subject: [PATCH 0061/2361] add a FIXME --- .../src/main/java/hudson/maven/MavenComputerListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index c0dd3876be..92a728fc5c 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -63,6 +63,7 @@ public class MavenComputerListener extends ComputerListener { copyJar(logger, root, ClassWorld.class, "plexus-classworld"); // copy classworlds 1.1 for maven2 builds + // FIXME take care of people using --webroot= new FilePath( new File( Hudson.getInstance().getRootDir(), "/war/classworlds-1.1.jar" ) ) .copyTo( root.child( "classworlds-1.1.jar" ) ); -- GitLab From 93ed8223ff7e81d5d9ca3abc8d7df594069bf1a9 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 14 Dec 2010 19:13:16 +0100 Subject: [PATCH 0062/2361] NPE free --- .../hudson/maven3/listeners/HudsonMavenExecutionResult.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java index 69af0bd0eb..170e300ac5 100755 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java +++ b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java @@ -54,7 +54,11 @@ public class HudsonMavenExecutionResult implements Serializable MavenProjectInfo mavenProjectInfo = new MavenProjectInfo( mavenProject ); mavenProjectInfos.add( mavenProjectInfo ); BuildSummary buildSummary = mavenExecutionResult.getBuildSummary( mavenProject ); - mavenProjectInfo.setBuildTime( buildSummary.getTime() ); + // NPE free : weird this null ??? + if ( buildSummary != null ) + { + mavenProjectInfo.setBuildTime( buildSummary.getTime() ); + } } } } -- GitLab From e90e51b91c6599dbe4df13f826301b11a6d3febe Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 14 Dec 2010 19:17:21 +0100 Subject: [PATCH 0063/2361] add comment on why null check --- .../hudson/maven3/listeners/HudsonMavenExecutionResult.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java index 170e300ac5..d7caa9d109 100755 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java +++ b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java @@ -54,7 +54,7 @@ public class HudsonMavenExecutionResult implements Serializable MavenProjectInfo mavenProjectInfo = new MavenProjectInfo( mavenProject ); mavenProjectInfos.add( mavenProjectInfo ); BuildSummary buildSummary = mavenExecutionResult.getBuildSummary( mavenProject ); - // NPE free : weird this null ??? + // NPE free : looks to have null here when the projects is not finished ie tests failures if ( buildSummary != null ) { mavenProjectInfo.setBuildTime( buildSummary.getTime() ); -- GitLab From 33573ca2bdaf7dbe8db841e0d09663b2c4abb85e Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 14 Dec 2010 11:36:04 -0800 Subject: [PATCH 0064/2361] [FIXED HUDSON-3696] Contract violation. This shouldn't be null. --- changelog.html | 3 +++ core/src/main/java/hudson/slaves/SlaveComputer.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog.html b/changelog.html index 2fe6364a54..26bb4b6fc0 100644 --- a/changelog.html +++ b/changelog.html @@ -46,6 +46,9 @@ Upcoming changes
  • Fixed a pipe leak to child processes. (issue 8244) +
  • + Fixed an NPE in ComputerRetentionWork + (issue 3696)
  • Debian package init script now honors ~/.profile.
  • diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index f4072a9725..62a8fdcf98 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -445,7 +445,7 @@ public class SlaveComputer extends Computer { public RetentionStrategy getRetentionStrategy() { Slave n = getNode(); - return n==null ? null : n.getRetentionStrategy(); + return n==null ? RetentionStrategy.INSTANCE : n.getRetentionStrategy(); } /** -- GitLab From 5ae399ab970936ac0b98f3f28c4dfbd9bf81767e Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 14 Dec 2010 20:36:31 -0800 Subject: [PATCH 0065/2361] Load classworlds.jar from within the Maven plugin, not from the war. --- maven-plugin/pom.xml | 22 +++++++++++++++++++ .../hudson/maven/MavenComputerListener.java | 6 ++--- .../hudson/maven/MavenProcessFactory.java | 3 +-- war/pom.xml | 2 -- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 80166224e5..74144de545 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -250,6 +250,28 @@ THE SOFTWARE. + + org.jvnet.maven-antrun-extended-plugin + maven-antrun-extended-plugin + + + resgen + generate-resources + + run + + + false + + + + + + + + + + diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index 92a728fc5c..0e44c251a2 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -63,10 +63,8 @@ public class MavenComputerListener extends ComputerListener { copyJar(logger, root, ClassWorld.class, "plexus-classworld"); // copy classworlds 1.1 for maven2 builds - // FIXME take care of people using --webroot= - new FilePath( new File( Hudson.getInstance().getRootDir(), "/war/classworlds-1.1.jar" ) ) - .copyTo( root.child( "classworlds-1.1.jar" ) ); - + root.child( "classworlds-1.1.jar" ).copyFrom(getClass().getClassLoader().getResource("classworlds.jar")); + logger.println("Copied classworlds.jar"); } /** diff --git a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java index eb23d91a0e..47bff2fa02 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java @@ -293,8 +293,7 @@ final class MavenProcessFactory implements ProcessCache.Factory { ( isMaster ? Which.jarFile( Main.class ).getAbsolutePath() : slaveRoot.child( "maven-agent.jar" ).getRemote() ) + ( launcher.isUnix() ? ":" : ";" ) - + ( isMaster ? new File( Hudson.getInstance().getRootDir(), "/war/classworlds-1.1.jar" ).getAbsolutePath() - : slaveRoot.child( "classworlds-1.1.jar" ).getRemote() ); + + ( isMaster ? classWorldsJar : slaveRoot.child( "classworlds.jar" ).getRemote() ); args.add( classPath ); //+classWorldsJar); args.add(Main.class.getName()); diff --git a/war/pom.xml b/war/pom.xml index 1c73f627ef..aa9c78e827 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -120,8 +120,6 @@ THE SOFTWARE. - - -- GitLab From e5f16f86fc243b61de75c7714306a95a05280e65 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 14 Dec 2010 20:41:09 -0800 Subject: [PATCH 0066/2361] use the version of nekohtml consistent with the test harness. Otherwise test harness breaks, as we end up picking up two NekoHTMLs in the classpath. --- maven-plugin/pom.xml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 74144de545..4310b3fb6c 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -130,6 +130,16 @@ THE SOFTWARE. org.apache.maven.wagon wagon-http-lightweight + + + nekohtml + nekohtml + + + nekohtml + xercesMinimal + + org.apache.maven.wagon @@ -193,6 +203,17 @@ THE SOFTWARE. org.apache.maven.wagon wagon-webdav + + + + nekohtml + nekohtml + + + nekohtml + xercesMinimal + + @@ -208,6 +229,12 @@ THE SOFTWARE. + + + net.sourceforge.nekohtml + nekohtml + 1.9.13 + -- GitLab From 2008d76f1567cb84802c0f691f2db8b19e4dac66 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 14 Dec 2010 20:49:56 -0800 Subject: [PATCH 0067/2361] this wasn't locating interceptor.jar; it was locating the hudson-core instead. --- .../src/main/java/hudson/maven/MavenProcessFactory.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java index 47bff2fa02..2fa5d4e33a 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenProcessFactory.java @@ -32,7 +32,6 @@ import hudson.slaves.Channels; import static hudson.Util.fixNull; import hudson.maven.agent.Main; import hudson.maven.agent.Maven21Interceptor; -import hudson.maven.agent.PluginManagerInterceptor; import hudson.maven.ProcessCache.NewProcess; import hudson.model.BuildListener; import hudson.model.Computer; @@ -70,11 +69,6 @@ import java.nio.charset.UnsupportedCharsetException; import java.util.Arrays; import java.util.logging.Logger; -import javax.inject.Inject; - -import org.apache.tools.ant.AntClassLoader; -import org.codehaus.plexus.classworlds.ClassWorld; - /** * Launches the maven process. @@ -311,7 +305,7 @@ final class MavenProcessFactory implements ProcessCache.Factory { // interceptor.jar args.add(isMaster? - Which.jarFile(AbortException.class).getAbsolutePath(): + Which.jarFile(hudson.maven.agent.AbortException.class).getAbsolutePath(): slaveRoot.child("maven-interceptor.jar").getRemote()); // TCP/IP port to establish the remoting infrastructure -- GitLab From 9cade34eea6afc31e5688a00dd4d3dede8fa15bf Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 14 Dec 2010 21:06:30 -0800 Subject: [PATCH 0068/2361] wrong file name --- .../src/main/java/hudson/maven/MavenComputerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java index 0e44c251a2..607789d7e7 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenComputerListener.java @@ -63,7 +63,7 @@ public class MavenComputerListener extends ComputerListener { copyJar(logger, root, ClassWorld.class, "plexus-classworld"); // copy classworlds 1.1 for maven2 builds - root.child( "classworlds-1.1.jar" ).copyFrom(getClass().getClassLoader().getResource("classworlds.jar")); + root.child( "classworlds.jar" ).copyFrom(getClass().getClassLoader().getResource("classworlds.jar")); logger.println("Copied classworlds.jar"); } -- GitLab From bb96fc7fc8d1e1e34bc68413ff52683417ba74f9 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 14 Dec 2010 21:18:25 -0800 Subject: [PATCH 0069/2361] we need an empty list set to avoid NPE. --- maven-plugin/src/main/java/hudson/maven/MavenUtil.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java index d8c4b51201..5b6df649dc 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java @@ -237,11 +237,11 @@ public class MavenUtil { File basedir = project.getFile().getParentFile(); relativePathInfo.put( project, rel ); + List modules = new ArrayList(); + if ( !nonRecursive ) { - List modules = new ArrayList(); - - for ( String modulePath : (List) project.getModules() ) + for ( String modulePath : project.getModules()) { if ( Util.fixEmptyAndTrim( modulePath ) != null ) { @@ -264,9 +264,9 @@ public class MavenUtil { modules.add( child ); } } - - project.setCollectedProjects( modules ); } + + project.setCollectedProjects( modules ); } /** -- GitLab From 680690d72e6208eb86b137c5f8696778da2804a0 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 14 Dec 2010 21:19:51 -0800 Subject: [PATCH 0070/2361] doc fix --- .../hudson/maven/MavenEmbedderRequest.java | 291 +++++++++--------- .../src/main/java/hudson/maven/MavenUtil.java | 13 - 2 files changed, 153 insertions(+), 151 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java b/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java index 4bf2926493..831ced3a59 100755 --- a/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenEmbedderRequest.java @@ -1,138 +1,153 @@ -/** - * - */ -package hudson.maven; - -/* - * 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 hudson.model.TaskListener; - -import java.io.File; -import java.util.Properties; - -import org.sonatype.aether.transfer.TransferListener; - -/** - * @author Olivier Lamy - */ -public class MavenEmbedderRequest -{ - private TaskListener listener; - - private File mavenHome; - - private String profiles; - - private Properties systemProperties; - - private String privateRepository; - - private File alternateSettings; - - private TransferListener transferListener; - - public MavenEmbedderRequest( TaskListener listener, File mavenHome, String profiles, Properties systemProperties, - String privateRepository, File alternateSettings ) - { - this.listener = listener; - this.mavenHome = mavenHome; - this.profiles = profiles; - this.systemProperties = systemProperties; - this.privateRepository = privateRepository; - this.alternateSettings = alternateSettings; - } - - public TaskListener getListener() - { - return listener; - } - - public MavenEmbedderRequest setListener( TaskListener listener ) - { - this.listener = listener; - return this; - } - - public File getMavenHome() - { - return mavenHome; - } - - public MavenEmbedderRequest setMavenHome( File mavenHome ) - { - this.mavenHome = mavenHome; - return this; - } - - public String getProfiles() - { - return profiles; - } - - public MavenEmbedderRequest setProfiles( String profiles ) - { - this.profiles = profiles; - return this; - } - - public Properties getSystemProperties() - { - return systemProperties; - } - - public MavenEmbedderRequest setSystemProperties( Properties systemProperties ) - { - this.systemProperties = systemProperties; - return this; - } - - public String getPrivateRepository() - { - return privateRepository; - } - - public MavenEmbedderRequest setPrivateRepository( String privateRepository ) - { - this.privateRepository = privateRepository; - return this; - } - - public File getAlternateSettings() - { - return alternateSettings; - } - - public MavenEmbedderRequest setAlternateSettings( File alternateSettings ) - { - this.alternateSettings = alternateSettings; - return this; - } - - public TransferListener getTransferListener() - { - return transferListener; - } - - public MavenEmbedderRequest setTransferListener( TransferListener transferListener ) - { - this.transferListener = transferListener; - return this; - } -} +/** + * + */ +package hudson.maven; + +/* + * 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 hudson.model.TaskListener; + +import java.io.File; +import java.util.Properties; + +import org.sonatype.aether.transfer.TransferListener; + +/** + * @author Olivier Lamy + */ +public class MavenEmbedderRequest +{ + private TaskListener listener; + + private File mavenHome; + + private String profiles; + + private Properties systemProperties; + + private String privateRepository; + + private File alternateSettings; + + private TransferListener transferListener; + + /** + * @param listener + * This is where the log messages from Maven will be recorded. + * @param mavenHome + * Directory of the Maven installation. We read {@code conf/settings.xml} + * from here. Can be null. + * @param profiles + * Profiles to activate/deactivate. Can be null. + * @param systemProperties + * The system properties that the embedded Maven sees. See {@link MavenEmbedder#setSystemProperties(Properties)}. + * @param privateRepository + * Optional private repository to use as the local repository. + * @param alternateSettings + * Optional alternate settings.xml file. + */ + public MavenEmbedderRequest( TaskListener listener, File mavenHome, String profiles, Properties systemProperties, + String privateRepository, File alternateSettings ) + { + this.listener = listener; + this.mavenHome = mavenHome; + this.profiles = profiles; + this.systemProperties = systemProperties; + this.privateRepository = privateRepository; + this.alternateSettings = alternateSettings; + } + + public TaskListener getListener() + { + return listener; + } + + public MavenEmbedderRequest setListener( TaskListener listener ) + { + this.listener = listener; + return this; + } + + public File getMavenHome() + { + return mavenHome; + } + + public MavenEmbedderRequest setMavenHome( File mavenHome ) + { + this.mavenHome = mavenHome; + return this; + } + + public String getProfiles() + { + return profiles; + } + + public MavenEmbedderRequest setProfiles( String profiles ) + { + this.profiles = profiles; + return this; + } + + public Properties getSystemProperties() + { + return systemProperties; + } + + public MavenEmbedderRequest setSystemProperties( Properties systemProperties ) + { + this.systemProperties = systemProperties; + return this; + } + + public String getPrivateRepository() + { + return privateRepository; + } + + public MavenEmbedderRequest setPrivateRepository( String privateRepository ) + { + this.privateRepository = privateRepository; + return this; + } + + public File getAlternateSettings() + { + return alternateSettings; + } + + public MavenEmbedderRequest setAlternateSettings( File alternateSettings ) + { + this.alternateSettings = alternateSettings; + return this; + } + + public TransferListener getTransferListener() + { + return transferListener; + } + + public MavenEmbedderRequest setTransferListener( TransferListener transferListener ) + { + this.transferListener = transferListener; + return this; + } +} diff --git a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java index 5b6df649dc..cc6d844b62 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java @@ -134,19 +134,6 @@ public class MavenUtil { /** * Creates a fresh {@link MavenEmbedder} instance. * - * @param listener - * This is where the log messages from Maven will be recorded. - * @param mavenHome - * Directory of the Maven installation. We read {@code conf/settings.xml} - * from here. Can be null. - * @param profiles - * Profiles to activate/deactivate. Can be null. - * @param systemProperties - * The system properties that the embedded Maven sees. See {@link MavenEmbedder#setSystemProperties(Properties)}. - * @param privateRepository - * Optional private repository to use as the local repository. - * @param alternateSettings - * Optional alternate settings.xml file. */ public static MavenEmbedder createEmbedder(MavenEmbedderRequest mavenEmbedderRequest) throws MavenEmbedderException, IOException { -- GitLab From ba251529946f619ac7f22dd83dbc539f1ff29afc Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 14 Dec 2010 22:12:03 -0800 Subject: [PATCH 0071/2361] redundant cast --- .../src/main/java/hudson/maven/MavenModuleSetBuild.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index c240cdd185..881b3a4384 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -1081,7 +1081,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild relPath, List infos) { PomInfo pi = new PomInfo(mp, parent, relPath.get(mp)); infos.add(pi); - for (MavenProject child : (List)mp.getCollectedProjects()) + for (MavenProject child : mp.getCollectedProjects()) toPomInfo(child,pi,relPath,infos); } -- GitLab From 7dd4171c04f94730b78aff2b557a0ceeaeb5bca8 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 00:04:28 -0800 Subject: [PATCH 0072/2361] pushed up the pronoun to AbstractItem. --- core/src/main/java/hudson/model/AbstractItem.java | 8 ++++++++ core/src/main/java/hudson/model/Job.java | 5 +---- .../main/resources/hudson/model/AbstractItem/delete.jelly | 2 +- .../resources/hudson/model/AbstractItem/delete.properties | 1 + .../hudson/model/AbstractItem/delete_da.properties | 2 +- .../hudson/model/AbstractItem/delete_nl.properties | 2 +- core/src/main/resources/hudson/model/Messages.properties | 1 + 7 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 core/src/main/resources/hudson/model/AbstractItem/delete.properties diff --git a/core/src/main/java/hudson/model/AbstractItem.java b/core/src/main/java/hudson/model/AbstractItem.java index 8877e40c45..c9f2bad44f 100644 --- a/core/src/main/java/hudson/model/AbstractItem.java +++ b/core/src/main/java/hudson/model/AbstractItem.java @@ -88,6 +88,14 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet return name; } + /** + * Get the term used in the UI to represent this kind of + * {@link Item}. Must start with a capital letter. + */ + public String getPronoun() { + return Messages.AbstractItem_Pronoun(); + } + @Exported public String getDisplayName() { return getName(); diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index a4548b2bbc..969fe8d090 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -248,10 +248,7 @@ public abstract class Job, RunT extends Run
    - ${%Are you sure about deleting the job?} + ${%blurb(it.pronoun)}
    diff --git a/core/src/main/resources/hudson/model/AbstractItem/delete.properties b/core/src/main/resources/hudson/model/AbstractItem/delete.properties new file mode 100644 index 0000000000..bd06c9b1b6 --- /dev/null +++ b/core/src/main/resources/hudson/model/AbstractItem/delete.properties @@ -0,0 +1 @@ +blurb=Are you sure about deleting the {0}? \ No newline at end of file diff --git a/core/src/main/resources/hudson/model/AbstractItem/delete_da.properties b/core/src/main/resources/hudson/model/AbstractItem/delete_da.properties index 67850704da..c99bd2f5c4 100644 --- a/core/src/main/resources/hudson/model/AbstractItem/delete_da.properties +++ b/core/src/main/resources/hudson/model/AbstractItem/delete_da.properties @@ -21,4 +21,4 @@ # THE SOFTWARE. Yes=Ja -Are\ you\ sure\ about\ deleting\ the\ job?=Er du sikker p\u00e5 at du vil slette dette job? +blurb=Er du sikker p\u00e5 at du vil slette dette {0}? diff --git a/core/src/main/resources/hudson/model/AbstractItem/delete_nl.properties b/core/src/main/resources/hudson/model/AbstractItem/delete_nl.properties index f1ed43d7c2..6041c399cb 100644 --- a/core/src/main/resources/hudson/model/AbstractItem/delete_nl.properties +++ b/core/src/main/resources/hudson/model/AbstractItem/delete_nl.properties @@ -20,5 +20,5 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -Are\ you\ sure\ about\ deleting\ the\ job?=Bent u zeker? U staat op het punt deze job te verwijderen! +blurb=Bent u zeker? U staat op het punt deze {0} te verwijderen! Yes=Ja diff --git a/core/src/main/resources/hudson/model/Messages.properties b/core/src/main/resources/hudson/model/Messages.properties index 970c833070..5291611773 100644 --- a/core/src/main/resources/hudson/model/Messages.properties +++ b/core/src/main/resources/hudson/model/Messages.properties @@ -26,6 +26,7 @@ AbstractBuild.BuildingOnMaster=Building on master AbstractBuild.KeptBecause=kept because of {0} AbstractItem.NoSuchJobExists=No such job ''{0}'' exists. Perhaps you meant ''{1}''? +AbstractItem.Pronoun=Job AbstractProject.NewBuildForWorkspace=Scheduling a new build to get a workspace. AbstractProject.AwaitingBuildForWorkspace=Awaiting build to get a workspace. AbstractProject.Pronoun=Project -- GitLab From f7670ca33a700313ca893f89b966ed6118305737 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Dec 2010 13:03:32 +0100 Subject: [PATCH 0073/2361] cleanup System.out.println --- .../java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java index 1213d5ed33..256a0c5436 100755 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java +++ b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java @@ -86,9 +86,6 @@ public class Maven3Launcher MavenExecutionRequest request = getMavenExecutionRequest( args, container ); hudsonMavenExecutionResult = new HudsonMavenExecutionResult( maven.execute( request ) ); - System.out.println("---- mavenExecutionResult ----"); - System.out.println( "mavenExecutionResult.getMavenProjectInfos().size() " + hudsonMavenExecutionResult.getMavenProjectInfos().size() ); - System.out.println("---- mavenExecutionResult ----"); // we don't care about cli mavenExecutionResult will be study in the the plugin return 0;// cli.doMain( args, null ); -- GitLab From 0a4f1f3eba832b4e98a93f29cedba0b2da5bffd3 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Dec 2010 13:04:18 +0100 Subject: [PATCH 0074/2361] remove unused imports --- .../java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java | 1 - .../jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java | 1 - 2 files changed, 2 deletions(-) diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java index 256a0c5436..d111b79e5f 100755 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java +++ b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java @@ -30,7 +30,6 @@ import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.jvnet.hudson.maven3.listeners.HudsonMavenBuildHelper; import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult; diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java index 4ce9571f56..eda384389f 100755 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java +++ b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java @@ -21,7 +21,6 @@ package org.jvnet.hudson.maven3.listeners; */ import java.io.Serializable; -import java.util.List; import org.apache.maven.project.ProjectBuildingResult; -- GitLab From fa228156ca8fe18af1bd5b5c58aa0280ec5a4796 Mon Sep 17 00:00:00 2001 From: Seiji Sogabe Date: Wed, 15 Dec 2010 21:07:11 +0900 Subject: [PATCH 0075/2361] Updated l10n(ja). --- .../hudson/matrix/MatrixProject/index_ja.properties | 1 + .../resources/hudson/model/AbstractItem/delete_ja.properties | 5 ++--- core/src/main/resources/hudson/model/Messages_ja.properties | 1 + .../hudson/maven/MavenModuleSet/index_ja.properties | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/resources/hudson/matrix/MatrixProject/index_ja.properties b/core/src/main/resources/hudson/matrix/MatrixProject/index_ja.properties index d94e1f88b3..f4ce6e4a33 100644 --- a/core/src/main/resources/hudson/matrix/MatrixProject/index_ja.properties +++ b/core/src/main/resources/hudson/matrix/MatrixProject/index_ja.properties @@ -23,3 +23,4 @@ Project=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8 This\ project\ is\ currently\ disabled=\u73fe\u5728\u3001\u3053\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306f\u7121\u52b9\u3067\u3059\u3002 Enable=\u6709\u52b9\u5316 +Disable\ Project=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u7121\u52b9\u5316 diff --git a/core/src/main/resources/hudson/model/AbstractItem/delete_ja.properties b/core/src/main/resources/hudson/model/AbstractItem/delete_ja.properties index 1368421698..d69525bd38 100644 --- a/core/src/main/resources/hudson/model/AbstractItem/delete_ja.properties +++ b/core/src/main/resources/hudson/model/AbstractItem/delete_ja.properties @@ -1,6 +1,6 @@ # The MIT License # -# Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, id:cactusman +# Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, id:cactusman, Seiji Sogabe # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,6 +20,5 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -Are\ you\ sure\ about\ deleting\ the\ job?=\u30b8\u30e7\u30d6\u3092\u524a\u9664\u3057\u307e\u3059\u304b\uff1f - +blurb={0} \u3092\u524a\u9664\u3057\u307e\u3059\u304b? Yes=\u306f\u3044 \ No newline at end of file diff --git a/core/src/main/resources/hudson/model/Messages_ja.properties b/core/src/main/resources/hudson/model/Messages_ja.properties index ec1b766b56..77b25a1d1c 100644 --- a/core/src/main/resources/hudson/model/Messages_ja.properties +++ b/core/src/main/resources/hudson/model/Messages_ja.properties @@ -25,6 +25,7 @@ AbstractBuild.BuildingOnMaster=\u30de\u30b9\u30bf\u30fc\u3067\u30d3\u30eb\u30c9\ AbstractBuild.KeptBecause=kept because of {0} AbstractItem.NoSuchJobExists=\u30b8\u30e7\u30d6''{0}''\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002''{1}''\u3067\u3059\u304b? +AbstractItem.Pronoun=\u30b8\u30e7\u30d6 AbstractProject.NewBuildForWorkspace=\u65b0\u898f\u306e\u30d3\u30eb\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001\u30ef\u30fc\u30af\u30b9\u30da\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002 AbstractProject.Pronoun=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8 AbstractProject.Aborted=\u4e2d\u6b62 diff --git a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/index_ja.properties b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/index_ja.properties index d7ae88442e..43605f79be 100644 --- a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/index_ja.properties +++ b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/index_ja.properties @@ -26,4 +26,5 @@ Latest\ Test\ Result=\u6700\u65b0\u306e\u30c6\u30b9\u30c8\u7d50\u679c Last\ Successful\ Artifacts=\u6700\u65b0\u6210\u529f\u30d3\u30eb\u30c9\u306e\u6210\u679c\u7269 This\ project\ is\ currently\ disabled=\u73fe\u5728\u3001\u3053\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306f\u7121\u52b9\u3067\u3059\u3002 Enable=\u6709\u52b9\u5316 +Disable\ Project=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u7121\u52b9\u5316 -- GitLab From 24cc881495bb5c3fd25ca2067f8e4afd760c2e76 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Dec 2010 13:12:37 +0100 Subject: [PATCH 0076/2361] remove unused class --- .../maven3/launcher/Maven3Launcher.java | 2 - .../listeners/HudsonMavenBuildHelper.java | 65 ------------------- 2 files changed, 67 deletions(-) delete mode 100644 maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java index d111b79e5f..4fe5db37ab 100755 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java +++ b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java @@ -31,7 +31,6 @@ import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.jvnet.hudson.maven3.listeners.HudsonMavenBuildHelper; import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult; /** @@ -102,7 +101,6 @@ public class Maven3Launcher private static MavenExecutionRequest getMavenExecutionRequest( String[] args, DefaultPlexusContainer container ) throws Exception { - HudsonMavenBuildHelper hudsonMavenBuildHelper = container.lookup( HudsonMavenBuildHelper.class ); MavenExecutionRequestBuilder mavenExecutionRequestBuilder = container .lookup( MavenExecutionRequestBuilder.class ); MavenExecutionRequest request = mavenExecutionRequestBuilder.getMavenExecutionRequest( args, System.out ); diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java deleted file mode 100644 index 3d4d77636f..0000000000 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenBuildHelper.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.jvnet.hudson.maven3.listeners; - -/* - * Olivier Lamy - * 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 javax.inject.Inject; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; - -/** - * simple helper to get various stuff from maven builds - * @author Olivier Lamy - */ -@Component(role=HudsonMavenBuildHelper.class) -public class HudsonMavenBuildHelper implements Initializable -{ - - // must be available in a static way weird - // and not really good design ! - //private static MavenPluginManager mavenPluginManager; - - @Inject - private PlexusContainer plexusContainer; - - public void initialize() - throws InitializationException - { - /* - try - { - mavenPluginManager = plexusContainer.lookup( MavenPluginManager.class ); - } - catch ( ComponentLookupException e ) - { - throw new InitializationException(e.getMessage(), e); - } - */ - } - - /*public static MavenPluginManager getMavenPluginManager() - { - return mavenPluginManager; - }*/ - -} -- GitLab From 5c584fe10fa396df4f1cf56725379fe22cda5448 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Dec 2010 14:54:28 +0100 Subject: [PATCH 0077/2361] use System.out only debug is activated --- .../src/main/java/hudson/maven/MavenModuleSetBuild.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 881b3a4384..2f53fbacb1 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -815,7 +815,9 @@ public class MavenModuleSetBuild extends AbstractMavenBuild Date: Wed, 15 Dec 2010 15:02:30 +0100 Subject: [PATCH 0078/2361] print statement only if debug is activated --- maven-plugin/src/main/java/hudson/maven/MavenUtil.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java index cc6d844b62..fe90da51cb 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java @@ -175,8 +175,10 @@ public class MavenUtil { if (mavenEmbedderRequest.getTransferListener() != null) { + if (debugMavenEmbedder) { mavenEmbedderRequest.getListener().getLogger() .println( "use transfertListener " + mavenEmbedderRequest.getTransferListener().getClass().getName() ); + } mavenRequest.setTransferListener( mavenEmbedderRequest.getTransferListener() ); } EmbedderLoggerImpl logger = -- GitLab From d6f5126193527441c4c893d358c237076a232d25 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Dec 2010 15:26:53 +0100 Subject: [PATCH 0079/2361] start fixing code style --- .../main/java/hudson/maven/ExecutedMojo.java | 28 ++++++++----------- .../main/java/hudson/maven/Maven3Builder.java | 4 +-- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java b/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java index be348e4f72..145b59bd1d 100644 --- a/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java +++ b/maven-plugin/src/main/java/hudson/maven/ExecutedMojo.java @@ -104,28 +104,24 @@ public final class ExecutedMojo implements Serializable { this.digest = digest; } - private Class getMojoClass(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException - { - try - { + private Class getMojoClass(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException { + try { return pd.getClassRealm().loadClass( md.getImplementation() ); - } catch (NoSuchMethodError e) - { + } catch (NoSuchMethodError e) { // maybe we are in maven2 build ClassRealm package has changed return getMojoClassForMaven2( md, pd ); } } - private Class getMojoClassForMaven2(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException - { - - Method method = ReflectionUtils.getPublicMethodNamed( pd.getClass(), "getClassRealm" ); - - org.codehaus.classworlds.ClassRealm cl = - (org.codehaus.classworlds.ClassRealm) ReflectionUtils.invokeMethod( method, pd ); - - Class clazz = cl.loadClass( md.getImplementation() ); - return clazz; + private Class getMojoClassForMaven2(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException { + + Method method = ReflectionUtils.getPublicMethodNamed( pd.getClass(), "getClassRealm" ); + + org.codehaus.classworlds.ClassRealm cl = + (org.codehaus.classworlds.ClassRealm) ReflectionUtils.invokeMethod( method, pd ); + + Class clazz = cl.loadClass( md.getImplementation() ); + return clazz; } diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index 6bc6fe10e9..2c9077c755 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -96,9 +96,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal this.reporters.putAll( reporters ); } - public Result call() - throws IOException - { + public Result call() throws IOException { MavenExecutionListener mavenExecutionListener = new MavenExecutionListener( this ); try { -- GitLab From a9a84ca8d53bf40543c5d670cee4368359f15c0e Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Dec 2010 15:30:34 +0100 Subject: [PATCH 0080/2361] start fixing code style --- .../maven3/launcher/Maven3Launcher.java | 37 +++++------------ .../listeners/MavenProjectBuildResult.java | 18 +++------ .../maven3/listeners/MavenProjectInfo.java | 40 ++++++------------- 3 files changed, 29 insertions(+), 66 deletions(-) diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java index 4fe5db37ab..9b6b484d1b 100755 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java +++ b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java @@ -37,39 +37,31 @@ import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult; * @author olamy * */ -public class Maven3Launcher -{ +public class Maven3Launcher { private static HudsonMavenExecutionResult hudsonMavenExecutionResult; private static ExecutionListener mavenExecutionListener; - public static ExecutionListener getMavenExecutionListener() - { + public static ExecutionListener getMavenExecutionListener() { return mavenExecutionListener; } - public static void setMavenExecutionListener( ExecutionListener listener ) - { + public static void setMavenExecutionListener( ExecutionListener listener ) { mavenExecutionListener = listener; } - public static HudsonMavenExecutionResult getMavenExecutionResult() - { + public static HudsonMavenExecutionResult getMavenExecutionResult() { return hudsonMavenExecutionResult; } - public static void setMavenExecutionResult( HudsonMavenExecutionResult result ) - { + public static void setMavenExecutionResult( HudsonMavenExecutionResult result ) { hudsonMavenExecutionResult = result; } - public static int main( String[] args ) - throws Exception - { + public static int main( String[] args ) throws Exception { ClassLoader orig = Thread.currentThread().getContextClassLoader(); - try - { + try { ClassRealm containerRealm = (ClassRealm) Thread.currentThread().getContextClassLoader(); @@ -87,25 +79,18 @@ public class Maven3Launcher // we don't care about cli mavenExecutionResult will be study in the the plugin return 0;// cli.doMain( args, null ); - } - catch ( ComponentLookupException e ) - { + } catch ( ComponentLookupException e ) { throw new Exception( e.getMessage(), e ); - } - finally - { + } finally { Thread.currentThread().setContextClassLoader( orig ); } } - private static MavenExecutionRequest getMavenExecutionRequest( String[] args, DefaultPlexusContainer container ) - throws Exception - { + private static MavenExecutionRequest getMavenExecutionRequest( String[] args, DefaultPlexusContainer container ) throws Exception { MavenExecutionRequestBuilder mavenExecutionRequestBuilder = container .lookup( MavenExecutionRequestBuilder.class ); MavenExecutionRequest request = mavenExecutionRequestBuilder.getMavenExecutionRequest( args, System.out ); - if ( mavenExecutionListener != null ) - { + if ( mavenExecutionListener != null ) { request.setExecutionListener( mavenExecutionListener ); } return request; diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java index eda384389f..f677182446 100755 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java +++ b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java @@ -32,33 +32,25 @@ public class MavenProjectBuildResult implements Serializable { private MavenProjectInfo mavenProjectInfo; - public MavenProjectBuildResult() - { + public MavenProjectBuildResult() { // no op } - public MavenProjectBuildResult( ProjectBuildingResult projectBuildingResult ) - { + public MavenProjectBuildResult( ProjectBuildingResult projectBuildingResult ) { // no op this.mavenProjectInfo = new MavenProjectInfo( projectBuildingResult.getProject() ); } - public MavenProjectInfo getMavenProjectInfo() - { + public MavenProjectInfo getMavenProjectInfo() { return mavenProjectInfo; } - public void setMavenProjectInfo( MavenProjectInfo mavenProjectInfo ) - { + public void setMavenProjectInfo( MavenProjectInfo mavenProjectInfo ) { this.mavenProjectInfo = mavenProjectInfo; } @Override - public String toString() - { + public String toString() { return mavenProjectInfo == null ? "null mavenProjectInfo" : this.mavenProjectInfo.toString(); } - - - } diff --git a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java index 2d26f8cf1a..7e444ef979 100755 --- a/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java +++ b/maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java @@ -41,74 +41,60 @@ public class MavenProjectInfo implements Serializable private long buildTime; - public MavenProjectInfo() - { + public MavenProjectInfo() { // no-op } - public MavenProjectInfo(MavenProject mavenProject) - { + public MavenProjectInfo(MavenProject mavenProject) { this.displayName = mavenProject.getName(); this.groupId= mavenProject.getGroupId(); this.artifactId = mavenProject.getArtifactId(); this.version = mavenProject.getVersion(); } - public long getBuildTime() - { + public long getBuildTime() { return buildTime; } - public void setBuildTime( long buildTime ) - { + public void setBuildTime( long buildTime ) { this.buildTime = buildTime; } - public String getDisplayName() - { + public String getDisplayName() { return displayName; } - public void setDisplayName( String displayName ) - { + public void setDisplayName( String displayName ) { this.displayName = displayName; } - public String getGroupId() - { + public String getGroupId() { return groupId; } - public void setGroupId( String groupId ) - { + public void setGroupId( String groupId ) { this.groupId = groupId; } - public String getArtifactId() - { + public String getArtifactId() { return artifactId; } - public void setArtifactId( String artifactId ) - { + public void setArtifactId( String artifactId ) { this.artifactId = artifactId; } - public String getVersion() - { + public String getVersion() { return version; } - public void setVersion( String version ) - { + public void setVersion( String version ) { this.version = version; } @Override - public String toString() - { + public String toString() { return groupId + ":" + artifactId + ":" + version; } - } -- GitLab From 0a6181e95430e198b06b01345827c55a4680da82 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Dec 2010 15:36:58 +0100 Subject: [PATCH 0081/2361] start fixing code style --- .../main/java/hudson/maven/Maven3Builder.java | 224 +++++------------- .../src/main/java/hudson/maven/MavenUtil.java | 25 +- 2 files changed, 73 insertions(+), 176 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index 2c9077c755..e2ba169fee 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -258,16 +258,11 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal executedMojosPerModule.put( e.getKey(), new CopyOnWriteArrayList() ); } this.reporters.putAll( new HashMap>(maven3Builder.reporters) ); - - } - private MavenBuildProxy2 getMavenBuildProxy2(MavenProject mavenProject) - { - for (Entry entry : proxies.entrySet()) - { - if (entry.getKey().compareTo( new ModuleName( mavenProject ) ) == 0) - { + private MavenBuildProxy2 getMavenBuildProxy2(MavenProject mavenProject) { + for (Entry entry : proxies.entrySet()) { + if (entry.getKey().compareTo( new ModuleName( mavenProject ) ) == 0) { return entry.getValue(); } } @@ -277,44 +272,25 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal // FIME really used somewhere ??? // FIXME MojoInfo need the real mojo ?? // so tricky to do. need to use MavenPluginManager on the current Maven Build - private Mojo getMojo(MojoExecution mojoExecution, MavenSession mavenSession) - { + private Mojo getMojo(MojoExecution mojoExecution, MavenSession mavenSession) { return null; - /* - try - { - return HudsonMavenBuildHelper.getMavenPluginManager().getConfiguredMojo( Mojo.class, mavenSession, - mojoExecution ); - } - catch ( PluginContainerException e ) - { - throw new RuntimeException( e.getMessage(), e ); - } - catch ( PluginConfigurationException e ) - { - throw new RuntimeException( e.getMessage(), e ); - }*/ } - private ExpressionEvaluator getExpressionEvaluator(MavenSession session, MojoExecution mojoExecution) - { + private ExpressionEvaluator getExpressionEvaluator(MavenSession session, MojoExecution mojoExecution) { return new PluginParameterExpressionEvaluator( session, mojoExecution ); } - private List getMavenReporters(MavenProject mavenProject) - { + private List getMavenReporters(MavenProject mavenProject) { return reporters.get( new ModuleName( mavenProject ) ); } - private void initMojoStartTime( MavenProject mavenProject) - { + private void initMojoStartTime( MavenProject mavenProject) { this.currentMojoStartPerModuleName.put( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ), Long.valueOf( new Date().getTime() ) ); } - private Long getMojoStartTime(MavenProject mavenProject) - { + private Long getMojoStartTime(MavenProject mavenProject) { return currentMojoStartPerModuleName.get( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ) ); } @@ -322,30 +298,28 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#projectDiscoveryStarted(org.apache.maven.execution.ExecutionEvent) */ - public void projectDiscoveryStarted( ExecutionEvent event ) - { + public void projectDiscoveryStarted( ExecutionEvent event ) { + // no op } /** * @see org.apache.maven.execution.ExecutionListener#sessionStarted(org.apache.maven.execution.ExecutionEvent) */ - public void sessionStarted( ExecutionEvent event ) - { + public void sessionStarted( ExecutionEvent event ) { + // no op } /** * @see org.apache.maven.execution.ExecutionListener#sessionEnded(org.apache.maven.execution.ExecutionEvent) */ - public void sessionEnded( ExecutionEvent event ) - { + public void sessionEnded( ExecutionEvent event ) { maven3Builder.listener.getLogger().println( "sessionEnded in MavenExecutionListener " ); } /** * @see org.apache.maven.execution.ExecutionListener#projectSkipped(org.apache.maven.execution.ExecutionEvent) */ - public void projectSkipped( ExecutionEvent event ) - { + public void projectSkipped( ExecutionEvent event ) { MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( event.getProject() ); maven3Builder.listener.getLogger().println("projectSkipped" ); mavenBuildProxy2.end(); @@ -355,8 +329,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#projectStarted(org.apache.maven.execution.ExecutionEvent) */ - public void projectStarted( ExecutionEvent event ) - { + public void projectStarted( ExecutionEvent event ) { maven3Builder.listener.getLogger().println( "projectStarted in MavenExecutionListener " + event.getProject().getGroupId() + ":" + event.getProject().getArtifactId() ); @@ -367,39 +340,25 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal mavenBuildProxy2.start(); - if (mavenReporters != null) - { - for (MavenReporter mavenReporter : mavenReporters) - { - try - { + if (mavenReporters != null) { + for (MavenReporter mavenReporter : mavenReporters) { + try { mavenReporter.enterModule( mavenBuildProxy2 ,mavenProject, maven3Builder.listener); - } - catch ( InterruptedException e ) - { + } catch ( InterruptedException e ) { e.printStackTrace(); - } - catch ( IOException e ) - { + } catch ( IOException e ) { e.printStackTrace(); } } } - if (mavenReporters != null) - { - for (MavenReporter mavenReporter : mavenReporters) - { - try - { + if (mavenReporters != null) { + for (MavenReporter mavenReporter : mavenReporters) { + try { mavenReporter.preBuild( mavenBuildProxy2 ,mavenProject, maven3Builder.listener); - } - catch ( InterruptedException e ) - { + } catch ( InterruptedException e ) { e.printStackTrace(); - } - catch ( IOException e ) - { + } catch ( IOException e ) { e.printStackTrace(); } } @@ -410,8 +369,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#projectSucceeded(org.apache.maven.execution.ExecutionEvent) */ - public void projectSucceeded( ExecutionEvent event ) - { + public void projectSucceeded( ExecutionEvent event ) { maven3Builder.listener.getLogger().println( "projectSucceeded in MavenExecutionListener " + event.getProject().getGroupId() + ":" + event.getProject().getArtifactId() ); @@ -422,39 +380,25 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal mavenBuildProxy2.end(); mavenBuildProxy2.setResult( Result.SUCCESS ); - if ( mavenReporters != null ) - { - for ( MavenReporter mavenReporter : mavenReporters ) - { - try - { + if ( mavenReporters != null ) { + for ( MavenReporter mavenReporter : mavenReporters ) { + try { mavenReporter.leaveModule( mavenBuildProxy2, mavenProject, maven3Builder.listener); - } - catch ( InterruptedException e ) - { + } catch ( InterruptedException e ) { e.printStackTrace(); - } - catch ( IOException e ) - { + } catch ( IOException e ) { e.printStackTrace(); } } } - if ( mavenReporters != null ) - { - for ( MavenReporter mavenReporter : mavenReporters ) - { - try - { + if ( mavenReporters != null ) { + for ( MavenReporter mavenReporter : mavenReporters ) { + try { mavenReporter.postBuild( mavenBuildProxy2, mavenProject, maven3Builder.listener); - } - catch ( InterruptedException e ) - { + } catch ( InterruptedException e ) { e.printStackTrace(); - } - catch ( IOException e ) - { + } catch ( IOException e ) { e.printStackTrace(); } } @@ -465,8 +409,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#projectFailed(org.apache.maven.execution.ExecutionEvent) */ - public void projectFailed( ExecutionEvent event ) - { + public void projectFailed( ExecutionEvent event ) { maven3Builder.listener.getLogger().println("projectFailed" ); MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( event.getProject() ); mavenBuildProxy2.end(); @@ -476,16 +419,14 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#mojoSkipped(org.apache.maven.execution.ExecutionEvent) */ - public void mojoSkipped( ExecutionEvent event ) - { + public void mojoSkipped( ExecutionEvent event ) { // TODO ? } /** * @see org.apache.maven.execution.ExecutionListener#mojoStarted(org.apache.maven.execution.ExecutionEvent) */ - public void mojoStarted( ExecutionEvent event ) - { + public void mojoStarted( ExecutionEvent event ) { initMojoStartTime( event.getProject() ); maven3Builder.listener.getLogger().println("mojoStarted " + event.getMojoExecution().getArtifactId()); @@ -502,20 +443,13 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( mavenProject ); - if (mavenReporters != null) - { - for (MavenReporter mavenReporter : mavenReporters) - { - try - { + if (mavenReporters != null) { + for (MavenReporter mavenReporter : mavenReporters) { + try { mavenReporter.preExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener); - } - catch ( InterruptedException e ) - { + } catch ( InterruptedException e ) { e.printStackTrace(); - } - catch ( IOException e ) - { + } catch ( IOException e ) { e.printStackTrace(); } } @@ -525,8 +459,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#mojoSucceeded(org.apache.maven.execution.ExecutionEvent) */ - public void mojoSucceeded( ExecutionEvent event ) - { + public void mojoSucceeded( ExecutionEvent event ) { Long startTime = getMojoStartTime( event.getProject() ); Date endTime = new Date(); maven3Builder.listener.getLogger().println("mojoSucceeded " + event.getMojoExecution().getArtifactId()); @@ -539,16 +472,13 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration, getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) ); - try - { + try { ExecutedMojo executedMojo = new ExecutedMojo( mojoInfo, startTime == null ? 0 : endTime.getTime() - startTime.longValue() ); this.executedMojosPerModule.get( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ) ).add( executedMojo ); - } - catch ( Exception e ) - { + } catch ( Exception e ) { // ignoring this maven3Builder.listener.getLogger().println( "ignoring exception during new ExecutedMojo " + e.getMessage() ); @@ -560,20 +490,14 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal mavenBuildProxy2.setExecutedMojos( this.executedMojosPerModule.get( new ModuleName( event.getProject() ) ) ); - if (mavenReporters != null) - { - for (MavenReporter mavenReporter : mavenReporters) - { - try - { + if (mavenReporters != null) { + for (MavenReporter mavenReporter : mavenReporters) { + try { mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, null); - } - catch ( InterruptedException e ) - { + } catch ( InterruptedException e ) { e.printStackTrace(); } - catch ( IOException e ) - { + catch ( IOException e ) { e.printStackTrace(); } } @@ -583,8 +507,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#mojoFailed(org.apache.maven.execution.ExecutionEvent) */ - public void mojoFailed( ExecutionEvent event ) - { + public void mojoFailed( ExecutionEvent event ) { maven3Builder.listener.getLogger().println("mojoFailed " + event.getMojoExecution().getArtifactId()); Long startTime = getMojoStartTime( event.getProject() ); Date endTime = new Date(); @@ -597,16 +520,12 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration, getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) ); - try - { + try { ExecutedMojo executedMojo = new ExecutedMojo( mojoInfo, startTime == null ? 0 : endTime.getTime() - startTime.longValue() ); this.executedMojosPerModule.get( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ) ).add( executedMojo ); - - } - catch ( Exception e ) - { + } catch ( Exception e ) { // ignoring this maven3Builder.listener.getLogger().println( "ignoring exception during new ExecutedMojo " + e.getMessage() ); @@ -618,21 +537,14 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal mavenBuildProxy2.setExecutedMojos( this.executedMojosPerModule.get( new ModuleName( event.getProject() ) ) ); - if (mavenReporters != null) - { - for (MavenReporter mavenReporter : mavenReporters) - { - try - { + if (mavenReporters != null) { + for (MavenReporter mavenReporter : mavenReporters) { + try { // FIXME get exception during mojo execution ? mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, null ); - } - catch ( InterruptedException e ) - { + } catch ( InterruptedException e ) { e.printStackTrace(); - } - catch ( IOException e ) - { + } catch ( IOException e ) { e.printStackTrace(); } } @@ -650,41 +562,35 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal /** * @see org.apache.maven.execution.ExecutionListener#forkSucceeded(org.apache.maven.execution.ExecutionEvent) */ - public void forkSucceeded( ExecutionEvent event ) - { + public void forkSucceeded( ExecutionEvent event ) { // TODO ! } /** * @see org.apache.maven.execution.ExecutionListener#forkFailed(org.apache.maven.execution.ExecutionEvent) */ - public void forkFailed( ExecutionEvent event ) - { + public void forkFailed( ExecutionEvent event ) { // TODO ! - } /** * @see org.apache.maven.execution.ExecutionListener#forkedProjectStarted(org.apache.maven.execution.ExecutionEvent) */ - public void forkedProjectStarted( ExecutionEvent event ) - { + public void forkedProjectStarted( ExecutionEvent event ) { // TODO ! } /** * @see org.apache.maven.execution.ExecutionListener#forkedProjectSucceeded(org.apache.maven.execution.ExecutionEvent) */ - public void forkedProjectSucceeded( ExecutionEvent event ) - { + public void forkedProjectSucceeded( ExecutionEvent event ) { // TODO ! } /** * @see org.apache.maven.execution.ExecutionListener#forkedProjectFailed(org.apache.maven.execution.ExecutionEvent) */ - public void forkedProjectFailed( ExecutionEvent event ) - { + public void forkedProjectFailed( ExecutionEvent event ) { // TODO ! } diff --git a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java index fe90da51cb..240f29303d 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java @@ -150,18 +150,14 @@ public class MavenUtil { if (mavenEmbedderRequest.getPrivateRepository()!=null) mavenRequest.setLocalRepositoryPath( mavenEmbedderRequest.getPrivateRepository() ); - if (mavenEmbedderRequest.getProfiles() != null) - { + if (mavenEmbedderRequest.getProfiles() != null) { mavenRequest.setProfiles(Arrays.asList( StringUtils.split( mavenEmbedderRequest.getProfiles(), "," ) )); } - if ( mavenEmbedderRequest.getAlternateSettings() != null ) - { + if ( mavenEmbedderRequest.getAlternateSettings() != null ) { mavenRequest.setUserSettingsFile( mavenEmbedderRequest.getAlternateSettings().getAbsolutePath() ); - } - else - { + } else { mavenRequest.setUserSettingsFile( new File( m2Home, "settings.xml" ).getAbsolutePath() ); } @@ -173,8 +169,7 @@ public class MavenUtil { // TODO olamy check this sould be userProperties mavenRequest.setSystemProperties(mavenEmbedderRequest.getSystemProperties()); - if (mavenEmbedderRequest.getTransferListener() != null) - { + if (mavenEmbedderRequest.getTransferListener() != null) { if (debugMavenEmbedder) { mavenEmbedderRequest.getListener().getLogger() .println( "use transfertListener " + mavenEmbedderRequest.getTransferListener().getClass().getName() ); @@ -228,15 +223,11 @@ public class MavenUtil { List modules = new ArrayList(); - if ( !nonRecursive ) - { - for ( String modulePath : project.getModules()) - { - if ( Util.fixEmptyAndTrim( modulePath ) != null ) - { + if ( !nonRecursive ) { + for ( String modulePath : project.getModules()) { + if ( Util.fixEmptyAndTrim( modulePath ) != null ) { File moduleFile = new File( basedir, modulePath ); - if ( moduleFile.exists() && moduleFile.isDirectory() ) - { + if ( moduleFile.exists() && moduleFile.isDirectory() ) { moduleFile = new File( basedir, modulePath + "/pom.xml" ); } if ( !moduleFile.exists() ) -- GitLab From 0ca0ad7b2c5a7ec83a56a0001f09b18d92a6c196 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Dec 2010 16:50:58 +0100 Subject: [PATCH 0082/2361] add TODO for improvment with maven 3.0.2 --- maven-plugin/src/main/java/hudson/maven/Maven3Builder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index e2ba169fee..910a1a3d73 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -540,7 +540,9 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal if (mavenReporters != null) { for (MavenReporter mavenReporter : mavenReporters) { try { - // FIXME get exception during mojo execution ? + // TODO get exception during mojo execution ? + // with maven 3.0.2 see http://jira.codehaus.org/browse/MNG-4922 + // catch NoSuchMethodError if folks not using 3.0.2+ mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, null ); } catch ( InterruptedException e ) { e.printStackTrace(); -- GitLab From 5a317d628f2223a967b3b8539c4fb663408fa7f9 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 12:46:33 -0800 Subject: [PATCH 0083/2361] handle non-Job Items gracefully --- .../resources/lib/hudson/ballColorTd.jelly | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/core/src/main/resources/lib/hudson/ballColorTd.jelly b/core/src/main/resources/lib/hudson/ballColorTd.jelly index 9236542e87..03e9c3d590 100644 --- a/core/src/main/resources/lib/hudson/ballColorTd.jelly +++ b/core/src/main/resources/lib/hudson/ballColorTd.jelly @@ -1,7 +1,7 @@ - - + + Display the ball in a TD. + + Color of the ball or null to skip drawing. + + - ${it.description} + + ${it.description} + \ No newline at end of file -- GitLab From f2d8d3dd8ca75d242be8dc3872ff03fb405d1b94 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 12:47:19 -0800 Subject: [PATCH 0084/2361] doc improvement --- core/src/main/resources/lib/hudson/ballColorTd.jelly | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/resources/lib/hudson/ballColorTd.jelly b/core/src/main/resources/lib/hudson/ballColorTd.jelly index 03e9c3d590..be8a7808ac 100644 --- a/core/src/main/resources/lib/hudson/ballColorTd.jelly +++ b/core/src/main/resources/lib/hudson/ballColorTd.jelly @@ -27,6 +27,9 @@ THE SOFTWARE. Color of the ball or null to skip drawing. + + Additional CSS styles to apply. + -- GitLab From 0bcf2f74494658f4fa1cc5dd6f2a52b7cdaf5e35 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 12:49:14 -0800 Subject: [PATCH 0085/2361] handle non-Job Items gracefully --- core/src/main/resources/lib/hudson/buildHealth.jelly | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/resources/lib/hudson/buildHealth.jelly b/core/src/main/resources/lib/hudson/buildHealth.jelly index 13672a59a0..933af05d51 100644 --- a/core/src/main/resources/lib/hudson/buildHealth.jelly +++ b/core/src/main/resources/lib/hudson/buildHealth.jelly @@ -37,10 +37,12 @@ THE SOFTWARE. this.className='healthReport hover';return true; this.className='healthReport';return true; - - ${buildHealth.score}% - + + + ${buildHealth.score}% + +
    -- GitLab From 889d582f26fe224a37c62d4f9fb19b2d3c4bc456 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Dec 2010 22:32:28 +0100 Subject: [PATCH 0086/2361] maven 3 doesn't mark the full build has failed if there is surefire failing tests --- .../main/java/hudson/maven/Maven3Builder.java | 22 +++++-------------- .../maven/reporters/SurefireArchiver.java | 5 +++++ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index 910a1a3d73..27e0b786f9 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -155,32 +155,22 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal mavenExecutionResult = Maven3Launcher.getMavenExecutionResult(); - - //FIXME handle - //mavenExecutionResult.getThrowables() PrintStream logger = listener.getLogger(); - logger.println("Maven3Builder classLoaderDebug"); - logger.println("getClass().getClassLoader(): " + getClass().getClassLoader()); - if(r==0 && mavenExecutionResult.getThrowables().isEmpty()) { - logger.print( "r==0" ); - markAsSuccess = true; - } + if(r==0 && mavenExecutionResult.getThrowables().isEmpty()) return Result.SUCCESS; + if (!mavenExecutionResult.getThrowables().isEmpty()) { - logger.println( "mavenExecutionResult.throwables not empty"); + logger.println( "mavenExecutionResult exceptions not empty"); for(Throwable throwable : mavenExecutionResult.getThrowables()) { throwable.printStackTrace( logger ); } - markAsSuccess = false; + } if(markAsSuccess) { - // FIXME message - //listener.getLogger().println(Messages.MavenBuilder_Failed()); - listener.getLogger().println("success"); + listener.getLogger().println(Messages.MavenBuilder_Failed()); return Result.SUCCESS; } - return Result.FAILURE; } catch (NoSuchMethodException e) { throw new IOException2(e); @@ -410,7 +400,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal * @see org.apache.maven.execution.ExecutionListener#projectFailed(org.apache.maven.execution.ExecutionEvent) */ public void projectFailed( ExecutionEvent event ) { - maven3Builder.listener.getLogger().println("projectFailed" ); + maven3Builder.listener.getLogger().println("projectFailed " + event.getProject().getGroupId() + ":" + event.getProject().getArtifactId()); MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( event.getProject() ); mavenBuildProxy2.end(); mavenBuildProxy2.setResult( Result.FAILURE ); diff --git a/maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java b/maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java index dc1aaa7bdb..9f2076d865 100644 --- a/maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java +++ b/maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java @@ -25,6 +25,7 @@ package hudson.maven.reporters; import hudson.Util; import hudson.Extension; +import hudson.maven.Maven3Builder; import hudson.maven.MavenBuild; import hudson.maven.MavenBuildProxy; import hudson.maven.MavenBuildProxy.BuildCallable; @@ -126,6 +127,10 @@ public class SurefireArchiver extends MavenReporter { if(failCount>0 && error instanceof MojoFailureException) { MavenBuilder.markAsSuccess = true; } + // TODO currenlty error is empty : will be here with maven 3.0.2+ + if(failCount>0) { + Maven3Builder.markAsSuccess = true; + } } return true; -- GitLab From 558a20b4d79a97507556b9683bdb0fe86bb056ac Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 16 Dec 2010 00:34:18 +0100 Subject: [PATCH 0087/2361] use last wagon version. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28b75aeb14..3f4d21e869 100644 --- a/pom.xml +++ b/pom.xml @@ -342,7 +342,7 @@ THE SOFTWARE. 3.0.1 ${mavenVersion} 1.8 - 1.0-beta-6 + 1.0-beta-7 UTF-8 -- GitLab From ee59683bf4b77c6dc783dc4c8ea599b8da73fcd0 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 15:24:47 -0800 Subject: [PATCH 0088/2361] this wasn't a boolean attribute --- core/src/main/resources/lib/hudson/projectView.jelly | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/lib/hudson/projectView.jelly b/core/src/main/resources/lib/hudson/projectView.jelly index 731ebbcf76..c34f69d485 100644 --- a/core/src/main/resources/lib/hudson/projectView.jelly +++ b/core/src/main/resources/lib/hudson/projectView.jelly @@ -33,8 +33,8 @@ THE SOFTWARE. The base URL of all job links. Normally ${rootURL}/ - - If the caller rendered a view tabes, set this to true so that CSS is adjusted accordingly. + + If the caller rendered a view tabes, set this attribute so that CSS is adjusted accordingly. If non-null, render nested views. -- GitLab From 0d5ed5a8c7eb91f00944b8a1e9eb4e969ee61d39 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 17:29:10 -0800 Subject: [PATCH 0089/2361] Allow the administrator to yank out dead executors. --- changelog.html | 2 ++ core/src/main/java/hudson/model/Computer.java | 15 ++++++++- core/src/main/java/hudson/model/Executor.java | 24 ++++++++++++++ .../hudson/model/Executor/causeOfDeath.jelly | 3 ++ .../test/java/hudson/model/ExecutorTest.java | 32 +++++++++++++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 test/src/test/java/hudson/model/ExecutorTest.java diff --git a/changelog.html b/changelog.html index 26bb4b6fc0..0b6dace8db 100644 --- a/changelog.html +++ b/changelog.html @@ -55,6 +55,8 @@ Upcoming changes Build names (e.g., "#123") can be now modified by users/plugins to arbitrary text. (issue 53, issue 4884) +
  • + Allow the administrator to yank out dead executors.
  • Fixed an issue preventing to copy data on AIX, HP-UX or Linux for S/390. (issue 8155) diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index f5b77f11cb..000e1500b1 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -685,10 +685,23 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces */ /*package*/ synchronized void removeExecutor(Executor e) { executors.remove(e); - if(executors.isEmpty()) + if(!isAlive()) Hudson.getInstance().removeComputer(this); } + /** + * Returns true if any of the executors are functioning. + * + * Note that if an executor dies, we'll leave it in {@link #executors} until + * the administrator yanks it out, so that we can see why it died. + */ + private boolean isAlive() { + for (Executor e : executors) + if (e.isAlive()) + return true; + return false; + } + /** * Interrupt all {@link Executor}s. */ diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index 8263bc595e..74c1cdd961 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -33,6 +33,8 @@ import hudson.model.queue.WorkUnit; import hudson.util.TimeUnit2; import hudson.util.InterceptingProxy; import hudson.security.ACL; +import org.kohsuke.stapler.HttpResponse; +import org.kohsuke.stapler.HttpResponses; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.export.ExportedBean; @@ -77,6 +79,8 @@ public class Executor extends Thread implements ModelObject { private Throwable causeOfDeath; + private boolean induceDeath; + public Executor(Computer owner, int n) { super("Executor #"+n+" for "+owner.getDisplayName()); this.owner = owner; @@ -107,6 +111,7 @@ public class Executor extends Thread implements ModelObject { // sometime an interrupt aborts a build but without clearing the flag. // see issue #1583 if (Thread.interrupted()) continue; + if (induceDeath) throw new ThreadDeath(); SubTask task; try { @@ -167,6 +172,14 @@ public class Executor extends Thread implements ModelObject { } } + /** + * For testing only. Simulate a fatal unexpected failure. + */ + public void killHard() { + induceDeath = true; + interrupt(); + } + /** * Returns true if we should keep going. */ @@ -361,6 +374,17 @@ public class Executor extends Thread implements ModelObject { rsp.forwardToPreviousPage(req); } + /** + * Throws away this executor and get a new one. + */ + public HttpResponse doYank() { + Hudson.getInstance().checkPermission(Hudson.ADMINISTER); + if (isAlive()) + throw new Failure("Can't yank a live executor"); + owner.removeExecutor(this); + return HttpResponses.redirectViaContextPath("/"); + } + /** * Checks if the current user has a permission to stop this build. */ diff --git a/core/src/main/resources/hudson/model/Executor/causeOfDeath.jelly b/core/src/main/resources/hudson/model/Executor/causeOfDeath.jelly index 8d3a2c335f..77ed955a5d 100644 --- a/core/src/main/resources/hudson/model/Executor/causeOfDeath.jelly +++ b/core/src/main/resources/hudson/model/Executor/causeOfDeath.jelly @@ -47,6 +47,9 @@ THE SOFTWARE.
                 ${%more info}
               
    +
    + + diff --git a/test/src/test/java/hudson/model/ExecutorTest.java b/test/src/test/java/hudson/model/ExecutorTest.java new file mode 100644 index 0000000000..d1b87dec61 --- /dev/null +++ b/test/src/test/java/hudson/model/ExecutorTest.java @@ -0,0 +1,32 @@ +package hudson.model; + +import com.gargoylesoftware.htmlunit.html.HtmlPage; +import org.jvnet.hudson.test.HudsonTestCase; + +/** + * @author Kohsuke Kawaguchi + */ +public class ExecutorTest extends HudsonTestCase { + public void testYank() throws Exception { + Computer c = Hudson.getInstance().toComputer(); + Executor e = c.getExecutors().get(0); + + // kill an executor + e.killHard(); + while (e.isAlive()) + Thread.sleep(10); + + // make sure it's dead + assertTrue(c.getExecutors().contains(e)); + assertTrue(e.getCauseOfDeath()!=null); + + // test the UI + HtmlPage p = createWebClient().goTo("/"); + p = p.getAnchorByText("Dead (!)").click(); + assertTrue(p.getWebResponse().getContentAsString().contains(ThreadDeath.class.getName())); + submit(p.getFormByName("yank")); + + assertFalse(c.getExecutors().contains(e)); + + } +} -- GitLab From b57b09734f3a36471be972a0958300a5d4ea1a03 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 17:29:26 -0800 Subject: [PATCH 0090/2361] bugs come before RFEs --- changelog.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog.html b/changelog.html index 0b6dace8db..4ef5a12209 100644 --- a/changelog.html +++ b/changelog.html @@ -49,6 +49,9 @@ Upcoming changes
  • Fixed an NPE in ComputerRetentionWork (issue 3696) +
  • + Fixed an issue preventing to copy data on AIX, HP-UX or Linux for S/390. + (issue 8155)
  • Debian package init script now honors ~/.profile.
  • @@ -57,9 +60,6 @@ Upcoming changes issue 4884)
  • Allow the administrator to yank out dead executors. -
  • - Fixed an issue preventing to copy data on AIX, HP-UX or Linux for S/390. - (issue 8155) -- GitLab From 75d748e6668ac68372ed5bf2c685b9a9430ed912 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 18:03:29 -0800 Subject: [PATCH 0091/2361] Allowed Item to expose a status icon --- .../java/hudson/model/AbstractStatusIcon.java | 33 +++++++++++ .../src/main/java/hudson/model/BallColor.java | 9 ++- .../main/java/hudson/model/StatusIcon.java | 58 +++++++++++++++++++ .../main/java/hudson/views/StatusColumn.java | 6 ++ .../resources/lib/hudson/ballColorTd.jelly | 6 +- 5 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 core/src/main/java/hudson/model/AbstractStatusIcon.java create mode 100644 core/src/main/java/hudson/model/StatusIcon.java diff --git a/core/src/main/java/hudson/model/AbstractStatusIcon.java b/core/src/main/java/hudson/model/AbstractStatusIcon.java new file mode 100644 index 0000000000..ea8c573ba9 --- /dev/null +++ b/core/src/main/java/hudson/model/AbstractStatusIcon.java @@ -0,0 +1,33 @@ +/* + * The MIT License + * + * Copyright (c) 2010, CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.model; + +/** + * Partial base class for {@link StatusIcon}. + * + * @author Kohsuke Kawaguchi + * @since 1.390 + */ +public abstract class AbstractStatusIcon implements StatusIcon { +} diff --git a/core/src/main/java/hudson/model/BallColor.java b/core/src/main/java/hudson/model/BallColor.java index 98ff3c4adb..59442621b8 100644 --- a/core/src/main/java/hudson/model/BallColor.java +++ b/core/src/main/java/hudson/model/BallColor.java @@ -23,9 +23,12 @@ */ package hudson.model; +import hudson.Functions; import hudson.util.ColorPalette; import org.jvnet.localizer.LocaleProvider; import org.jvnet.localizer.Localizable; +import org.kohsuke.stapler.Stapler; +import org.kohsuke.stapler.StaplerRequest; import java.awt.*; import java.util.Locale; @@ -50,7 +53,7 @@ import java.util.Locale; * * @author Kohsuke Kawaguchi */ -public enum BallColor { +public enum BallColor implements StatusIcon { RED("red",Messages._BallColor_Failed(), ColorPalette.RED), RED_ANIME("red_anime",Messages._BallColor_InProgress(), ColorPalette.RED), YELLOW("yellow",Messages._BallColor_Unstable(), ColorPalette.YELLOW), @@ -86,6 +89,10 @@ public enum BallColor { return image; } + public String getImageOf(String size) { + return Stapler.getCurrentRequest().getContextPath()+'/'+Hudson.RESOURCE_PATH+'/'+size+'/'+image; + } + /** * Gets the human-readable description used as img/@alt. */ diff --git a/core/src/main/java/hudson/model/StatusIcon.java b/core/src/main/java/hudson/model/StatusIcon.java new file mode 100644 index 0000000000..170e232dfa --- /dev/null +++ b/core/src/main/java/hudson/model/StatusIcon.java @@ -0,0 +1,58 @@ +/* + * The MIT License + * + * Copyright (c) 2010, CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.model; + +/** + * {@link Item} can return this from the "getIconColor" method so that + * its "status icon" can be shown in Hudson UI. + * + *

    + * For future compatibility, please extend from {@link AbstractStatusIcon} + * instead of implementing this directly, so that we can add methods later. + * + *

    + * This is a generalization of {@link BallColor}. + * + * @author Kohsuke Kawaguchi + * @since 1.390 + */ +public interface StatusIcon { + /** + * Returns the URL to the image. + * + * @param size + * The size specified. Must support "16x16", "24x24", and "32x32" at least. + * For forward compatibility, if you receive a size that's not supported, + * consider returning your biggest icon (and let the browser rescale.) + * @return + * The URL is rendered as is in the img @src attribute, so it must contain + * the context path, etc. + */ + String getImageOf(String size); + + /** + * Gets the human-readable description used as img/@alt. + */ + String getDescription(); +} diff --git a/core/src/main/java/hudson/views/StatusColumn.java b/core/src/main/java/hudson/views/StatusColumn.java index 919f9e7af8..9d67ae1536 100644 --- a/core/src/main/java/hudson/views/StatusColumn.java +++ b/core/src/main/java/hudson/views/StatusColumn.java @@ -24,8 +24,14 @@ package hudson.views; import hudson.Extension; +import hudson.model.StatusIcon; import org.kohsuke.stapler.DataBoundConstructor; +/** + * Shows the status icon for item. It's colored ball for jobs. + * + * @see StatusIcon + */ public class StatusColumn extends ListViewColumn { @DataBoundConstructor public StatusColumn() { diff --git a/core/src/main/resources/lib/hudson/ballColorTd.jelly b/core/src/main/resources/lib/hudson/ballColorTd.jelly index be8a7808ac..d39d6f108d 100644 --- a/core/src/main/resources/lib/hudson/ballColorTd.jelly +++ b/core/src/main/resources/lib/hudson/ballColorTd.jelly @@ -32,9 +32,9 @@ THE SOFTWARE. - - ${it.description} + ${it.description} - \ No newline at end of file + -- GitLab From 4cf9bb3533b6541dd1c8f64d60288270215ae7bc Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 18:11:24 -0800 Subject: [PATCH 0092/2361] pick up latest stapler --- core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/pom.xml b/core/pom.xml index 9b9776cf67..5f655a8d67 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -382,7 +382,7 @@ THE SOFTWARE. org.kohsuke.stapler stapler-jelly - 1.154 + 1.155 commons-jelly -- GitLab From 2ac5163eb61180ac7d0aa39bad35fe7d7b5b44a1 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 18:19:39 -0800 Subject: [PATCH 0093/2361] added a convenience class for the stock icon --- .../src/main/java/hudson/model/BallColor.java | 2 +- .../main/java/hudson/model/StatusIcon.java | 1 + .../java/hudson/model/StockStatusIcon.java | 35 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/hudson/model/StockStatusIcon.java diff --git a/core/src/main/java/hudson/model/BallColor.java b/core/src/main/java/hudson/model/BallColor.java index 59442621b8..a01352d43b 100644 --- a/core/src/main/java/hudson/model/BallColor.java +++ b/core/src/main/java/hudson/model/BallColor.java @@ -90,7 +90,7 @@ public enum BallColor implements StatusIcon { } public String getImageOf(String size) { - return Stapler.getCurrentRequest().getContextPath()+'/'+Hudson.RESOURCE_PATH+'/'+size+'/'+image; + return Stapler.getCurrentRequest().getContextPath()+'/'+Hudson.RESOURCE_PATH+"/images/"+size+'/'+image; } /** diff --git a/core/src/main/java/hudson/model/StatusIcon.java b/core/src/main/java/hudson/model/StatusIcon.java index 170e232dfa..458955c2be 100644 --- a/core/src/main/java/hudson/model/StatusIcon.java +++ b/core/src/main/java/hudson/model/StatusIcon.java @@ -36,6 +36,7 @@ package hudson.model; * * @author Kohsuke Kawaguchi * @since 1.390 + * @see StockStatusIcon */ public interface StatusIcon { /** diff --git a/core/src/main/java/hudson/model/StockStatusIcon.java b/core/src/main/java/hudson/model/StockStatusIcon.java new file mode 100644 index 0000000000..b68cd861b4 --- /dev/null +++ b/core/src/main/java/hudson/model/StockStatusIcon.java @@ -0,0 +1,35 @@ +package hudson.model; + +import org.jvnet.localizer.LocaleProvider; +import org.jvnet.localizer.Localizable; +import org.kohsuke.stapler.Stapler; + +/** + * {@link StatusIcon} for stock icon in Hudson. + * + * @author Kohsuke Kawaguchi + * @since 1.390. + */ +public final class StockStatusIcon extends AbstractStatusIcon { + private final Localizable description; + private final String image; + + /** + * @param image + * Short file name like "folder.gif" that points to a stock icon in Hudson. + * @param description + * Used as {@link #getDescription()}. + */ + public StockStatusIcon(String image, Localizable description) { + this.image = image; + this.description = description; + } + + public String getImageOf(String size) { + return Stapler.getCurrentRequest().getContextPath()+'/'+Hudson.RESOURCE_PATH+"/images/"+size+'/'+image; + } + + public String getDescription() { + return description.toString(LocaleProvider.getLocale()); + } +} -- GitLab From 14786e0380b2cc9fcfffb239fe95f3991c3d91a3 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 15 Dec 2010 20:51:42 -0800 Subject: [PATCH 0094/2361] creating an RC branch --- changelog.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/changelog.html b/changelog.html index 4ef5a12209..a9e2d69bf7 100644 --- a/changelog.html +++ b/changelog.html @@ -39,6 +39,14 @@ Upcoming changes

    + + + - - -

    What's new in 1.389 (2010/12/11)

    -- GitLab From 6438d5a0359c2844385f324623dfe2926b1c5bab Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 4 Jan 2011 13:43:02 -0800 Subject: [PATCH 0232/2361] parent POM has bumped to 1.8 --- plugins/pom.xml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/plugins/pom.xml b/plugins/pom.xml index 6e9a2addc1..a11d5fb62d 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -4,8 +4,7 @@ org.jvnet.hudson hudson - 1.7 - ../pom.xml + 1.8 org.jvnet.hudson.plugins @@ -227,17 +226,9 @@ - - hudson-www - scp://hudson-labs.org/home/kohsuke/www/hudson-labs.org/maven-site/ - - - maven.hudson-labs.org - http://maven.hudson-labs.org/content/repositories/releases - maven.hudson-labs.org - http://maven.hudson-labs.org/content/repositories/snapshots + http://maven.hudson-labs.org:8081/content/repositories/snapshots -- GitLab From 12867e8734704815dc1d9a3889dc23b37f81d84b Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 4 Jan 2011 13:44:42 -0800 Subject: [PATCH 0233/2361] Inheriting 1.8 parent POM and removed duplication Shouldn't be pulling any snapshot dependencies from maven.hudson-labs.org --- pom.xml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index 8020203b34..2f709dd028 100644 --- a/pom.xml +++ b/pom.xml @@ -27,8 +27,7 @@ THE SOFTWARE. org.jvnet.hudson hudson - 1.7 - ../pom.xml + 1.8 org.jvnet.hudson.main @@ -513,16 +512,6 @@ THE SOFTWARE. false - - maven.hudson-labs.org.snapshots - http://maven.hudson-labs.org/content/repositories/snapshots/ - - false - - - true - - @@ -551,13 +540,9 @@ THE SOFTWARE. hudson-www scp://hudson-labs.org/home/kohsuke/www/hudson-labs.org/maven-site/ - - maven.hudson-labs.org - http://maven.hudson-labs.org/content/repositories/releases - maven.hudson-labs.org - http://maven.hudson-labs.org/content/repositories/snapshots + http://maven.hudson-labs.org:8081/content/repositories/snapshots -- GitLab From 4bdf8ffbc7b3793878373fafbc0597c3a4635938 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 1 Jan 2011 16:36:11 -0800 Subject: [PATCH 0234/2361] Security filters should honor SecurityRealm.getLoginUrl() --- core/src/main/java/hudson/security/SecurityRealm.java | 6 ++++++ .../main/webapp/WEB-INF/security/SecurityFilters.groovy | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/security/SecurityRealm.java b/core/src/main/java/hudson/security/SecurityRealm.java index e2f9ff631c..8818cc729b 100644 --- a/core/src/main/java/hudson/security/SecurityRealm.java +++ b/core/src/main/java/hudson/security/SecurityRealm.java @@ -186,6 +186,11 @@ public abstract class SecurityRealm extends AbstractDescribableImplweb.xml, so that the user can be eventually authenticated * by the container. + * + *

    + * Path is relative from the context root of the Hudson application. + * The URL returned by this method will get the "from" query parameter indicating + * the page that the user was at. */ public String getLoginUrl() { return "login"; @@ -382,6 +387,7 @@ public abstract class SecurityRealm extends AbstractDescribableImpl Date: Wed, 5 Jan 2011 18:41:15 -0800 Subject: [PATCH 0235/2361] using a newer version --- plugins/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pom.xml b/plugins/pom.xml index a11d5fb62d..2c44b38fd2 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -120,7 +120,7 @@ org.jvnet.hudson.tools maven-hpi-plugin - 1.54 + 1.57 true true -- GitLab From 9502f530e5032c8d2fc2c9ccd7c9a2b5846fc917 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 5 Jan 2011 09:07:44 -0800 Subject: [PATCH 0236/2361] still a work in progress. Federated login support --- .../main/java/hudson/security/FederatedLoginService.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 core/src/main/java/hudson/security/FederatedLoginService.java diff --git a/core/src/main/java/hudson/security/FederatedLoginService.java b/core/src/main/java/hudson/security/FederatedLoginService.java new file mode 100644 index 0000000000..08c2c2ddd8 --- /dev/null +++ b/core/src/main/java/hudson/security/FederatedLoginService.java @@ -0,0 +1,7 @@ +package hudson.security; + +/** + * @author Kohsuke Kawaguchi + */ +public class FederatedLoginService { +} -- GitLab From 347be37405e3571566c06a2e805ba548e6e47a34 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 5 Jan 2011 18:13:41 -0800 Subject: [PATCH 0237/2361] Added an extension point for external federated login service. --- core/src/main/java/hudson/model/Hudson.java | 74 ++++++---- .../security/FederatedLoginService.java | 138 +++++++++++++++++- .../FederatedLoginServiceUserProperty.java | 36 +++++ .../resources/hudson/model/Hudson/login.jelly | 6 + 4 files changed, 223 insertions(+), 31 deletions(-) create mode 100644 core/src/main/java/hudson/security/FederatedLoginServiceUserProperty.java diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index 8621b5c3ef..77b5e873d5 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -1,20 +1,20 @@ /* * The MIT License - * + * * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, * Erik Ramfelt, Koichi Fujikawa, Red Hat, Inc., Seiji Sogabe, * Stephen Connolly, Tom Huybrechts, Yahoo! Inc., Alan Harder - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -81,6 +81,7 @@ import hudson.security.ACL; import hudson.security.AccessControlled; import hudson.security.AuthorizationStrategy; import hudson.security.BasicAuthenticationFilter; +import hudson.security.FederatedLoginService; import hudson.security.HudsonFilter; import hudson.security.LegacyAuthorizationStrategy; import hudson.security.LegacySecurityRealm; @@ -263,7 +264,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl */ // this field needs to be at the very top so that other components can look at this value even during unmarshalling private String version = "1.0"; - + /** * Number of executors of the master node. */ @@ -419,9 +420,9 @@ public final class Hudson extends Node implements ItemGroup, Stapl * This is {@link Integer} so that we can initialize it to '5' for upgrading users. */ /*package*/ Integer quietPeriod; - + /** - * Global default for {@link AbstractProject#getScmCheckoutRetryCount()} + * Global default for {@link AbstractProject#getScmCheckoutRetryCount()} */ /*package*/ int scmCheckoutRetryCount; @@ -483,7 +484,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl * {@link hudson.security.csrf.CrumbIssuer} */ private volatile CrumbIssuer crumbIssuer; - + /** * All labels known to Hudson. This allows us to reuse the same label instances * as much as possible, even though that's not a strict requirement. @@ -586,12 +587,12 @@ public final class Hudson extends Node implements ItemGroup, Stapl throw new IllegalStateException("second instance"); theInstance = this; - // doing this early allows InitStrategy to set environment upfront + // doing this early allows InitStrategy to set environment upfront final InitStrategy is = InitStrategy.get(Thread.currentThread().getContextClassLoader()); - + Trigger.timer = new Timer("Hudson cron thread"); queue = new Queue(CONSISTENT_HASH?LoadBalancer.CONSISTENT_HASH:LoadBalancer.DEFAULT); - + try { dependencyGraph = DependencyGraph.EMPTY; } catch (InternalError e) { @@ -725,7 +726,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl * *

    * At this point plugins are not loaded yet, so we fall back to the META-INF/services look up to discover implementations. - * As such there's no way for plugins to participate into this process. + * As such there's no way for plugins to participate into this process. */ private ReactorListener buildReactorListener() throws IOException { List r = (List) Service.loadInstances(Thread.currentThread().getContextClassLoader(), InitReactorListener.class); @@ -959,7 +960,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl throw new AssertionError(type+" is missing its descriptor"); return d; } - + /** * Gets the {@link Descriptor} instance in the current Hudson by its type. */ @@ -1099,6 +1100,18 @@ public final class Hudson extends Node implements ItemGroup, Stapl save(); } + public FederatedLoginService getFederatedLoginService(String name) { + for (FederatedLoginService fls : FederatedLoginService.all()) { + if (fls.getUrlName().equals(name)) + return fls; + } + return null; + } + + public List getFederatedLoginServices() { + return FederatedLoginService.all(); + } + public Launcher createLauncher(TaskListener listener) { return new LocalLauncher(listener).decorateFor(this); } @@ -1214,7 +1227,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl if (item.hasPermission(Item.READ)) viewableItems.add(item); } - + return viewableItems; } @@ -1222,7 +1235,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl * Returns the read-only view of all the {@link TopLevelItem}s keyed by their names. *

    * This method is efficient, as it doesn't involve any copying. - * + * * @since 1.296 */ public Map getItemMap() { @@ -1336,7 +1349,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl views.remove(view); save(); } - + public ViewsTabBar getViewsTabBar() { return viewsTabBar; } @@ -1659,15 +1672,15 @@ public final class Hudson extends Node implements ItemGroup, Stapl public int getQuietPeriod() { return quietPeriod!=null ? quietPeriod : 5; } - + /** * Gets the global SCM check out retry count. */ public int getScmCheckoutRetryCount() { return scmCheckoutRetryCount; } - - + + /** * @deprecated @@ -1822,7 +1835,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl public boolean isUseCrumbs() { return crumbIssuer!=null; } - + /** * Returns the constant that captures the three basic security modes * in Hudson. @@ -1954,7 +1967,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl * * @return * {@link InitMilestone#STARTED} even if the initialization hasn't been started, so that this method - * never returns null. + * never returns null. */ public InitMilestone getInitLevel() { return initLevel; @@ -2463,7 +2476,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl label = json.optString("labelString",""); quietPeriod = json.getInt("quiet_period"); - + scmCheckoutRetryCount = json.getInt("retry_count"); systemMessage = Util.nullify(req.getParameter("system_message")); @@ -2501,7 +2514,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl public CrumbIssuer getCrumbIssuer() { return crumbIssuer; } - + public void setCrumbIssuer(CrumbIssuer issuer) { crumbIssuer = issuer; } @@ -2897,7 +2910,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl // Parse the request MultipartFormDataParser p = new MultipartFormDataParser(req); if(Hudson.getInstance().isUseCrumbs() && !Hudson.getInstance().getCrumbIssuer().validateCrumb(req, p)) { - rsp.sendError(HttpServletResponse.SC_FORBIDDEN,"No crumb found"); + rsp.sendError(HttpServletResponse.SC_FORBIDDEN,"No crumb found"); } try { rsp.sendRedirect2(req.getContextPath()+"/fingerprint/"+ @@ -2999,7 +3012,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl * Queues up a restart of Hudson for when there are no builds running, if we can. * * This first replaces "app" to {@link HudsonIsRestarting} - * + * * @since 1.332 */ @CLIMethod(name="safe-restart") @@ -3055,7 +3068,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl lifecycle.verifyRestartable(); // verify that Hudson is restartable // Quiet down so that we won't launch new builds. isQuietingDown = true; - + new Thread("safe-restart thread") { final String exitUser = getAuthentication().getName(); @Override @@ -3105,7 +3118,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl System.exit(0); } - + /** * Shutdown the system safely. * @since 1.332 @@ -3268,7 +3281,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl // this method can be used to check if a file exists anywhere in the file system, // so it should be protected. checkPermission(Item.CREATE); - + if(fixEmpty(value)==null) return FormValidation.ok(); @@ -3470,6 +3483,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl || rest.startsWith("/tcpSlaveAgentListener") || rest.startsWith("/cli") || rest.startsWith("/whoAmI") + || rest.startsWith("/federatedLoginService/") || rest.startsWith("/securityRealm")) return this; // URLs that are always visible without READ permission throw e; @@ -3588,7 +3602,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl public static T lookup(Class type) { return Hudson.getInstance().lookup.get(type); } - + /** * @deprecated since 2007-12-18. * Use {@link #checkPermission(Permission)} @@ -3761,7 +3775,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl * Automatically try to launch a slave when Hudson is initialized or a new slave is created. */ public static boolean AUTOMATIC_SLAVE_LAUNCH = true; - + private static final Logger LOGGER = Logger.getLogger(Hudson.class.getName()); private static final Pattern ICON_SIZE = Pattern.compile("\\d+x\\d+"); diff --git a/core/src/main/java/hudson/security/FederatedLoginService.java b/core/src/main/java/hudson/security/FederatedLoginService.java index 08c2c2ddd8..e516e565d3 100644 --- a/core/src/main/java/hudson/security/FederatedLoginService.java +++ b/core/src/main/java/hudson/security/FederatedLoginService.java @@ -1,7 +1,143 @@ package hudson.security; +import hudson.ExtensionList; +import hudson.ExtensionPoint; +import hudson.model.Hudson; +import hudson.model.User; +import hudson.model.UserProperty; +import org.acegisecurity.context.SecurityContextHolder; +import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.acegisecurity.userdetails.UserDetails; + +import java.io.IOException; + /** + * Abstraction for a login mechanism through external authenticator/identity provider + * (instead of username/password.) + * + *

    + * This extension point adds additional login mechanism for {@link SecurityRealm}s that + * authenticate the user via username/password (which typically extends from {@link AbstractPasswordBasedSecurityRealm}.) + * The intended use case is protocols like OpenID, OAuth, and other SSO-like services. + * + *

    + * The basic abstraction is that: + * + *

      + *
    • + * The user can have (possibly multiple, possibly zero) opaque strings to their {@linkplain User} object. + * Such opaque strings are called "identifiers." + * Think of them as OpenID URLs, twitter account names, etc. + * Identifiers are only comparable within the same {@link FederatedLoginService} implementation. + * + *
    • + * After getting authenticated by some means, the user can add additional identifiers to their account. + * Your implementation would do protocol specific thing to verify that the user indeed owns those identifiers, + * then call {@link #onAssociated(String)} to record such association. + * + *
    • + * In the login page, instead of entering the username and password, the user opts for authenticating + * via other services. Think of OpenID, OAuth, your corporate SSO service, etc. + * The user proves (by your protocol specific way) that they own some identifier, then you call + * {@link #onIdentified(String)} to sign in that user. + * + *
    + * + * + *

    Views

    + *
    + *
    loginFragment.jelly + *
    + * Injected into the login form page, after the default "login" button but before + * the "create account" link. Use this to generate a button or a link so that the user + * can initiate login via your federated login service. + *
    + * + *

    URL Binding

    + *

    + * Each {@link FederatedLoginService} is exposed to the URL space via {@link Hudson#getFederatedLoginService(String)}. + * So for example if your {@linkplain #getUrlName() url name} is "openid", this object gets + * "/federatedLoginService/openid" as the URL. + * * @author Kohsuke Kawaguchi + * @since 1.393 */ -public class FederatedLoginService { +public abstract class FederatedLoginService implements ExtensionPoint { + /** + * Returns the url name that determines where this {@link FederatedLoginService} is mapped to in the URL space. + * + *

    + * The object is bound to /federatedLoginService/URLNAME/. The url name needs to be unique among all + * {@link FederatedLoginService}s. + */ + public abstract String getUrlName(); + + /** + * Returns your implementation of {@link FederatedLoginServiceUserProperty} that stores + * opaque identifiers. + */ + public abstract Class getUserPropertyClass(); + + /** + * Locates the user who owns a particular identifier. + */ + public User findUserByIdentifier(String identifier) { + Class pt = getUserPropertyClass(); + for (User u : User.getAll()) { + if (u.getProperty(pt).has(identifier)) + return u; + } + return null; + } + + /** + * Your implementation will call this method to authenticate the user when you confirmed that + * the current HTTP request owns the given identifier. + * + *

    + * This method will locate the user who owns this identifier, associate the credential with + * the current session, and returns true. IOW, it signs in the user. + * + * @return + * true if the user who owns the identifier is discovered and the user is signed in. + * false if the given identifier is not claimed by anyone. + */ + protected boolean onIdentified(String identifier) { + User u = findUserByIdentifier(identifier); + if (u!=null) { + // login as this user + UserDetails d = Hudson.getInstance().getSecurityRealm().loadUserByUsername(u.getId()); + + UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(d,"",d.getAuthorities()); + token.setDetails(d); + SecurityContextHolder.getContext().setAuthentication(token); + return true; + } else { + // unassociated identity + return false; + } + } + + /** + * Your implementation will call this method when you confirmed that + * the current user owns the given identifier. + *

    + * This method will record the identifier in {@link FederatedLoginServiceUserProperty} so that + * in the future the user can login to Hudson with the identifier. + */ + protected void onAssociated(String identifier) throws IOException { + User u = User.current(); + if (u==null) throw new IllegalStateException("Current request is unauthenticated"); + + FederatedLoginServiceUserProperty p = u.getProperty(getUserPropertyClass()); + if (p==null) { + p = (FederatedLoginServiceUserProperty) UserProperty.all().find(getUserPropertyClass()).newInstance(u); + u.addProperty(p); + } + p.addIdentifier(identifier); + } + + public static ExtensionList all() { + return Hudson.getInstance().getExtensionList(FederatedLoginService.class); + } } diff --git a/core/src/main/java/hudson/security/FederatedLoginServiceUserProperty.java b/core/src/main/java/hudson/security/FederatedLoginServiceUserProperty.java new file mode 100644 index 0000000000..3784f4d7dd --- /dev/null +++ b/core/src/main/java/hudson/security/FederatedLoginServiceUserProperty.java @@ -0,0 +1,36 @@ +package hudson.security; + +import hudson.model.UserProperty; + +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * + * @author Kohsuke Kawaguchi + * @since 1.393 + * @see FederatedLoginService + */ +public class FederatedLoginServiceUserProperty extends UserProperty { + protected final Set identifiers; + + protected FederatedLoginServiceUserProperty(Collection identifiers) { + this.identifiers = new HashSet(identifiers); + } + + public boolean has(String identifier) { + return identifiers.contains(identifier); + } + + public Collection getIdentifiers() { + return Collections.unmodifiableSet(identifiers); + } + + public synchronized void addIdentifier(String id) throws IOException { + identifiers.add(id); + user.save(); + } +} diff --git a/core/src/main/resources/hudson/model/Hudson/login.jelly b/core/src/main/resources/hudson/model/Hudson/login.jelly index 3762d00719..b041db82ed 100644 --- a/core/src/main/resources/hudson/model/Hudson/login.jelly +++ b/core/src/main/resources/hudson/model/Hudson/login.jelly @@ -55,6 +55,12 @@ THE SOFTWARE. + +

    + +
    + +
    ${%signUp} -- GitLab From 1f8e300c8a17f6837c9bc5f50b8cc04feb726b18 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 5 Jan 2011 19:09:00 -0800 Subject: [PATCH 0238/2361] needs a title --- .../hudson/security/HudsonPrivateSecurityRealm/_entryForm.jelly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/_entryForm.jelly b/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/_entryForm.jelly index 13afd1d37b..d832781050 100644 --- a/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/_entryForm.jelly +++ b/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/_entryForm.jelly @@ -24,7 +24,7 @@ THE SOFTWARE. - + @@ -33,13 +35,13 @@ Some tips: major bugmajor bug fix bugbug fix xxxxx
    -
    +
  • Fixed a dead lock in concurrent builds of the same Maven projects. (issue 4220) -
  • - thread dump now reports all the threads from all the slaves, not just the master.
  • Plugin Manager incorrectly displays "Changes will take effect when you restart Jenkins". (issue 8917) +
  • + Added Manage Jenkins link in sidepanel of Plugin Manager and Update Center. + (issue 8780) +
  • + Thread dump now reports all the threads from all the slaves, not just the master.
  • Made the extension point implementation discovery logic customizable by a plugin (issue 8897) -- GitLab From f7dbe86350d97d38a66cd4684367bf6d4a44211d Mon Sep 17 00:00:00 2001 From: Andrew Bayer Date: Fri, 4 Mar 2011 11:01:43 -0800 Subject: [PATCH 0688/2361] If you had two clouds and only the second one could provision a label, it'd never get that far - check to see if a cloud can provision a label before trying to do so. --- .../java/hudson/slaves/NodeProvisioner.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/hudson/slaves/NodeProvisioner.java b/core/src/main/java/hudson/slaves/NodeProvisioner.java index 8935ec03ff..caa7275eb0 100644 --- a/core/src/main/java/hudson/slaves/NodeProvisioner.java +++ b/core/src/main/java/hudson/slaves/NodeProvisioner.java @@ -180,18 +180,21 @@ public class NodeProvisioner { for( Cloud c : hudson.clouds ) { if(excessWorkload<0) break; // enough slaves allocated - // provisioning a new node should be conservative --- for example if exceeWorkload is 1.4, - // we don't want to allocate two nodes but just one. - // OTOH, because of the exponential decay, even when we need one slave, excess workload is always - // something like 0.95, in which case we want to allocate one node. - // so the threshold here is 1-MARGIN, and hence floor(excessWorkload+MARGIN) is needed to handle this. - - Collection additionalCapacities = c.provision(label, (int)Math.round(Math.floor(excessWorkload+m))); - for (PlannedNode ac : additionalCapacities) { - excessWorkload -= ac.numExecutors; - LOGGER.info("Started provisioning "+ac.displayName+" from "+c.name+" with "+ac.numExecutors+" executors. Remaining excess workload:"+excessWorkload); + // Make sure this cloud actually can provision for this label. + if (c.canProvision(label)) { + // provisioning a new node should be conservative --- for example if exceeWorkload is 1.4, + // we don't want to allocate two nodes but just one. + // OTOH, because of the exponential decay, even when we need one slave, excess workload is always + // something like 0.95, in which case we want to allocate one node. + // so the threshold here is 1-MARGIN, and hence floor(excessWorkload+MARGIN) is needed to handle this. + + Collection additionalCapacities = c.provision(label, (int)Math.round(Math.floor(excessWorkload+m))); + for (PlannedNode ac : additionalCapacities) { + excessWorkload -= ac.numExecutors; + LOGGER.info("Started provisioning "+ac.displayName+" from "+c.name+" with "+ac.numExecutors+" executors. Remaining excess workload:"+excessWorkload); + } + pendingLaunches.addAll(additionalCapacities); } - pendingLaunches.addAll(additionalCapacities); } } } -- GitLab From 1458f93a3c809bf8b5a4f2b1ed3de3769bffc715 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 5 Mar 2011 22:13:07 +0100 Subject: [PATCH 0689/2361] [FIXED JENKINS-8939] Fix for JENKINS-8711 breaks deployments with credentials take care about using settings from the remote node --- .../hudson/maven/MavenModuleSetBuild.java | 2 + .../java/hudson/maven/RedeployPublisher.java | 68 +++++++++++++++---- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index f0a61fa973..d785954566 100755 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -1088,6 +1088,8 @@ public class MavenModuleSetBuild extends AbstractMavenBuild { + public String call() throws IOException { + return System.getProperty("user.home"); } - - return MavenUtil.createEmbedder(new MavenEmbedderRequest(listener, - m!=null?m.getHomeDir():null, - profiles, - systemProperties, - privateRepository, - settingsLoc )); } -- GitLab From d023101b39faa5c7aacd66babb59b3f51093f241 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 5 Mar 2011 22:42:41 +0100 Subject: [PATCH 0690/2361] take care of missing / for file path --- maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java b/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java index 7caa66e1cc..7bde14a656 100644 --- a/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java +++ b/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java @@ -187,7 +187,7 @@ public class RedeployPublisher extends Recorder { if (StringUtils.isBlank( altSettingsPath ) ) { // get userHome from the node where job has been executed String remoteUserHome = project.getSomeWorkspace().act( new GetUserHome() ); - altSettingsPath = remoteUserHome + ".m2/settings.xml"; + altSettingsPath = remoteUserHome + "/.m2/settings.xml"; } // we copy this file in the master in a temporary file -- GitLab From 47a39f9fcec63f84b06af03453af88196171b92e Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 5 Mar 2011 22:52:09 +0100 Subject: [PATCH 0691/2361] take care of missing / for file path --- .../src/main/java/hudson/maven/RedeployPublisher.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java b/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java index 7bde14a656..7d3fb48483 100644 --- a/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java +++ b/maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java @@ -168,9 +168,10 @@ public class RedeployPublisher extends Recorder { try { AbstractProject project = build.getProject(); - if (project instanceof ProjectWithMaven) { - m = ((ProjectWithMaven) project).inferMavenInstallation().forNode(Hudson.getInstance(),listener); - } + // don't care here as it's executed in the master + //if (project instanceof ProjectWithMaven) { + // m = ((ProjectWithMaven) project).inferMavenInstallation().forNode(Hudson.getInstance(),listener); + //} if (project instanceof MavenModuleSet) { profiles = ((MavenModuleSet) project).getProfiles(); systemProperties = ((MavenModuleSet) project).getMavenProperties(); -- GitLab From d3202f28a5c6e4fed9df98cb1eb4f4b01c8d537c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 5 Mar 2011 23:10:06 +0100 Subject: [PATCH 0692/2361] format code --- maven-plugin/src/main/java/hudson/maven/MavenUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java index cd7e60b5a2..3abd0ccb85 100755 --- a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java @@ -178,8 +178,8 @@ public class MavenUtil { if (mavenEmbedderRequest.getTransferListener() != null) { if (debugMavenEmbedder) { - mavenEmbedderRequest.getListener().getLogger() - .println( "use transfertListener " + mavenEmbedderRequest.getTransferListener().getClass().getName() ); + mavenEmbedderRequest.getListener().getLogger() + .println( "use transfertListener " + mavenEmbedderRequest.getTransferListener().getClass().getName() ); } mavenRequest.setTransferListener( mavenEmbedderRequest.getTransferListener() ); } -- GitLab From 31b951f4025c34959b5a3e33d24601c6156a64ad Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 5 Mar 2011 23:15:15 +0100 Subject: [PATCH 0693/2361] changelog for JENKINS-8939 --- changelog.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.html b/changelog.html index fbdb97ee28..b392533ce3 100644 --- a/changelog.html +++ b/changelog.html @@ -60,6 +60,9 @@ Upcoming changes

    What's new in 1.399 (2011/02/27)

    • -- GitLab From 0d834e17ec993512e62078c727915ddf942acca0 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 6 Mar 2011 22:29:00 -0800 Subject: [PATCH 0700/2361] releasing a new plugin parent POM --- plugins/pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/pom.xml b/plugins/pom.xml index 03c8f1dec0..090a08d52d 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -10,7 +10,7 @@ org.jenkins-ci.plugins plugin Jenkins plugin POM - 1.400-SNAPSHOT + 1.400 pom @@ -38,7 +38,7 @@ org.jenkins-ci.main maven-plugin - 1.400-SNAPSHOT + 1.400 @@ -48,25 +48,25 @@ org.jenkins-ci.main jenkins-war war - 1.400-SNAPSHOT + 1.400 test org.jenkins-ci.main jenkins-core - 1.400-SNAPSHOT + 1.400 provided org.jenkins-ci.main jenkins-test-harness - 1.400-SNAPSHOT + 1.400 test org.jenkins-ci.main ui-samples-plugin - 1.400-SNAPSHOT + 1.400 test -- GitLab From f260afda37994ae23a023f497f3d19129ad7ef63 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 6 Mar 2011 22:29:05 -0800 Subject: [PATCH 0701/2361] toward the next release --- plugins/pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/pom.xml b/plugins/pom.xml index 090a08d52d..a0d97cb035 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -10,7 +10,7 @@ org.jenkins-ci.plugins plugin Jenkins plugin POM - 1.400 + 1.401-SNAPSHOT pom @@ -38,7 +38,7 @@ org.jenkins-ci.main maven-plugin - 1.400 + 1.401-SNAPSHOT @@ -48,25 +48,25 @@ org.jenkins-ci.main jenkins-war war - 1.400 + 1.401-SNAPSHOT test org.jenkins-ci.main jenkins-core - 1.400 + 1.401-SNAPSHOT provided org.jenkins-ci.main jenkins-test-harness - 1.400 + 1.401-SNAPSHOT test org.jenkins-ci.main ui-samples-plugin - 1.400 + 1.401-SNAPSHOT test -- GitLab From ed44cc3969c03a6e13a1b06863752e9798a52403 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 6 Mar 2011 22:32:02 -0800 Subject: [PATCH 0702/2361] updated changelog as a part of the release --- debian/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/debian/changelog b/debian/debian/changelog index 9b8388563d..e3d9ff6d54 100644 --- a/debian/debian/changelog +++ b/debian/debian/changelog @@ -1,3 +1,9 @@ +jenkins (1.400) unstable; urgency=low + + * See http://jenkins-ci.org/changelog for more details. + + -- Kohsuke Kawaguchi Sun, 06 Mar 2011 22:29:43 -0800 + jenkins (1.399) unstable; urgency=low * See http://jenkins-ci.org/changelog for more details. -- GitLab From 2bba3bca45898fb6ee78b22f60f4ca1e7ec6b2e8 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 7 Mar 2011 11:54:29 -0800 Subject: [PATCH 0703/2361] Exposed the pending provisioning requests to outside. --- .../main/java/hudson/slaves/NodeProvisioner.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/slaves/NodeProvisioner.java b/core/src/main/java/hudson/slaves/NodeProvisioner.java index caa7275eb0..dec35a0cfe 100644 --- a/core/src/main/java/hudson/slaves/NodeProvisioner.java +++ b/core/src/main/java/hudson/slaves/NodeProvisioner.java @@ -34,6 +34,7 @@ import hudson.model.MultiStageTimeSeries.TimeScale; import hudson.Extension; import java.awt.Color; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Future; import java.util.concurrent.ExecutionException; import java.util.List; @@ -84,7 +85,7 @@ public class NodeProvisioner { */ private final Label label; - private List pendingLaunches = new ArrayList(); + private List pendingLaunches = new CopyOnWriteArrayList(); /** * Exponential moving average of the "planned capacity" over time, which is the number of @@ -101,6 +102,17 @@ public class NodeProvisioner { this.stat = loadStatistics; } + /** + * Nodes that are being launched. + * + * @return + * Can be empty but never null + * @since 1.401 + */ + public List getPendingLaunches() { + return new ArrayList(pendingLaunches); + } + /** * Periodically invoked to keep track of the load. * Launches additional nodes if necessary. -- GitLab From 6047566bb3d4075acd4df5ae02118b48a94bc0d0 Mon Sep 17 00:00:00 2001 From: alanharder Date: Tue, 8 Mar 2011 10:32:41 -0800 Subject: [PATCH 0704/2361] use latest parent --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a82ca3afbb..86cd7d273d 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci jenkins - 1.16 + 1.17 org.jenkins-ci.main -- GitLab From 94bc566f59231e1df51e2e89335e7d39826c4004 Mon Sep 17 00:00:00 2001 From: alanharder Date: Tue, 8 Mar 2011 10:33:01 -0800 Subject: [PATCH 0705/2361] use latest parent, and use plugin versions specified in parent for more items, which upgrades the versions used for maven-hpi-plugin, maven-stapler-plugin and maven-localizer-plugin --- plugins/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/pom.xml b/plugins/pom.xml index a0d97cb035..34fef323d9 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci jenkins - 1.16 + 1.17 org.jenkins-ci.plugins @@ -120,7 +120,7 @@ org.jenkins-ci.tools maven-hpi-plugin - 1.64 + true true @@ -129,7 +129,7 @@ org.kohsuke.stapler maven-stapler-plugin - 1.12 + true @@ -142,7 +142,7 @@ org.jvnet.localizer maven-localizer-plugin - 1.8 + -- GitLab From 2b5041a4b36d0cfaf0dcb75ab07a56eb6471af3a Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 8 Mar 2011 10:36:14 -0800 Subject: [PATCH 0706/2361] creating an RC branch --- changelog.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/changelog.html b/changelog.html index 7f4f2ef9b3..c926905eb5 100644 --- a/changelog.html +++ b/changelog.html @@ -59,6 +59,14 @@ Upcoming changes + + + - - -

      What's new in 1.400 (2011/03/06)

        -- GitLab From 51770129bbac3e9dcbdbbd927f2d65dbdb330c0b Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 8 Mar 2011 10:36:20 -0800 Subject: [PATCH 0707/2361] the trunk is toward 1.402-SNAPSHOT --- cli/pom.xml | 2 +- core/pom.xml | 2 +- maven-agent/pom.xml | 2 +- maven-interceptor/pom.xml | 2 +- maven-plugin/pom.xml | 2 +- maven3-agent/pom.xml | 2 +- maven3-interceptor/pom.xml | 2 +- plugins/pom.xml | 12 ++++++------ pom.xml | 2 +- remoting/pom.xml | 2 +- test/pom.xml | 2 +- ui-samples-plugin/pom.xml | 2 +- war/pom.xml | 2 +- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index b449b42e3e..8072d390dd 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -4,7 +4,7 @@ pom org.jenkins-ci.main - 1.401-SNAPSHOT + 1.402-SNAPSHOT cli Jenkins CLI diff --git a/core/pom.xml b/core/pom.xml index 626ee57e92..29f777bab8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT ../pom.xml diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index f1a7bbb733..7b4464f5e2 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT ../pom.xml diff --git a/maven-interceptor/pom.xml b/maven-interceptor/pom.xml index c83a20fcf8..64179b648a 100644 --- a/maven-interceptor/pom.xml +++ b/maven-interceptor/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT ../pom.xml diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 39d464d099..51d138409f 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT maven-plugin diff --git a/maven3-agent/pom.xml b/maven3-agent/pom.xml index 8702aeb023..66a9b72773 100755 --- a/maven3-agent/pom.xml +++ b/maven3-agent/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT maven3-agent Jenkins Maven3 CLI Agent diff --git a/maven3-interceptor/pom.xml b/maven3-interceptor/pom.xml index 915fd0ea46..b34ed92a13 100755 --- a/maven3-interceptor/pom.xml +++ b/maven3-interceptor/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT maven3-interceptor Jenkins Maven3 Interceptor diff --git a/plugins/pom.xml b/plugins/pom.xml index 34fef323d9..644a33e645 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -10,7 +10,7 @@ org.jenkins-ci.plugins plugin Jenkins plugin POM - 1.401-SNAPSHOT + 1.402-SNAPSHOT pom @@ -38,7 +38,7 @@ org.jenkins-ci.main maven-plugin - 1.401-SNAPSHOT + 1.402-SNAPSHOT @@ -48,25 +48,25 @@ org.jenkins-ci.main jenkins-war war - 1.401-SNAPSHOT + 1.402-SNAPSHOT test org.jenkins-ci.main jenkins-core - 1.401-SNAPSHOT + 1.402-SNAPSHOT provided org.jenkins-ci.main jenkins-test-harness - 1.401-SNAPSHOT + 1.402-SNAPSHOT test org.jenkins-ci.main ui-samples-plugin - 1.401-SNAPSHOT + 1.402-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 86cd7d273d..9211d24bc0 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT pom Jenkins main module diff --git a/remoting/pom.xml b/remoting/pom.xml index 9c208d3baa..7491292e9b 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT ../pom.xml diff --git a/test/pom.xml b/test/pom.xml index 5325fa2618..d335d5cb01 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. pom org.jenkins-ci.main - 1.401-SNAPSHOT + 1.402-SNAPSHOT 4.0.0 org.jenkins-ci.main diff --git a/ui-samples-plugin/pom.xml b/ui-samples-plugin/pom.xml index f89cc6707f..ca5d5be9fc 100644 --- a/ui-samples-plugin/pom.xml +++ b/ui-samples-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT ui-samples-plugin diff --git a/war/pom.xml b/war/pom.xml index e0f828927e..d99be6c940 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.402-SNAPSHOT ../pom.xml -- GitLab From 229f536cbafadde6d1be07b92b367d2a7eba8609 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 8 Mar 2011 11:04:00 -0800 Subject: [PATCH 0708/2361] [FIXED JENKINS-8866] Look for Descriptor.getId()==null and warn the administrator --- changelog.html | 4 +- core/src/main/java/hudson/PluginManager.java | 14 ++++ .../diagnosis/NullIdDescriptorMonitor.java | 80 +++++++++++++++++++ .../main/java/hudson/model/Descriptor.java | 4 + core/src/main/java/hudson/model/Hudson.java | 2 +- .../NullIdDescriptorMonitor/message.jelly | 36 +++++++++ .../message.properties | 3 + 7 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 core/src/main/java/hudson/diagnosis/NullIdDescriptorMonitor.java create mode 100644 core/src/main/resources/hudson/diagnosis/NullIdDescriptorMonitor/message.jelly create mode 100644 core/src/main/resources/hudson/diagnosis/NullIdDescriptorMonitor/message.properties diff --git a/changelog.html b/changelog.html index c926905eb5..c121a698e2 100644 --- a/changelog.html +++ b/changelog.html @@ -60,7 +60,9 @@ Upcoming changes diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index b4b843fc07..c275fa0e5c 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -455,6 +455,20 @@ public abstract class PluginManager extends AbstractModelObject { return result; } + /** + * Return the {@link PluginWrapper} that loaded the given class 'c'. + * + * @since 1.402. + */ + public PluginWrapper whichPlugin(Class c) { + ClassLoader cl = c.getClassLoader(); + for (PluginWrapper p : activePlugins) { + if (p.classLoader==cl) + return p; + } + return null; + } + /** * Orderly terminates all the plugins. */ diff --git a/core/src/main/java/hudson/diagnosis/NullIdDescriptorMonitor.java b/core/src/main/java/hudson/diagnosis/NullIdDescriptorMonitor.java new file mode 100644 index 0000000000..b54355f620 --- /dev/null +++ b/core/src/main/java/hudson/diagnosis/NullIdDescriptorMonitor.java @@ -0,0 +1,80 @@ +/* + * The MIT License + * + * Copyright (c) 2011, CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.diagnosis; + +import hudson.Extension; +import hudson.PluginWrapper; +import hudson.init.Initializer; +import hudson.model.AdministrativeMonitor; +import hudson.model.Descriptor; +import hudson.model.Hudson; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.logging.Logger; + +import static hudson.init.InitMilestone.EXTENSIONS_AUGMENTED; + +/** + * Some old descriptors apparently has the getId() method that's used in different ways + * and that's causing errors like JENKINS-8866, so detect and report that. + * + * @author Kohsuke Kawaguchi + * @since 1.402 + */ +@Extension +public class NullIdDescriptorMonitor extends AdministrativeMonitor { + + private final List problems = new ArrayList(); + + @Override + public boolean isActivated() { + return !problems.isEmpty(); + } + + public List getProblems() { + return Collections.unmodifiableList(problems); + } + + private void verify() { + Hudson h = Hudson.getInstance(); + for (Descriptor d : h.getExtensionList(Descriptor.class)) { + if (d.getId()==null) { + PluginWrapper p = h.getPluginManager().whichPlugin(d.getClass()); + LOGGER.severe(MessageFormat.format("Descriptor {0} from plugin {1} with display name {2} has null ID", + d, p==null?"???":p.getLongName(), d.getDisplayName())); + problems.add(d); + } + } + } + + @Initializer(after=EXTENSIONS_AUGMENTED) + public static void verifyId() { + AdministrativeMonitor.all().get(NullIdDescriptorMonitor.class).verify(); + } + + private static final Logger LOGGER = Logger.getLogger(NullIdDescriptorMonitor.class.getName()); +} diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 5ad77d0862..183ba785a0 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -30,6 +30,8 @@ import hudson.BulkChange; import hudson.Util; import static hudson.Functions.jsStringEscape; import hudson.diagnosis.OldDataMonitor; +import hudson.init.InitMilestone; +import hudson.init.Initializer; import hudson.model.listeners.SaveableListener; import hudson.util.ReflectionUtils; import hudson.util.ReflectionUtils.Parameter; @@ -41,12 +43,14 @@ import org.springframework.util.StringUtils; import org.jvnet.tiger_types.Types; import org.apache.commons.io.IOUtils; +import static hudson.init.InitMilestone.EXTENSIONS_AUGMENTED; import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; import javax.servlet.ServletException; import javax.servlet.RequestDispatcher; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index 3975a337bf..54eb95f5a9 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -1682,7 +1682,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl public static final DescriptorImpl INSTANCE = new DescriptorImpl(); public String getDisplayName() { - throw new UnsupportedOperationException(); + return ""; } @Override diff --git a/core/src/main/resources/hudson/diagnosis/NullIdDescriptorMonitor/message.jelly b/core/src/main/resources/hudson/diagnosis/NullIdDescriptorMonitor/message.jelly new file mode 100644 index 0000000000..3717859576 --- /dev/null +++ b/core/src/main/resources/hudson/diagnosis/NullIdDescriptorMonitor/message.jelly @@ -0,0 +1,36 @@ + + + +
        + ${%blurb} +
          + +
        • + ${%problem(d, d.displayName, app.pluginManager.whichPlugin(d.getClass()))} +
        • +
          +
        +
        +
        diff --git a/core/src/main/resources/hudson/diagnosis/NullIdDescriptorMonitor/message.properties b/core/src/main/resources/hudson/diagnosis/NullIdDescriptorMonitor/message.properties new file mode 100644 index 0000000000..399938b97a --- /dev/null +++ b/core/src/main/resources/hudson/diagnosis/NullIdDescriptorMonitor/message.properties @@ -0,0 +1,3 @@ +blurb=The following extensions have no ID value and therefore likely cause a problem. Please upgrade these plugins if they are not the latest, \ + and if they are the latest, please file a bug so that we can fix them. +problem=Descriptor {0} from plugin {2} with display name {1} \ No newline at end of file -- GitLab From 114546f538e001b7c5fc44add6e92868b2c7c2ce Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 9 Mar 2011 10:38:03 -0800 Subject: [PATCH 0709/2361] doc improvement --- core/src/main/java/hudson/slaves/ComputerLauncher.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/java/hudson/slaves/ComputerLauncher.java b/core/src/main/java/hudson/slaves/ComputerLauncher.java index d9a25343ed..982561194b 100644 --- a/core/src/main/java/hudson/slaves/ComputerLauncher.java +++ b/core/src/main/java/hudson/slaves/ComputerLauncher.java @@ -67,6 +67,9 @@ public abstract class ComputerLauncher extends AbstractDescribableImpl * This method must operate synchronously. Asynchrony is provided by {@link Computer#connect(boolean)} and -- GitLab From b40e7b4228a6a5979fa484b2d2b15259bfab0ff5 Mon Sep 17 00:00:00 2001 From: Robert Elliot Date: Thu, 3 Mar 2011 23:40:04 +0000 Subject: [PATCH 0710/2361] [FIXED JENKINS-8929] Changed the definition of a building downstream project to one that is Building, Waiting, Pending or Buildable but NOT blocked. This prevents the deadlock condition where upstream project A is blocked on downstream project B, which is blocked on upstream project A - now in this scenario B will remain blocked but A will build, eventually freeing up B. --- .../main/java/hudson/model/AbstractProject.java | 6 ++++-- core/src/main/java/hudson/model/Queue.java | 14 +++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index a3aff920f5..5d8e237ca3 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -100,6 +100,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -1082,9 +1083,10 @@ public abstract class AbstractProject

        ,R extends A protected AbstractProject getBuildingDownstream() { DependencyGraph graph = Hudson.getInstance().getDependencyGraph(); Set tups = graph.getTransitiveDownstream(this); - tups.add(this); + Queue queue = Hudson.getInstance().getQueue(); + for (AbstractProject tup : tups) { - if(tup!=this && (tup.isBuilding() || tup.isInQueue())) + if(tup.isBuilding() || queue.getUnblockedItems().containsKey(tup)) return tup; } return null; diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index cab37a93aa..03f5b60049 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -77,6 +77,7 @@ import java.util.Collections; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -633,6 +634,17 @@ public class Queue extends ResourceController implements Saveable { return new ArrayList(pendings.values()); } + /** + * Gets all items that are in the queue but not blocked + */ + synchronized ItemList getUnblockedItems() { + ItemList queuedNotBlocked = new ItemList(); + queuedNotBlocked.addAll(waitingList); + queuedNotBlocked.addAll(pendings); + queuedNotBlocked.addAll(buildables); + return queuedNotBlocked; + } + /** * Is the given task currently pending execution? */ @@ -1557,7 +1569,7 @@ public class Queue extends ResourceController implements Saveable { /** * {@link ArrayList} of {@link Item} with more convenience methods. */ - private static class ItemList extends ArrayList { + static class ItemList extends ArrayList { public T get(Task task) { for (T item: this) { if (item.task == task) { -- GitLab From 6de6353aebdb7406b4a4a76f09d15256f66fee7f Mon Sep 17 00:00:00 2001 From: Robert Elliot Date: Fri, 4 Mar 2011 07:54:01 +0000 Subject: [PATCH 0711/2361] Changed logic to build list of unblocked items in the queue safely so it will not break if a new category of queue items is added --- .../main/java/hudson/model/AbstractProject.java | 14 +++++++------- core/src/main/java/hudson/model/Queue.java | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 5d8e237ca3..f09655c600 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -43,6 +43,7 @@ import hudson.model.Cause.UserCause; import hudson.model.Descriptor.FormException; import hudson.model.Fingerprint.RangeSet; import hudson.model.Queue.Executable; +import hudson.model.Queue.ItemList; import hudson.model.Queue.Task; import hudson.model.queue.SubTask; import hudson.model.Queue.WaitingItem; @@ -1074,8 +1075,8 @@ public abstract class AbstractProject

        ,R extends A } /** - * Returns the project if any of the downstream project (or itself) is either - * building or is in the queue. + * Returns the project if any of the downstream project is either + * building, waiting, pending or buildable. *

        * This means eventually there will be an automatic triggering of * the given project (provided that all builds went smoothly.) @@ -1084,16 +1085,16 @@ public abstract class AbstractProject

        ,R extends A DependencyGraph graph = Hudson.getInstance().getDependencyGraph(); Set tups = graph.getTransitiveDownstream(this); Queue queue = Hudson.getInstance().getQueue(); - + ItemList unblockedItems = queue.getUnblockedItems(); for (AbstractProject tup : tups) { - if(tup.isBuilding() || queue.getUnblockedItems().containsKey(tup)) + if(tup.isBuilding() || unblockedItems.containsKey(tup)) return tup; } return null; } /** - * Returns the project if any of the upstream project (or itself) is either + * Returns the project if any of the upstream project is either * building or is in the queue. *

        * This means eventually there will be an automatic triggering of @@ -1102,9 +1103,8 @@ public abstract class AbstractProject

        ,R extends A protected AbstractProject getBuildingUpstream() { DependencyGraph graph = Hudson.getInstance().getDependencyGraph(); Set tups = graph.getTransitiveUpstream(this); - tups.add(this); for (AbstractProject tup : tups) { - if(tup!=this && (tup.isBuilding() || tup.isInQueue())) + if(tup.isBuilding() || tup.isInQueue()) return tup; } return null; diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index 03f5b60049..9c6f4f3c32 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -639,9 +639,8 @@ public class Queue extends ResourceController implements Saveable { */ synchronized ItemList getUnblockedItems() { ItemList queuedNotBlocked = new ItemList(); - queuedNotBlocked.addAll(waitingList); - queuedNotBlocked.addAll(pendings); - queuedNotBlocked.addAll(buildables); + queuedNotBlocked.addAll(Arrays.asList(getItems())); + queuedNotBlocked.removeAll(blockedProjects); return queuedNotBlocked; } -- GitLab From 86d88e5e7b341c884b156185051945678ce81ae8 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 9 Mar 2011 13:03:28 -0800 Subject: [PATCH 0712/2361] [JENKINS-8929] follow up changes - AbstractProject.getBuildingUpstream/getBuildingDownstream() should be symmetric. - It's unlikely for us to add another category of items, so reverted getUnblockedItems() implementation to the older one that was more efficient. - ItemList was meant to be internal, so keep it as such, at least for now. --- .../java/hudson/model/AbstractProject.java | 19 ++++++------- core/src/main/java/hudson/model/Queue.java | 28 +++++++++++++++---- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index f09655c600..ad494bff6e 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -43,7 +43,6 @@ import hudson.model.Cause.UserCause; import hudson.model.Descriptor.FormException; import hudson.model.Fingerprint.RangeSet; import hudson.model.Queue.Executable; -import hudson.model.Queue.ItemList; import hudson.model.Queue.Task; import hudson.model.queue.SubTask; import hudson.model.Queue.WaitingItem; @@ -1082,12 +1081,10 @@ public abstract class AbstractProject

        ,R extends A * the given project (provided that all builds went smoothly.) */ protected AbstractProject getBuildingDownstream() { - DependencyGraph graph = Hudson.getInstance().getDependencyGraph(); - Set tups = graph.getTransitiveDownstream(this); - Queue queue = Hudson.getInstance().getQueue(); - ItemList unblockedItems = queue.getUnblockedItems(); - for (AbstractProject tup : tups) { - if(tup.isBuilding() || unblockedItems.containsKey(tup)) + Set unblockedTasks = Hudson.getInstance().getQueue().getUnblockedTasks(); + + for (AbstractProject tup : Hudson.getInstance().getDependencyGraph().getTransitiveDownstream(this)) { + if (tup!=this && (tup.isBuilding() || unblockedTasks.contains(tup))) return tup; } return null; @@ -1101,10 +1098,10 @@ public abstract class AbstractProject

        ,R extends A * the given project (provided that all builds went smoothly.) */ protected AbstractProject getBuildingUpstream() { - DependencyGraph graph = Hudson.getInstance().getDependencyGraph(); - Set tups = graph.getTransitiveUpstream(this); - for (AbstractProject tup : tups) { - if(tup.isBuilding() || tup.isInQueue()) + Set unblockedTasks = Hudson.getInstance().getQueue().getUnblockedTasks(); + + for (AbstractProject tup : Hudson.getInstance().getDependencyGraph().getTransitiveUpstream(this)) { + if (tup!=this && (tup.isBuilding() || unblockedTasks.contains(tup))) return tup; } return null; diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index 9c6f4f3c32..c5c933d0f4 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -76,6 +76,7 @@ import java.util.Collection; import java.util.Collections; import java.util.GregorianCalendar; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -636,14 +637,31 @@ public class Queue extends ResourceController implements Saveable { /** * Gets all items that are in the queue but not blocked + * + * @since 1.402 */ - synchronized ItemList getUnblockedItems() { - ItemList queuedNotBlocked = new ItemList(); - queuedNotBlocked.addAll(Arrays.asList(getItems())); - queuedNotBlocked.removeAll(blockedProjects); + public synchronized List getUnblockedItems() { + List queuedNotBlocked = new ArrayList(); + queuedNotBlocked.addAll(waitingList); + queuedNotBlocked.addAll(buildables); + queuedNotBlocked.addAll(pendings); + // but not 'blockedProjects' return queuedNotBlocked; } + /** + * Works just like {@link #getUnblockedItems()} but return tasks. + * + * @since 1.402 + */ + public synchronized Set getUnblockedTasks() { + List items = getUnblockedItems(); + Set unblockedTasks = new HashSet(items.size()); + for (Queue.Item t : items) + unblockedTasks.add(t.task); + return unblockedTasks; + } + /** * Is the given task currently pending execution? */ @@ -1568,7 +1586,7 @@ public class Queue extends ResourceController implements Saveable { /** * {@link ArrayList} of {@link Item} with more convenience methods. */ - static class ItemList extends ArrayList { + private static class ItemList extends ArrayList { public T get(Task task) { for (T item: this) { if (item.task == task) { -- GitLab From 05b9727edf1089b1c5e6e9461b4f62c71790065e Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 9 Mar 2011 13:07:08 -0800 Subject: [PATCH 0713/2361] recording JENKINS-8929 fix --- changelog.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.html b/changelog.html index c121a698e2..8085432822 100644 --- a/changelog.html +++ b/changelog.html @@ -60,6 +60,9 @@ Upcoming changes

        diff --git a/core/src/main/java/hudson/slaves/ComputerListener.java b/core/src/main/java/hudson/slaves/ComputerListener.java index e9861438d4..793b4ab73e 100644 --- a/core/src/main/java/hudson/slaves/ComputerListener.java +++ b/core/src/main/java/hudson/slaves/ComputerListener.java @@ -44,20 +44,43 @@ import java.io.IOException; */ public abstract class ComputerListener implements ExtensionPoint { /** - * Called before a {@link Computer} is brought online. + * Called before a {@link ComputerLauncher} is asked to launch a connection with {@link Computer}. * *

        * This enables you to do some configurable checks to see if we * want to bring this slave online or if there are considerations * that would keep us from doing so. * + *

        + * Throwing {@link AbortException} would let you veto the launch operation. Other thrown exceptions + * will also have the same effect, but their stack trace will be dumped, so they are meant for error situation. + * + * @param c + * Computer that's being launched. Never null. + * @param taskListener + * Connected to the slave console log. Useful for reporting progress/errors on a lengthy operation. + * Never null. * @throws AbortException * Exceptions will be recorded to the listener, and * the computer will not become online. * - * @since 1.400 + * @since 1.402 + */ + public void preLaunch(Computer c, TaskListener taskListener) throws IOException, InterruptedException { + } + + /** + * Called when a slave attempted to connect via {@link ComputerLauncher} but it failed. + * + * @param c + * Computer that was trying to launch. Never null. + * @param taskListener + * Connected to the slave console log. Useful for reporting progress/errors on a lengthy operation. + * Never null. + * + * @since 1.402 */ - public void allowOnline(Computer c) throws AbortException { + public void onLaunchFailure(Computer c, TaskListener taskListener) throws IOException, InterruptedException { } /** diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index e72898ac9e..3fd6beed57 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -192,7 +192,7 @@ public class SlaveComputer extends Computer { log.rewind(); try { for (ComputerListener cl : ComputerListener.all()) - cl.allowOnline(SlaveComputer.this); + cl.preLaunch(SlaveComputer.this, taskListener); launcher.launch(SlaveComputer.this, taskListener); return null; } catch (AbortException e) { @@ -207,8 +207,11 @@ public class SlaveComputer extends Computer { throw e; } } finally { - if (channel==null) + if (channel==null) { offlineCause = new OfflineCause.LaunchFailed(); + for (ComputerListener cl : ComputerListener.all()) + cl.onLaunchFailure(SlaveComputer.this, taskListener); + } } } }); -- GitLab From 01dd347fa0ec20129508e35d8526c3b0681f18f0 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 9 Mar 2011 17:26:21 -0800 Subject: [PATCH 0716/2361] Making pronoun customizable --- .../src/main/java/hudson/matrix/MatrixConfiguration.java | 3 ++- core/src/main/java/hudson/model/AbstractItem.java | 9 ++++++++- core/src/main/java/hudson/model/AbstractProject.java | 5 ++++- core/src/main/java/hudson/model/ExternalJob.java | 3 ++- core/src/main/java/hudson/model/Job.java | 4 +++- core/src/main/java/hudson/slaves/SlaveComputer.java | 1 + .../main/java/hudson/util/AlternativeUiTextProvider.java | 4 +++- maven-plugin/src/main/java/hudson/maven/MavenModule.java | 3 ++- 8 files changed, 25 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/matrix/MatrixConfiguration.java b/core/src/main/java/hudson/matrix/MatrixConfiguration.java index f9409ddce7..f80a4ac595 100644 --- a/core/src/main/java/hudson/matrix/MatrixConfiguration.java +++ b/core/src/main/java/hudson/matrix/MatrixConfiguration.java @@ -24,6 +24,7 @@ package hudson.matrix; import hudson.Util; +import hudson.util.AlternativeUiTextProvider; import hudson.util.DescribableList; import hudson.model.AbstractBuild; import hudson.model.Cause; @@ -200,7 +201,7 @@ public class MatrixConfiguration extends Project @Override public String getPronoun() { - return Messages.MatrixConfiguration_Pronoun(); + return AlternativeUiTextProvider.get(PRONOUN, this, Messages.MatrixConfiguration_Pronoun()); } @Override diff --git a/core/src/main/java/hudson/model/AbstractItem.java b/core/src/main/java/hudson/model/AbstractItem.java index 4208b84765..df287c0524 100644 --- a/core/src/main/java/hudson/model/AbstractItem.java +++ b/core/src/main/java/hudson/model/AbstractItem.java @@ -36,6 +36,8 @@ import hudson.model.listeners.SaveableListener; import hudson.security.AccessControlled; import hudson.security.Permission; import hudson.security.ACL; +import hudson.util.AlternativeUiTextProvider; +import hudson.util.AlternativeUiTextProvider.Message; import hudson.util.AtomicFileWriter; import hudson.util.IOException2; import org.apache.tools.ant.taskdefs.Copy; @@ -104,7 +106,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet * {@link Item}. Must start with a capital letter. */ public String getPronoun() { - return Messages.AbstractItem_Pronoun(); + return AlternativeUiTextProvider.get(PRONOUN, this, Messages.AbstractItem_Pronoun()); } @Exported @@ -500,4 +502,9 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName())); return item; } + + /** + * Replaceable pronoun of that points to a job. Defaults to "Job"/"Project" depending on the context. + */ + public static final Message PRONOUN = new Message(); } diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index ad494bff6e..a4456a7888 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -353,7 +353,7 @@ public abstract class AbstractProject

        ,R extends A */ @Override public String getPronoun() { - return Messages.AbstractProject_Pronoun(); + return AlternativeUiTextProvider.get(PRONOUN, this,Messages.AbstractProject_Pronoun()); } /** @@ -1920,6 +1920,9 @@ public abstract class AbstractProject

        ,R extends A */ public static final Permission ABORT = BUILD; + /** + * Replaceable "Build Now" text. + */ public static final Message BUILD_NOW_TEXT = new Message(); /** diff --git a/core/src/main/java/hudson/model/ExternalJob.java b/core/src/main/java/hudson/model/ExternalJob.java index 6953bdfa22..fcc939eb56 100644 --- a/core/src/main/java/hudson/model/ExternalJob.java +++ b/core/src/main/java/hudson/model/ExternalJob.java @@ -25,6 +25,7 @@ package hudson.model; import hudson.model.RunMap.Constructor; import hudson.Extension; +import hudson.util.AlternativeUiTextProvider; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @@ -110,7 +111,7 @@ public class ExternalJob extends ViewJob implements Top @Override public String getPronoun() { - return Messages.ExternalJob_Pronoun(); + return AlternativeUiTextProvider.get(PRONOUN, this, Messages.ExternalJob_Pronoun()); } public static final class DescriptorImpl extends TopLevelItemDescriptor { diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 8991cf7c25..89fe3266f1 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -42,6 +42,8 @@ import hudson.search.SearchItem; import hudson.search.SearchItems; import hudson.security.ACL; import hudson.tasks.LogRotator; +import hudson.util.AlternativeUiTextProvider; +import hudson.util.AlternativeUiTextProvider.Message; import hudson.util.ChartUtil; import hudson.util.ColorPalette; import hudson.util.CopyOnWriteList; @@ -242,7 +244,7 @@ public abstract class Job, RunT extends Run * Context object type. Use {@link Void} to indicate that there's no context. */ - public static class Message { + public static final class Message { // decided not to retain T as Class so that we can have Message>, for example. /** diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModule.java b/maven-plugin/src/main/java/hudson/maven/MavenModule.java index 59de43e742..dc1cf24bc4 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModule.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModule.java @@ -44,6 +44,7 @@ import hudson.model.Saveable; import hudson.tasks.LogRotator; import hudson.tasks.Publisher; import hudson.tasks.Maven.MavenInstallation; +import hudson.util.AlternativeUiTextProvider; import hudson.util.DescribableList; import org.apache.maven.project.MavenProject; import org.kohsuke.stapler.StaplerRequest; @@ -314,7 +315,7 @@ public final class MavenModule extends AbstractMavenProject Date: Wed, 9 Mar 2011 17:55:44 -0800 Subject: [PATCH 0717/2361] This column is showing the name --- core/src/main/resources/hudson/views/Messages.properties | 2 +- core/src/main/resources/hudson/views/Messages_da.properties | 1 - core/src/main/resources/hudson/views/Messages_de.properties | 1 - core/src/main/resources/hudson/views/Messages_es.properties | 1 - core/src/main/resources/hudson/views/Messages_ja.properties | 2 +- core/src/main/resources/hudson/views/Messages_pt_BR.properties | 2 -- 6 files changed, 2 insertions(+), 7 deletions(-) diff --git a/core/src/main/resources/hudson/views/Messages.properties b/core/src/main/resources/hudson/views/Messages.properties index b8ee8646a0..eef88e7266 100644 --- a/core/src/main/resources/hudson/views/Messages.properties +++ b/core/src/main/resources/hudson/views/Messages.properties @@ -21,7 +21,7 @@ # THE SOFTWARE. BuildButtonColumn.DisplayName=Build Button -JobColumn.DisplayName=Job +JobColumn.DisplayName=Name LastDurationColumn.DisplayName=Last Duration LastFailureColumn.DisplayName=Last Failure LastStableColumn.DisplayName=Last Stable diff --git a/core/src/main/resources/hudson/views/Messages_da.properties b/core/src/main/resources/hudson/views/Messages_da.properties index 8f3108b06a..2a83f55fc2 100644 --- a/core/src/main/resources/hudson/views/Messages_da.properties +++ b/core/src/main/resources/hudson/views/Messages_da.properties @@ -27,4 +27,3 @@ WeatherColumn.DisplayName=Vejrudsigt LastSuccessColumn.DisplayName=Seneste succes LastFailureColumn.DisplayName=Seneste fejlede LastStableColumn.DisplayName=Seneste stabile -JobColumn.DisplayName=Job diff --git a/core/src/main/resources/hudson/views/Messages_de.properties b/core/src/main/resources/hudson/views/Messages_de.properties index de687ac54f..c030ebc410 100644 --- a/core/src/main/resources/hudson/views/Messages_de.properties +++ b/core/src/main/resources/hudson/views/Messages_de.properties @@ -21,7 +21,6 @@ # THE SOFTWARE. BuildButtonColumn.DisplayName=Build-Schaltflche -JobColumn.DisplayName=Job LastDurationColumn.DisplayName=Letzte Dauer LastFailureColumn.DisplayName=Letzter Fehlschlag LastStableColumn.DisplayName=Letzter stabiler Build diff --git a/core/src/main/resources/hudson/views/Messages_es.properties b/core/src/main/resources/hudson/views/Messages_es.properties index 970f80ec23..4f500856f6 100644 --- a/core/src/main/resources/hudson/views/Messages_es.properties +++ b/core/src/main/resources/hudson/views/Messages_es.properties @@ -21,7 +21,6 @@ # THE SOFTWARE. BuildButtonColumn.DisplayName=Botn de ejecucin -JobColumn.DisplayName=Tarea LastDurationColumn.DisplayName=ltima duracin LastFailureColumn.DisplayName=ltimo fallo LastStableColumn.DisplayName=ltimo estable diff --git a/core/src/main/resources/hudson/views/Messages_ja.properties b/core/src/main/resources/hudson/views/Messages_ja.properties index 35c728fee8..2cac213423 100644 --- a/core/src/main/resources/hudson/views/Messages_ja.properties +++ b/core/src/main/resources/hudson/views/Messages_ja.properties @@ -21,7 +21,7 @@ # THE SOFTWARE. BuildButtonColumn.DisplayName=\u30D3\u30EB\u30C9\u30DC\u30BF\u30F3 -JobColumn.DisplayName=\u30B8\u30E7\u30D6 +JobColumn.DisplayName=\u540D\u524D LastDurationColumn.DisplayName=\u30D3\u30EB\u30C9\u6240\u8981\u6642\u9593 LastFailureColumn.DisplayName=\u6700\u65B0\u306E\u5931\u6557\u30D3\u30EB\u30C9 LastStableColumn.DisplayName=\u6700\u65B0\u306E\u5B89\u5B9A\u30D3\u30EB\u30C9 diff --git a/core/src/main/resources/hudson/views/Messages_pt_BR.properties b/core/src/main/resources/hudson/views/Messages_pt_BR.properties index c92238bb7c..3430c688e9 100644 --- a/core/src/main/resources/hudson/views/Messages_pt_BR.properties +++ b/core/src/main/resources/hudson/views/Messages_pt_BR.properties @@ -34,5 +34,3 @@ LastSuccessColumn.DisplayName=\u00daltimo sucesso LastFailureColumn.DisplayName=\u00daltima falha # Last Stable LastStableColumn.DisplayName=\u00daltimo est\u00e1vel -# Job -JobColumn.DisplayName=Tarefa -- GitLab From 054f74389046793f1bf392cfdd6c1eaa1154175d Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Thu, 10 Mar 2011 09:36:41 +0000 Subject: [PATCH 0718/2361] upping the version so that we can rebuild on a ci system --- cli/pom.xml | 2 +- core/pom.xml | 2 +- maven-agent/pom.xml | 2 +- maven-interceptor/pom.xml | 2 +- maven-plugin/pom.xml | 2 +- maven3-agent/pom.xml | 2 +- maven3-interceptor/pom.xml | 2 +- pom.xml | 2 +- remoting/pom.xml | 2 +- test/pom.xml | 2 +- ui-samples-plugin/pom.xml | 2 +- war/pom.xml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index f04bea1c9d..0a4dc0dc97 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -4,7 +4,7 @@ pom org.jenkins-ci.main - 1.400 + 1.400.0-SNAPSHOT cli Jenkins CLI diff --git a/core/pom.xml b/core/pom.xml index c0b8fc12d9..44f0e923ad 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT ../pom.xml diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index 3e04a3fbbf..8c5b1fd545 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT ../pom.xml diff --git a/maven-interceptor/pom.xml b/maven-interceptor/pom.xml index ed6655de3b..f835d9b00e 100644 --- a/maven-interceptor/pom.xml +++ b/maven-interceptor/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT ../pom.xml diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 0040231c35..558a5c594a 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT maven-plugin diff --git a/maven3-agent/pom.xml b/maven3-agent/pom.xml index ed5d21aa85..184d710f88 100755 --- a/maven3-agent/pom.xml +++ b/maven3-agent/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT maven3-agent Jenkins Maven3 CLI Agent diff --git a/maven3-interceptor/pom.xml b/maven3-interceptor/pom.xml index 1d69a38236..9061c0134a 100755 --- a/maven3-interceptor/pom.xml +++ b/maven3-interceptor/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT maven3-interceptor Jenkins Maven3 Interceptor diff --git a/pom.xml b/pom.xml index 1cbd6412a6..329d1ca7ea 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT pom Jenkins main module diff --git a/remoting/pom.xml b/remoting/pom.xml index c58415f811..ece0c94b53 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT ../pom.xml diff --git a/test/pom.xml b/test/pom.xml index 31a7740f52..98530864b7 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. pom org.jenkins-ci.main - 1.400 + 1.400.0-SNAPSHOT 4.0.0 org.jenkins-ci.main diff --git a/ui-samples-plugin/pom.xml b/ui-samples-plugin/pom.xml index b7de3d28a1..2e191386cc 100644 --- a/ui-samples-plugin/pom.xml +++ b/ui-samples-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT ui-samples-plugin diff --git a/war/pom.xml b/war/pom.xml index b28cddda86..c7df7df710 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.400 + 1.400.0-SNAPSHOT ../pom.xml -- GitLab From b33dfa88f8a2bffe8a6588a0948ea972be59f589 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 10 Mar 2011 10:37:55 -0800 Subject: [PATCH 0719/2361] Integrated JavaScript proxy support. --- core/pom.xml | 2 +- .../plugins/ui_samples/JavaScriptProxy.java | 32 +++++++++++++ .../ui_samples/JavaScriptProxy/index.jelly | 45 +++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 ui-samples-plugin/src/main/java/hudson/plugins/ui_samples/JavaScriptProxy.java create mode 100644 ui-samples-plugin/src/main/resources/hudson/plugins/ui_samples/JavaScriptProxy/index.jelly diff --git a/core/pom.xml b/core/pom.xml index 29f777bab8..e8cf323005 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -382,7 +382,7 @@ THE SOFTWARE. org.kohsuke.stapler stapler-jelly - 1.155 + 1.157 commons-jelly diff --git a/ui-samples-plugin/src/main/java/hudson/plugins/ui_samples/JavaScriptProxy.java b/ui-samples-plugin/src/main/java/hudson/plugins/ui_samples/JavaScriptProxy.java new file mode 100644 index 0000000000..33a90f6d54 --- /dev/null +++ b/ui-samples-plugin/src/main/java/hudson/plugins/ui_samples/JavaScriptProxy.java @@ -0,0 +1,32 @@ +package hudson.plugins.ui_samples; + +import hudson.Extension; +import org.kohsuke.stapler.bind.JavaScriptMethod; + +/** + * "Export" Java objects to JavaScript in the browser as a proxy object, so that + * you can make ajax-calls to the server later. + * + * @author Kohsuke Kawaguchi + */ +@Extension +public class JavaScriptProxy extends UISample { + private int i; + + @Override + public String getDescription() { + return "Use JavaScript proxy objects to access server-side Java objects from inside the browser."; + } + + /** + * The annotation exposes this method to JavaScript proxy. + */ + @JavaScriptMethod + public int increment(int n) { + return i+=n; + } + + @Extension + public static final class DescriptorImpl extends UISampleDescriptor { + } +} diff --git a/ui-samples-plugin/src/main/resources/hudson/plugins/ui_samples/JavaScriptProxy/index.jelly b/ui-samples-plugin/src/main/resources/hudson/plugins/ui_samples/JavaScriptProxy/index.jelly new file mode 100644 index 0000000000..7192bbca48 --- /dev/null +++ b/ui-samples-plugin/src/main/resources/hudson/plugins/ui_samples/JavaScriptProxy/index.jelly @@ -0,0 +1,45 @@ + + + + +

        + In Jenkins, you can export arbitrary server-side Java object to JavaScript via a proxy, + then invoke their methods from JavaScript. See the Wiki for more details. + In this sample, we call a method on the server to increment a counter. This object is a singleton, + so you'll see the same counter value across all the browsers. +

        + + + +
        + + + -- GitLab From 35023af76c40254826b1a4d6cdcb49a040662645 Mon Sep 17 00:00:00 2001 From: Paul Weiss Date: Thu, 10 Mar 2011 13:25:34 -0500 Subject: [PATCH 0720/2361] Fix bug JENKINS-9006: don't fail an email if only one of the recipients is bad. --- core/src/main/java/hudson/tasks/MailSender.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/src/main/java/hudson/tasks/MailSender.java b/core/src/main/java/hudson/tasks/MailSender.java index 155a99f01c..ae4786d794 100644 --- a/core/src/main/java/hudson/tasks/MailSender.java +++ b/core/src/main/java/hudson/tasks/MailSender.java @@ -412,4 +412,15 @@ public class MailSender { * Sometimes the outcome of the previous build affects the e-mail we send, hence this checkpoint. */ private static final CheckPoint CHECKPOINT = new CheckPoint("mail sent"); + + static { + // Fix JENKINS-9006 + // When sending to multiple recipients, send to valid recipients even if some are + // invalid, unless we have explicitly said otherwise. + for (String property: Arrays.asList("mail.smtp.sendpartial", "mail.smtps.sendpartial")) { + if (System.getProperty(property) == null) { + System.setProperty(property, "true"); + } + } + } } -- GitLab From 888b9d368373fce964057cc119aee164f9f037a0 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 10 Mar 2011 21:29:16 +0100 Subject: [PATCH 0721/2361] [JENKINS-9006] update changelog --- changelog.html | 3 +++ core/src/main/java/hudson/Launcher.java | 2 +- test/pom.xml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.html b/changelog.html index 230cba4155..87d17d3742 100644 --- a/changelog.html +++ b/changelog.html @@ -76,6 +76,9 @@ Upcoming changes diff --git a/core/src/main/java/hudson/tasks/test/AggregatedTestResultPublisher.java b/core/src/main/java/hudson/tasks/test/AggregatedTestResultPublisher.java index 561abb1cc4..5ffa2d9368 100644 --- a/core/src/main/java/hudson/tasks/test/AggregatedTestResultPublisher.java +++ b/core/src/main/java/hudson/tasks/test/AggregatedTestResultPublisher.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Michael B. Donohue, Yahoo!, Inc. + * Copyright (c) 2004-2011, Sun Microsystems, Inc., Kohsuke Kawaguchi, Michael B. Donohue, Yahoo!, Inc., Andrew Bayer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -68,13 +68,23 @@ public class AggregatedTestResultPublisher extends Recorder { */ public final String jobs; + /** + * Should failed builds be included? + */ + public final boolean includeFailedBuilds; + public AggregatedTestResultPublisher(String jobs) { + this(jobs, false); + } + + public AggregatedTestResultPublisher(String jobs, boolean includeFailedBuilds) { this.jobs = Util.fixEmptyAndTrim(jobs); + this.includeFailedBuilds = includeFailedBuilds; } public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { // add a TestResult just so that it can show up later. - build.addAction(new TestResultAction(jobs,build)); + build.addAction(new TestResultAction(jobs,includeFailedBuilds,build)); return true; } @@ -95,6 +105,11 @@ public class AggregatedTestResultPublisher extends Recorder { */ private final String jobs; + /** + * Should failed builds be included? + */ + private final boolean includeFailedBuilds; + /** * The last time the fields of this object is computed from the rest. */ @@ -113,8 +128,10 @@ public class AggregatedTestResultPublisher extends Recorder { private transient List didntRun; private transient List noFingerprints; - public TestResultAction(String jobs, AbstractBuild owner) { + public TestResultAction(String jobs, boolean includeFailedBuilds, AbstractBuild owner) { super(owner); + this.includeFailedBuilds = includeFailedBuilds; + if(jobs==null) { // resolve null as the transitive downstream jobs StringBuilder buf = new StringBuilder(); @@ -140,6 +157,10 @@ public class AggregatedTestResultPublisher extends Recorder { return r; } + public boolean getIncludeFailedBuilds() { + return includeFailedBuilds; + } + private AbstractProject getProject() { return owner.getProject(); } @@ -224,7 +245,12 @@ public class AggregatedTestResultPublisher extends Recorder { RangeSet rs = owner.getDownstreamRelationship(job); if(rs.isEmpty()) { // is this job expected to produce a test result? - Run b = job.getLastSuccessfulBuild(); + Run b; + if (includeFailedBuilds) { + b = job.getLastBuild(); + } else { + b = job.getLastSuccessfulBuild(); + } if(b!=null && b.getAction(AbstractTestResultAction.class)!=null) { if(b.getAction(FingerprintAction.class)!=null) { didntRun.add(job); @@ -236,7 +262,14 @@ public class AggregatedTestResultPublisher extends Recorder { for (int n : rs.listNumbersReverse()) { Run b = job.getBuildByNumber(n); if(b==null) continue; - if(b.isBuilding() || b.getResult().isWorseThan(Result.UNSTABLE)) + Result targetResult; + if (includeFailedBuilds) { + targetResult = Result.FAILURE; + } else { + targetResult = Result.UNSTABLE; + } + + if(b.isBuilding() || b.getResult().isWorseThan(targetResult)) continue; // don't count them for( AbstractTestResultAction ta : b.getActions(AbstractTestResultAction.class)) { diff --git a/core/src/main/resources/hudson/tasks/test/AggregatedTestResultPublisher/config.jelly b/core/src/main/resources/hudson/tasks/test/AggregatedTestResultPublisher/config.jelly index 8ca661d2ea..913f136635 100644 --- a/core/src/main/resources/hudson/tasks/test/AggregatedTestResultPublisher/config.jelly +++ b/core/src/main/resources/hudson/tasks/test/AggregatedTestResultPublisher/config.jelly @@ -1,7 +1,7 @@ diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index a4456a7888..1b6ac2cf5c 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -1,10 +1,10 @@ /* * The MIT License * - * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, + * Copyright (c) 2004-2011, Sun Microsystems, Inc., Kohsuke Kawaguchi, * Brian Westrich, Erik Ramfelt, Ertan Deniz, Jean-Baptiste Quenot, * Luca Domenico Milanesio, R. Tyler Ballance, Stephen Connolly, Tom Huybrechts, - * id:cactusman, Yahoo! Inc. + * id:cactusman, Yahoo! Inc., Andrew Bayer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -1836,7 +1836,20 @@ public abstract class AbstractProject

        ,R extends A return FormValidation.ok(); } - public AutoCompletionCandidates doAutoCompleteAssignedLabelString(@QueryParameter String value) { + public AutoCompletionCandidates doAutoCompleteUpstreamProjects(@QueryParameter String value) { + AutoCompletionCandidates candidates = new AutoCompletionCandidates(); + List jobs = Hudson.getInstance().getItems(Job.class); + for (Job job: jobs) { + if (job.getFullName().startsWith(value)) { + if (job.hasPermission(Item.READ)) { + candidates.add(job.getFullName()); + } + } + } + return candidates; + } + + public AutoCompletionCandidates doAutoCompleteAssignedLabelString(@QueryParameter String value) { AutoCompletionCandidates c = new AutoCompletionCandidates(); Set

      • Added autocompletion to "Build after other projects" textbox, with support for "autoCompleteField" on textboxes without a true field. +
      • + Include OS type and version of slave in the system information page. + (issue 8996)
      diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index 8fe3c9430d..ec6baa5354 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -514,6 +514,20 @@ public class SlaveComputer extends Computer { return ((Slave)node).getLauncher(); } + /** + * Get the slave version + */ + public String getSlaveVersion() throws IOException, InterruptedException { + return channel.call(new SlaveVersion()); + } + + /** + * Get the OS description. + */ + public String getOSDescription() throws IOException, InterruptedException { + return channel.call(new DetectOS()) ? "Unix" : "Windows"; + } + private static final Logger logger = Logger.getLogger(SlaveComputer.class.getName()); private static final class SlaveVersion implements Callable { diff --git a/core/src/main/resources/hudson/slaves/SlaveComputer/systemInfo.jelly b/core/src/main/resources/hudson/slaves/SlaveComputer/systemInfo.jelly index 50a4091c2d..1ea94c9938 100644 --- a/core/src/main/resources/hudson/slaves/SlaveComputer/systemInfo.jelly +++ b/core/src/main/resources/hudson/slaves/SlaveComputer/systemInfo.jelly @@ -33,6 +33,7 @@ THE SOFTWARE. +

      ${it.oSDescription} slave, version ${it.slaveVersion}

      ${%System Properties}

      ${%Environment Variables}

      -- GitLab From 5e3000fe1bedd49e582a6f6e73d5008ba84953d3 Mon Sep 17 00:00:00 2001 From: Andrew Bayer Date: Sun, 13 Mar 2011 15:21:27 -0700 Subject: [PATCH 0769/2361] Fixing setting of includeFailedBuilds on aggregated test results. --- .../java/hudson/tasks/test/AggregatedTestResultPublisher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/tasks/test/AggregatedTestResultPublisher.java b/core/src/main/java/hudson/tasks/test/AggregatedTestResultPublisher.java index 82647b95d8..6ec7ee4616 100644 --- a/core/src/main/java/hudson/tasks/test/AggregatedTestResultPublisher.java +++ b/core/src/main/java/hudson/tasks/test/AggregatedTestResultPublisher.java @@ -346,9 +346,9 @@ public class AggregatedTestResultPublisher extends Recorder { public AggregatedTestResultPublisher newInstance(StaplerRequest req, JSONObject formData) throws FormException { JSONObject s = formData.getJSONObject("specify"); if(s.isNullObject()) - return new AggregatedTestResultPublisher(null); + return new AggregatedTestResultPublisher(null, req.getParameter("includeFailedBuilds") != null); else - return new AggregatedTestResultPublisher(s.getString("jobs")); + return new AggregatedTestResultPublisher(s.getString("jobs"), req.getParameter("includeFailedBuilds") != null); } public AutoCompletionCandidates doAutoCompleteJobs(@QueryParameter String value) { -- GitLab From 192a22dbcb99aba989c4b9faf9f431eb00f156c6 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 13 Mar 2011 20:33:57 -0700 Subject: [PATCH 0770/2361] [maven-release-plugin] prepare release jenkins-1_401 --- cli/pom.xml | 2 +- core/pom.xml | 2 +- maven-agent/pom.xml | 2 +- maven-interceptor/pom.xml | 2 +- maven-plugin/pom.xml | 2 +- maven3-agent/pom.xml | 2 +- maven3-interceptor/pom.xml | 2 +- pom.xml | 2 +- remoting/pom.xml | 2 +- test/pom.xml | 2 +- ui-samples-plugin/pom.xml | 2 +- war/pom.xml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index b449b42e3e..82c134d8e3 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -4,7 +4,7 @@ pom org.jenkins-ci.main - 1.401-SNAPSHOT + 1.401 cli Jenkins CLI diff --git a/core/pom.xml b/core/pom.xml index 626ee57e92..6c4abdacc8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 ../pom.xml diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index f1a7bbb733..67ec178e8b 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 ../pom.xml diff --git a/maven-interceptor/pom.xml b/maven-interceptor/pom.xml index c83a20fcf8..c467e22d4c 100644 --- a/maven-interceptor/pom.xml +++ b/maven-interceptor/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 ../pom.xml diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 39d464d099..eb8b7f8a35 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 maven-plugin diff --git a/maven3-agent/pom.xml b/maven3-agent/pom.xml index 8702aeb023..811a1b5a64 100755 --- a/maven3-agent/pom.xml +++ b/maven3-agent/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 maven3-agent Jenkins Maven3 CLI Agent diff --git a/maven3-interceptor/pom.xml b/maven3-interceptor/pom.xml index 915fd0ea46..4c0c019a46 100755 --- a/maven3-interceptor/pom.xml +++ b/maven3-interceptor/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 maven3-interceptor Jenkins Maven3 Interceptor diff --git a/pom.xml b/pom.xml index 86cd7d273d..f114af145e 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 pom Jenkins main module diff --git a/remoting/pom.xml b/remoting/pom.xml index 9c208d3baa..8980b4082f 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 ../pom.xml diff --git a/test/pom.xml b/test/pom.xml index 5325fa2618..d12a3c1e0c 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. pom org.jenkins-ci.main - 1.401-SNAPSHOT + 1.401 4.0.0 org.jenkins-ci.main diff --git a/ui-samples-plugin/pom.xml b/ui-samples-plugin/pom.xml index f89cc6707f..7826be3b67 100644 --- a/ui-samples-plugin/pom.xml +++ b/ui-samples-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 ui-samples-plugin diff --git a/war/pom.xml b/war/pom.xml index e0f828927e..292838a2f2 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401-SNAPSHOT + 1.401 ../pom.xml -- GitLab From 253edbcc99f1709b05bf85fed0b4da436ea54872 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 13 Mar 2011 20:33:58 -0700 Subject: [PATCH 0771/2361] [maven-release-plugin] prepare for next development iteration --- cli/pom.xml | 2 +- core/pom.xml | 2 +- maven-agent/pom.xml | 2 +- maven-interceptor/pom.xml | 2 +- maven-plugin/pom.xml | 2 +- maven3-agent/pom.xml | 2 +- maven3-interceptor/pom.xml | 2 +- pom.xml | 2 +- remoting/pom.xml | 2 +- test/pom.xml | 2 +- ui-samples-plugin/pom.xml | 2 +- war/pom.xml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 82c134d8e3..8072d390dd 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -4,7 +4,7 @@ pom org.jenkins-ci.main - 1.401 + 1.402-SNAPSHOT cli Jenkins CLI diff --git a/core/pom.xml b/core/pom.xml index 6c4abdacc8..29f777bab8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT ../pom.xml diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index 67ec178e8b..7b4464f5e2 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT ../pom.xml diff --git a/maven-interceptor/pom.xml b/maven-interceptor/pom.xml index c467e22d4c..64179b648a 100644 --- a/maven-interceptor/pom.xml +++ b/maven-interceptor/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT ../pom.xml diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index eb8b7f8a35..51d138409f 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT maven-plugin diff --git a/maven3-agent/pom.xml b/maven3-agent/pom.xml index 811a1b5a64..66a9b72773 100755 --- a/maven3-agent/pom.xml +++ b/maven3-agent/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT maven3-agent Jenkins Maven3 CLI Agent diff --git a/maven3-interceptor/pom.xml b/maven3-interceptor/pom.xml index 4c0c019a46..b34ed92a13 100755 --- a/maven3-interceptor/pom.xml +++ b/maven3-interceptor/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT maven3-interceptor Jenkins Maven3 Interceptor diff --git a/pom.xml b/pom.xml index f114af145e..9211d24bc0 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT pom Jenkins main module diff --git a/remoting/pom.xml b/remoting/pom.xml index 8980b4082f..7491292e9b 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT ../pom.xml diff --git a/test/pom.xml b/test/pom.xml index d12a3c1e0c..d335d5cb01 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. pom org.jenkins-ci.main - 1.401 + 1.402-SNAPSHOT 4.0.0 org.jenkins-ci.main diff --git a/ui-samples-plugin/pom.xml b/ui-samples-plugin/pom.xml index 7826be3b67..ca5d5be9fc 100644 --- a/ui-samples-plugin/pom.xml +++ b/ui-samples-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT ui-samples-plugin diff --git a/war/pom.xml b/war/pom.xml index 292838a2f2..d99be6c940 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.401 + 1.402-SNAPSHOT ../pom.xml -- GitLab From c649fb7c4a372c7a8aea440ce1b7f0525d612c10 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 13 Mar 2011 20:55:22 -0700 Subject: [PATCH 0772/2361] updated changelog for release --- changelog.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/changelog.html b/changelog.html index c926905eb5..92ebcbe5f1 100644 --- a/changelog.html +++ b/changelog.html @@ -66,7 +66,10 @@ Upcoming changes +

      What's new in 1.401 (2011/03/13)

      • Fix for JENKINS-8711 breaks deployments with credentials @@ -92,7 +95,6 @@ Upcoming changes Defined a mechanism to replace some of the key UI text. (issue 8579)
      -

      What's new in 1.400 (2011/03/06)

      • -- GitLab From e0ea40629edd8d30b07f4041d15a59c05d5b7d79 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 13 Mar 2011 20:55:22 -0700 Subject: [PATCH 0773/2361] releasing a new plugin parent POM --- plugins/pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/pom.xml b/plugins/pom.xml index 34fef323d9..b413f0aff4 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -10,7 +10,7 @@ org.jenkins-ci.plugins plugin Jenkins plugin POM - 1.401-SNAPSHOT + 1.401 pom @@ -38,7 +38,7 @@ org.jenkins-ci.main maven-plugin - 1.401-SNAPSHOT + 1.401 @@ -48,25 +48,25 @@ org.jenkins-ci.main jenkins-war war - 1.401-SNAPSHOT + 1.401 test org.jenkins-ci.main jenkins-core - 1.401-SNAPSHOT + 1.401 provided org.jenkins-ci.main jenkins-test-harness - 1.401-SNAPSHOT + 1.401 test org.jenkins-ci.main ui-samples-plugin - 1.401-SNAPSHOT + 1.401 test -- GitLab From f94d8deb5dd6c9ee889f24708b8490fe0d3eeab0 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 13 Mar 2011 20:55:27 -0700 Subject: [PATCH 0774/2361] toward the next release --- plugins/pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/pom.xml b/plugins/pom.xml index b413f0aff4..644a33e645 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -10,7 +10,7 @@ org.jenkins-ci.plugins plugin Jenkins plugin POM - 1.401 + 1.402-SNAPSHOT pom @@ -38,7 +38,7 @@ org.jenkins-ci.main maven-plugin - 1.401 + 1.402-SNAPSHOT @@ -48,25 +48,25 @@ org.jenkins-ci.main jenkins-war war - 1.401 + 1.402-SNAPSHOT test org.jenkins-ci.main jenkins-core - 1.401 + 1.402-SNAPSHOT provided org.jenkins-ci.main jenkins-test-harness - 1.401 + 1.402-SNAPSHOT test org.jenkins-ci.main ui-samples-plugin - 1.401 + 1.402-SNAPSHOT test -- GitLab From 324568764598a3b85f74c5cb8f0c8a20a9f167ef Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 13 Mar 2011 20:58:35 -0700 Subject: [PATCH 0775/2361] updated changelog as a part of the release --- debian/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/debian/changelog b/debian/debian/changelog index e3d9ff6d54..2917667684 100644 --- a/debian/debian/changelog +++ b/debian/debian/changelog @@ -1,3 +1,9 @@ +jenkins (1.401) unstable; urgency=low + + * See http://jenkins-ci.org/changelog for more details. + + -- Kohsuke Kawaguchi Sun, 13 Mar 2011 20:56:10 -0700 + jenkins (1.400) unstable; urgency=low * See http://jenkins-ci.org/changelog for more details. -- GitLab From 7d46b22599c6001eaeff7f47715fa80491b3fdd5 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 14 Mar 2011 14:03:40 +0100 Subject: [PATCH 0776/2361] [JENKINS-7535] Rebuilding dependency graph slow on large installations Submitted by evernat. --- .../main/java/hudson/maven/MavenModule.java | 10 ++++++---- .../java/hudson/maven/ModuleDependency.java | 20 ++++++++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModule.java b/maven-plugin/src/main/java/hudson/maven/MavenModule.java index dc1cf24bc4..a19d13c792 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModule.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModule.java @@ -392,8 +392,9 @@ public final class MavenModule extends AbstractMavenProject Date: Mon, 14 Mar 2011 15:41:42 +0100 Subject: [PATCH 0777/2361] minor fix for German localization --- .../main/resources/hudson/model/Hudson/configure_de.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/hudson/model/Hudson/configure_de.properties b/core/src/main/resources/hudson/model/Hudson/configure_de.properties index 7ae893b638..c62709d81b 100644 --- a/core/src/main/resources/hudson/model/Hudson/configure_de.properties +++ b/core/src/main/resources/hudson/model/Hudson/configure_de.properties @@ -36,7 +36,7 @@ Authorization=Rechtevergabe Save=bernehmen \#\ of\ executors=Anzahl Build-Prozessoren Labels=Labels -SCM\ checkout\ retry\ count=Wartezeit zwischen SCM-Checkout-Versuchen +SCM\ checkout\ retry\ count=Anzahl der SCM-Checkout Wiederholungen Prevent\ Cross\ Site\ Request\ Forgery\ exploits="Cross Site Request Forgery"-Angriffe verhindern Crumbs=Crumbs Crumb\ Algorithm=Crumb-Algorithmus -- GitLab From 9caa08791d55bb74f3a07c19ae784f148f28fb22 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 14 Mar 2011 08:48:17 -0700 Subject: [PATCH 0778/2361] creating an RC branch --- changelog.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/changelog.html b/changelog.html index 183dba0e36..625aa0bcf5 100644 --- a/changelog.html +++ b/changelog.html @@ -59,6 +59,14 @@ Upcoming changes + + + - - -

        What's new in 1.401 (2011/03/13)

          -- GitLab From 4e328c9f8abcd94caa4fdef65afca23384a79566 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 14 Mar 2011 08:48:20 -0700 Subject: [PATCH 0779/2361] the trunk is toward 1.403-SNAPSHOT --- cli/pom.xml | 2 +- core/pom.xml | 2 +- maven-agent/pom.xml | 2 +- maven-interceptor/pom.xml | 2 +- maven-plugin/pom.xml | 2 +- maven3-agent/pom.xml | 2 +- maven3-interceptor/pom.xml | 2 +- plugins/pom.xml | 12 ++++++------ pom.xml | 2 +- remoting/pom.xml | 2 +- test/pom.xml | 2 +- ui-samples-plugin/pom.xml | 2 +- war/pom.xml | 2 +- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 8072d390dd..8c06805e6f 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -4,7 +4,7 @@ pom org.jenkins-ci.main - 1.402-SNAPSHOT + 1.403-SNAPSHOT cli Jenkins CLI diff --git a/core/pom.xml b/core/pom.xml index 5dcb5f3812..f0d1ffd4fd 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT ../pom.xml diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index 7b4464f5e2..6574368cbc 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT ../pom.xml diff --git a/maven-interceptor/pom.xml b/maven-interceptor/pom.xml index 64179b648a..fefcafb14a 100644 --- a/maven-interceptor/pom.xml +++ b/maven-interceptor/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT ../pom.xml diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 72889a3e6d..6bc60fcde4 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT maven-plugin diff --git a/maven3-agent/pom.xml b/maven3-agent/pom.xml index 66a9b72773..f267c48c19 100755 --- a/maven3-agent/pom.xml +++ b/maven3-agent/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT maven3-agent Jenkins Maven3 CLI Agent diff --git a/maven3-interceptor/pom.xml b/maven3-interceptor/pom.xml index b34ed92a13..c196d73a4d 100755 --- a/maven3-interceptor/pom.xml +++ b/maven3-interceptor/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT maven3-interceptor Jenkins Maven3 Interceptor diff --git a/plugins/pom.xml b/plugins/pom.xml index 644a33e645..d59d12e44c 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -10,7 +10,7 @@ org.jenkins-ci.plugins plugin Jenkins plugin POM - 1.402-SNAPSHOT + 1.403-SNAPSHOT pom @@ -38,7 +38,7 @@ org.jenkins-ci.main maven-plugin - 1.402-SNAPSHOT + 1.403-SNAPSHOT @@ -48,25 +48,25 @@ org.jenkins-ci.main jenkins-war war - 1.402-SNAPSHOT + 1.403-SNAPSHOT test org.jenkins-ci.main jenkins-core - 1.402-SNAPSHOT + 1.403-SNAPSHOT provided org.jenkins-ci.main jenkins-test-harness - 1.402-SNAPSHOT + 1.403-SNAPSHOT test org.jenkins-ci.main ui-samples-plugin - 1.402-SNAPSHOT + 1.403-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 3c4f04e75b..c97dab2268 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT pom Jenkins main module diff --git a/remoting/pom.xml b/remoting/pom.xml index 7491292e9b..8152b1b0fc 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT ../pom.xml diff --git a/test/pom.xml b/test/pom.xml index 398804c7ae..3bff2bdc38 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. pom org.jenkins-ci.main - 1.402-SNAPSHOT + 1.403-SNAPSHOT 4.0.0 org.jenkins-ci.main diff --git a/ui-samples-plugin/pom.xml b/ui-samples-plugin/pom.xml index ca5d5be9fc..6adb9a5f2a 100644 --- a/ui-samples-plugin/pom.xml +++ b/ui-samples-plugin/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT ui-samples-plugin diff --git a/war/pom.xml b/war/pom.xml index d99be6c940..5f3aeaab87 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.402-SNAPSHOT + 1.403-SNAPSHOT ../pom.xml -- GitLab From 18eb94865ec119b1bc2b4674847042f908be9efc Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 14 Mar 2011 19:27:27 +0100 Subject: [PATCH 0780/2361] remove unused import --- .../java/hudson/maven/MavenModuleSetBuild.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 5e0bb7e8e3..04fe7d6252 100755 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -35,12 +35,25 @@ import hudson.Util; import hudson.maven.MavenBuild.ProxyImpl2; import hudson.maven.reporters.MavenFingerprinter; import hudson.maven.reporters.MavenMailer; -import hudson.model.*; +import hudson.model.AbstractProject; +import hudson.model.Action; +import hudson.model.Build; +import hudson.model.BuildListener; import hudson.model.Cause.UpstreamCause; +import hudson.model.Computer; +import hudson.model.Environment; +import hudson.model.Fingerprint; +import hudson.model.Hudson; +import hudson.model.ParameterDefinition; +import hudson.model.ParametersAction; +import hudson.model.ParametersDefinitionProperty; +import hudson.model.Result; +import hudson.model.Run; +import hudson.model.StringParameterDefinition; +import hudson.model.TaskListener; import hudson.remoting.Channel; import hudson.remoting.VirtualChannel; import hudson.scm.ChangeLogSet; -import hudson.slaves.NodeProperty; import hudson.tasks.BuildWrapper; import hudson.tasks.MailSender; import hudson.tasks.Maven.MavenInstallation; @@ -80,7 +93,6 @@ import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; import org.codehaus.plexus.util.PathTool; -import org.jenkinsci.plugins.tokenmacro.MacroEvaluationException; import org.jenkinsci.plugins.tokenmacro.TokenMacro; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -- GitLab From ee12b204d8d4e04364f81cb0470f68c4c73efbab Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 11 Mar 2011 18:50:31 -0800 Subject: [PATCH 0781/2361] Match the parent tag name, or else innerHTML assignment can create strange intermediate nodes. (For example, when we are inserting a number of s) --- war/src/main/webapp/scripts/hudson-behavior.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/war/src/main/webapp/scripts/hudson-behavior.js b/war/src/main/webapp/scripts/hudson-behavior.js index 3382f559ec..f5a6aabb95 100644 --- a/war/src/main/webapp/scripts/hudson-behavior.js +++ b/war/src/main/webapp/scripts/hudson-behavior.js @@ -433,7 +433,7 @@ function renderOnDemand(e,callback,noBehaviour) { if (!e || !Element.hasClassName(e,"render-on-demand")) return; var proxy = eval(e.getAttribute("proxy")); proxy.render(function (t) { - var c = document.createElement("div"); + var c = document.createElement(e.parentNode.tagName); c.innerHTML = t.responseText; while (c.firstChild!=null) { -- GitLab From cec116c76fb84896ab24d5b5fb0056aa6044c6c0 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 11 Mar 2011 18:51:19 -0800 Subject: [PATCH 0782/2361] Fragment can contain text and other stuff, not just elements. --- war/src/main/webapp/scripts/hudson-behavior.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/war/src/main/webapp/scripts/hudson-behavior.js b/war/src/main/webapp/scripts/hudson-behavior.js index f5a6aabb95..124bab0c1f 100644 --- a/war/src/main/webapp/scripts/hudson-behavior.js +++ b/war/src/main/webapp/scripts/hudson-behavior.js @@ -439,7 +439,8 @@ function renderOnDemand(e,callback,noBehaviour) { while (c.firstChild!=null) { var n = c.firstChild; e.parentNode.insertBefore(n,e); - noBehaviour || Behaviour.applySubtree(n,true); + if (n.nodeType==1 && !noBehaviour) + Behaviour.applySubtree(n,true); } Element.remove(e); -- GitLab From cbe2677d93c04b540dcc75f2ab89d3da356a343f Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 14 Mar 2011 11:29:17 -0700 Subject: [PATCH 0783/2361] Fixed the uploading of Extension points Wiki page. --- core/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 5dcb5f3812..7bf9be9197 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -198,7 +198,7 @@ THE SOFTWARE. --> org.codehaus.mojo apt-maven-plugin - 1.0-alpha-2 + 1.0-alpha-4 true org.jvnet.hudson.tools.ExtensionPointListerFactory @@ -209,9 +209,9 @@ THE SOFTWARE. - org.jvnet.hudson.tools + org.jenkins-ci.tools extension-point-lister - 1.7 + 1.8 com.sun -- GitLab From c3fc09939cd688a8aa1bb19a1be2b0d7ab72e087 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 14 Mar 2011 13:26:11 -0700 Subject: [PATCH 0784/2361] [FIXED JENKINS-7871] Fixed a race condition in FilePath.copyTo that results in missing tail bits when the master is heavily loaded. --- changelog.html | 3 + core/src/main/java/hudson/FilePath.java | 4 + core/src/test/java/hudson/FilePathTest.java | 95 +++++++++++++++++++ .../main/java/hudson/remoting/Channel.java | 23 +++-- .../java/hudson/remoting/LocalChannel.java | 4 + .../java/hudson/remoting/VirtualChannel.java | 8 ++ 6 files changed, 128 insertions(+), 9 deletions(-) diff --git a/changelog.html b/changelog.html index 625aa0bcf5..1b826ce259 100644 --- a/changelog.html +++ b/changelog.html @@ -68,6 +68,9 @@ Upcoming changes