mirror of https://github.com/apache/maven.git
o Removed obsolete code
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@828650 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f7d7cbb6a0
commit
ad34db3748
|
@ -1,123 +0,0 @@
|
|||
package org.apache.maven.listeners;
|
||||
|
||||
/*
|
||||
* 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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Configuration;
|
||||
|
||||
/**
|
||||
* This listener has two parts: the collection of the extension elements which happens during POM construction,
|
||||
* and the processing of the build extensions once the construction is finished and the build plan is being
|
||||
* created. The extensions that are found can be contributed to a Mercury session where a set of artifacts
|
||||
* are retrieved and any number of extensions may be required. We don't want to load them as they are discovered
|
||||
* because that prevents any sort of analysis so we collect, analyze and process.
|
||||
*
|
||||
* @author Jason van Zyl
|
||||
*
|
||||
*/
|
||||
@Component(role = MavenModelEventListener.class, hint="extensions", instantiationStrategy="per-lookup" )
|
||||
public class BuildExtensionListener
|
||||
implements MavenModelEventListener
|
||||
{
|
||||
@Configuration(value = "true")
|
||||
private boolean inBuild = true;
|
||||
|
||||
//@Requirement
|
||||
//PlexusPluginManager pluginManager;
|
||||
|
||||
private List<Extension> buildExtensions = new ArrayList<Extension>();
|
||||
|
||||
public void fire(Model model)
|
||||
{
|
||||
buildExtensions.addAll(new ArrayList<Extension>(model.getBuild().getExtensions()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the extension elements that were found during the POM construction process and now
|
||||
* retrieve all the artifacts necessary, load them in a realm, and discovery the components
|
||||
* that are in the realm. Any components that are discovered will be available to lookups
|
||||
* in the container from any location and the right classloader will be used to execute
|
||||
* any components discovered in the extension realm.
|
||||
*
|
||||
* @param session Maven session used as the execution context for the current Maven project.
|
||||
*/
|
||||
public void processModelContainers( MavenSession session )
|
||||
{
|
||||
if(!inBuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Extension be : buildExtensions )
|
||||
{
|
||||
/*
|
||||
PluginResolutionRequest request = new PluginResolutionRequest()
|
||||
.setPluginMetadata( new PluginMetadata( be.getGroupId(), be.getArtifactId(), be.getVersion() ) )
|
||||
.addLocalRepository( session.getRequest().getLocalRepositoryPath() )
|
||||
.setRemoteRepositories( convertToMercuryRepositories( session.getRequest().getRemoteRepositories() ) );
|
||||
|
||||
PluginResolutionResult result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = pluginManager.resolve( request );
|
||||
|
||||
ClassRealm realm = pluginManager.createClassRealm( result.getArtifacts() );
|
||||
|
||||
realm.display();
|
||||
|
||||
List<ComponentDescriptor<?>> components = pluginManager.discoverComponents( realm );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
List<String> convertToMercuryRepositories( List<ArtifactRepository> repositories )
|
||||
{
|
||||
List<String> repos = new ArrayList<String>();
|
||||
|
||||
if ( repositories != null )
|
||||
{
|
||||
for ( ArtifactRepository r : repositories )
|
||||
{
|
||||
repos.add( r.getUrl() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This will only ever be use for the test that I have. So yes this will break
|
||||
// folks behind proxies until alpha-2. Such is life.
|
||||
repos.add( "http://repo1.maven.org/maven2" );
|
||||
}
|
||||
|
||||
return repos;
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package org.apache.maven.listeners;
|
||||
|
||||
/*
|
||||
* 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.util.List;
|
||||
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
||||
@Component(role = MavenModelEventProcessor.class)
|
||||
public class DefaultMavenModelEventProcessor
|
||||
implements MavenModelEventProcessor
|
||||
{
|
||||
@Requirement
|
||||
List<MavenModelEventListener> listeners;
|
||||
|
||||
public void processModelContainers( MavenSession session )
|
||||
{
|
||||
for( MavenModelEventListener listener : listeners )
|
||||
{
|
||||
listener.processModelContainers( session );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package org.apache.maven.listeners;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.building.ModelEventListener;
|
||||
|
||||
|
||||
public interface MavenModelEventListener
|
||||
extends ModelEventListener
|
||||
{
|
||||
void processModelContainers( MavenSession session );
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package org.apache.maven.listeners;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
|
||||
public interface MavenModelEventProcessor
|
||||
{
|
||||
void processModelContainers( MavenSession session );
|
||||
}
|
Loading…
Reference in New Issue