diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java index 1bea2b3eb1..5adab1fcda 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java @@ -71,6 +71,8 @@ public class DefaultMavenExecutionRequest private File globalSettingsFile; + private File userToolchainsFile; + // ---------------------------------------------------------------------------- // Request // ---------------------------------------------------------------------------- @@ -138,6 +140,7 @@ public class DefaultMavenExecutionRequest copy.setProjectPresent( original.isProjectPresent() ); copy.setUserSettingsFile( original.getUserSettingsFile() ); copy.setGlobalSettingsFile( original.getGlobalSettingsFile() ); + copy.setUserToolchainsFile( original.getUserToolchainsFile() ); copy.setBaseDirectory( new File( original.getBaseDirectory() ) ); copy.setGoals( original.getGoals() ); copy.setUseReactor( original.useReactor() ); @@ -652,7 +655,7 @@ public class DefaultMavenExecutionRequest return this; } - // Settin10gs files + // Settings files public File getUserSettingsFile() { @@ -678,6 +681,18 @@ public class DefaultMavenExecutionRequest return this; } + public File getUserToolchainsFile() + { + return userToolchainsFile; + } + + public MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile ) + { + this.userToolchainsFile = userToolchainsFile; + + return this; + } + public MavenExecutionRequest addRemoteRepository( ArtifactRepository repository ) { if ( remoteRepositories == null ) diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java index 146b4115ec..4aaeef116b 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java @@ -230,5 +230,8 @@ public interface MavenExecutionRequest MavenExecutionRequest setErrorReporter( CoreErrorReporter reporter ); CoreErrorReporter getErrorReporter(); + File getUserToolchainsFile(); + MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile ); + ProjectBuilderConfiguration getProjectBuildingConfiguration(); } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java index ff987622a4..8045cd9f69 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java @@ -76,6 +76,8 @@ public class CLIManager public static final String ALTERNATE_GLOBAL_SETTINGS = "gs"; + public static final char ALTERNATE_USER_TOOLCHAINS = 't'; + public static final String FAIL_FAST = "ff"; public static final String FAIL_AT_END = "fae"; @@ -111,6 +113,7 @@ public class CLIManager options.addOption( OptionBuilder.withLongOpt( "lax-checksums" ).withDescription( "Warn if checksums don't match" ).create( CHECKSUM_WARNING_POLICY ) ); options.addOption( OptionBuilder.withLongOpt( "settings" ).withDescription( "Alternate path for the user settings file" ).hasArg().create( ALTERNATE_USER_SETTINGS ) ); options.addOption( OptionBuilder.withLongOpt( "global-settings" ).withDescription( "Alternate path for the global settings file" ).hasArg().create( ALTERNATE_GLOBAL_SETTINGS ) ); + options.addOption( OptionBuilder.withLongOpt( "toolchains" ).withDescription( "Alternate path for the user toolchains file" ).hasArg().create( ALTERNATE_USER_TOOLCHAINS ) ); options.addOption( OptionBuilder.withLongOpt( "fail-fast" ).withDescription( "Stop at first failure in reactorized builds" ).create( FAIL_FAST ) ); options.addOption( OptionBuilder.withLongOpt( "fail-at-end" ).withDescription( "Only fail the build afterwards; allow all non-impacted builds to continue" ).create( FAIL_AT_END ) ); options.addOption( OptionBuilder.withLongOpt( "fail-never" ).withDescription( "NEVER fail the build, regardless of project result" ).create( FAIL_NEVER ) ); diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIRequestUtils.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIRequestUtils.java index b75a85762a..c66191f3fe 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIRequestUtils.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIRequestUtils.java @@ -30,6 +30,7 @@ import java.util.Map.Entry; import org.apache.commons.cli.CommandLine; import org.apache.maven.MavenTransferListener; +import org.apache.maven.embedder.MavenEmbedder; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.codehaus.plexus.util.cli.CommandLineUtils; @@ -222,6 +223,16 @@ public final class CLIRequestUtils Properties userProperties = new Properties(); populateProperties( commandLine, executionProperties, userProperties ); + File userToolchainsFile; + if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ) + { + userToolchainsFile = new File( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ); + } + else + { + userToolchainsFile = MavenEmbedder.DEFAULT_USER_TOOLCHAINS_FILE; + } + MavenExecutionRequest request = new DefaultMavenExecutionRequest() .setBaseDirectory( baseDirectory ) .setGoals( goals ) @@ -240,7 +251,9 @@ public final class CLIRequestUtils .setTransferListener( transferListener ) // default: batch mode which goes along with interactive .setUpdateSnapshots( updateSnapshots ) // default: false .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false - .setGlobalChecksumPolicy( globalChecksumPolicy ); // default: warn + .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn + .setUserToolchainsFile( userToolchainsFile ); + if ( alternatePomFile != null ) { diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java index e251a3fde1..04284ce85c 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java @@ -23,10 +23,8 @@ import java.io.File; import java.io.IOException; import java.io.Reader; import java.io.Writer; -import java.net.URL; import java.util.Arrays; import java.util.Collection; -import java.util.Iterator; import java.util.List; import org.apache.maven.Maven; @@ -80,11 +78,7 @@ import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; -import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; -import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; @@ -111,6 +105,8 @@ public class MavenEmbedder public static final File DEFAULT_GLOBAL_SETTINGS_FILE = new File( System.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/settings.xml" ); + public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File( userMavenConfigurationHome, "toolchains.xml" ); + // ---------------------------------------------------------------------------- // // ---------------------------------------------------------------------------- diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java index 69903b03a4..61e3548ac4 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java @@ -17,7 +17,6 @@ package org.apache.maven.embedder.execution; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -50,6 +49,7 @@ import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.apache.maven.settings.SettingsUtils; +import org.apache.maven.toolchain.ToolchainsBuilder; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @@ -80,6 +80,9 @@ public class DefaultMavenExecutionRequestPopulator @Requirement private RepositorySystem repositorySystem; + @Requirement + private ToolchainsBuilder toolchainsBuilder; + // 2009-03-05 Oleg: this component is defined sub-classed in this package @Requirement(hint = "maven") private SecDispatcher securityDispatcher; @@ -99,6 +102,8 @@ public class DefaultMavenExecutionRequestPopulator localRepository( request, configuration ); + toolchains( request, configuration ); + artifactTransferMechanism( request, configuration ); realmManager( request, configuration ); @@ -526,4 +531,10 @@ public class DefaultMavenExecutionRequestPopulator request.setProfileManager( globalProfileManager ); request.setProfileActivationContext( activationContext ); } + + private void toolchains( MavenExecutionRequest request, Configuration configuration ) + { + toolchainsBuilder.setUserToolchainsFile( request.getUserToolchainsFile() ); + } + } diff --git a/maven-toolchain/pom.xml b/maven-toolchain/pom.xml index e27791d892..f651b78cd3 100644 --- a/maven-toolchain/pom.xml +++ b/maven-toolchain/pom.xml @@ -34,6 +34,18 @@ + + org.codehaus.plexus + plexus-component-metadata + + + + generate-metadata + generate-test-metadata + + + + org.codehaus.modello modello-maven-plugin diff --git a/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java b/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java index f58f39c73d..4cc6ca5763 100644 --- a/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java +++ b/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java @@ -1,3 +1,5 @@ +package org.apache.maven.toolchain; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -17,214 +19,84 @@ * under the License. */ -package org.apache.maven.toolchain; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; -import java.util.List; import java.util.Map; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; -import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.ToolchainModel; -import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; 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.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.logging.Logger; /** - * * @author mkleint */ -@Component(role=ToolchainManager.class) -public class DefaultToolchainManager extends AbstractLogEnabled - implements ToolchainManager, - ToolchainManagerPrivate +@Component( role = ToolchainManager.class ) +public class DefaultToolchainManager + implements ToolchainManager + { - @Requirement - private PlexusContainer container; - public DefaultToolchainManager( ) - { - } + @Requirement + Logger logger; - public ToolchainPrivate[] getToolchainsForType( String type ) - throws MisconfiguredToolchainException - { - try - { - PersistedToolchains pers = readToolchainSettings (); - Map factories = container.lookupMap( ToolchainFactory.class ); - List toRet = new ArrayList( ); - if ( pers != null ) - { - List lst = pers.getToolchains(); - if ( lst != null ) - { - Iterator it = lst.iterator(); - while ( it.hasNext() ) - { - ToolchainModel toolchainModel = (ToolchainModel) it.next(); - ToolchainFactory fact = factories.get( toolchainModel.getType() ); - if ( fact != null ) - { - toRet.add( fact.createToolchain( toolchainModel ) ); - } - else - { - getLogger().error("Missing toolchain factory for type:" + toolchainModel.getType() + ". Possibly caused by misconfigured project."); - } - } - } - } - for ( ToolchainFactory toolchainFactory : factories.values() ) - { - ToolchainPrivate tool = toolchainFactory.createDefaultToolchain(); - if ( tool != null ) - { - toRet.add( tool ); - } - } - ToolchainPrivate[] tc = new ToolchainPrivate[ toRet.size() ]; - return (ToolchainPrivate[]) toRet.toArray(tc); - } - catch ( ComponentLookupException ex ) - { - getLogger().fatalError("Error in component lookup", ex); - } - return new ToolchainPrivate[0]; - } + @Requirement( role = ToolchainFactory.class ) + Map factories; - public Toolchain getToolchainFromBuildContext( String type, - MavenSession session ) + public Toolchain getToolchainFromBuildContext( String type, MavenSession session ) { - Map context = retrieveContext(session); - if ( "javac".equals( type )) - { - //HACK to make compiler plugin happy - type = "jdk"; - } - Object obj = context.get( getStorageKey( type ) ); - ToolchainModel model = (ToolchainModel)obj; - - if ( model != null ) + Map context = retrieveContext( session ); + + ToolchainModel model = (ToolchainModel) context.get( getStorageKey( type ) ); + + if ( model != null ) { try { - ToolchainFactory fact = container.lookup(ToolchainFactory.class, type); - return fact.createToolchain( model ); - } - catch ( ComponentLookupException ex ) - { - getLogger().fatalError("Error in component lookup", ex); + ToolchainFactory fact = factories.get( type ); + if ( fact != null ) + { + return fact.createToolchain( model ); + } + else + { + logger.error( "Missing toolchain factory for type: " + type + + ". Possibly caused by misconfigured project." ); + } } catch ( MisconfiguredToolchainException ex ) { - getLogger().error("Misconfigured toolchain.", ex); + logger.error( "Misconfigured toolchain.", ex ); } } + return null; } - private MavenProject getCurrentProject(MavenSession session) { - //use reflection since MavenSession.getCurrentProject() is not part of 2.0.8 - try - { - Method meth = session.getClass().getMethod("getCurrentProject", new Class[0]); - return (MavenProject) meth.invoke (session ); - } catch (Exception ex) - { - //just ignore, we're running in pre- 2.0.9 - } - return null; - } - - private Map retrieveContext( MavenSession session ) + Map retrieveContext( MavenSession session ) { - if (session == null) - { - return new HashMap(); - } - PluginDescriptor desc = new PluginDescriptor(); - desc.setGroupId( PluginDescriptor.getDefaultPluginGroupId() ); - desc.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId ("toolchains") ); - MavenProject current = getCurrentProject(session); - if ( current != null ) - { - return session.getPluginContext( desc, current ); - - } - return new HashMap(); - } - + Map context = null; - public void storeToolchainToBuildContext( ToolchainPrivate toolchain, - MavenSession session ) - { - Map context = retrieveContext( session ); - context.put( getStorageKey( toolchain.getType() ), toolchain.getModel () ); + if ( session != null ) + { + PluginDescriptor desc = new PluginDescriptor(); + desc.setGroupId( PluginDescriptor.getDefaultPluginGroupId() ); + desc.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( "toolchains" ) ); + + MavenProject current = session.getCurrentProject(); + if ( current != null ) + { + context = session.getPluginContext( desc, current ); + } + } + + return ( context != null ) ? context : new HashMap(); } - + public static final String getStorageKey( String type ) { - return "toolchain-" + type; //NOI18N + return "toolchain-" + type; // NOI18N } - - private PersistedToolchains readToolchainSettings( ) - throws MisconfiguredToolchainException - { - //TODO how to point to the local path? - File tch = new File( System.getProperty( "user.home" ), - ".m2/toolchains.xml" ); - if ( tch.exists() ) - { - MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader(); - InputStreamReader in = null; - try - { - in = new InputStreamReader( new BufferedInputStream( new FileInputStream( tch ) ) ); - return reader.read( in ); - } - catch ( Exception ex ) - { - throw new MisconfiguredToolchainException( "Cannot read toolchains file at " + tch.getAbsolutePath( ), - ex ); - } - finally - { - if (in != null) - { - try - { - in.close(); - } - catch (IOException ex) - { } - } -// IOUtil.close( in ); - } - } - else - { - //TODO log the fact that no toolchains file was found. - } - return null; - } -} \ No newline at end of file +} diff --git a/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java b/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java new file mode 100644 index 0000000000..81ad574c11 --- /dev/null +++ b/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java @@ -0,0 +1,89 @@ +package org.apache.maven.toolchain; + +/* + * 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 java.util.Map; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.toolchain.model.PersistedToolchains; +import org.apache.maven.toolchain.model.ToolchainModel; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; + +/** + * @author mkleint + */ +@Component( role = ToolchainManagerPrivate.class ) +public class DefaultToolchainManagerPrivate + extends DefaultToolchainManager + implements ToolchainManagerPrivate +{ + + @Requirement + private ToolchainsBuilder toolchainsBuilder; + + public ToolchainPrivate[] getToolchainsForType( String type ) + throws MisconfiguredToolchainException + { + PersistedToolchains pers = toolchainsBuilder.build(); + + List toRet = new ArrayList(); + + if ( pers != null ) + { + List lst = pers.getToolchains(); + if ( lst != null ) + { + for ( ToolchainModel toolchainModel : lst ) + { + ToolchainFactory fact = factories.get( toolchainModel.getType() ); + if ( fact != null ) + { + toRet.add( fact.createToolchain( toolchainModel ) ); + } + else + { + logger.error( "Missing toolchain factory for type: " + toolchainModel.getType() + + ". Possibly caused by misconfigured project." ); + } + } + } + } + + for ( ToolchainFactory toolchainFactory : factories.values() ) + { + ToolchainPrivate tool = toolchainFactory.createDefaultToolchain(); + if ( tool != null ) + { + toRet.add( tool ); + } + } + + return toRet.toArray( new ToolchainPrivate[toRet.size()] ); + } + + public void storeToolchainToBuildContext( ToolchainPrivate toolchain, MavenSession session ) + { + Map context = retrieveContext( session ); + context.put( getStorageKey( toolchain.getType() ), toolchain.getModel() ); + } + +} diff --git a/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainsBuilder.java b/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainsBuilder.java new file mode 100644 index 0000000000..d51840c53c --- /dev/null +++ b/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainsBuilder.java @@ -0,0 +1,85 @@ +package org.apache.maven.toolchain; + +/* + * 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.Reader; + +import org.apache.maven.toolchain.model.PersistedToolchains; +import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.ReaderFactory; + +/** + * @author Benjamin Bentmann + */ +@Component( role = ToolchainsBuilder.class, hint = "default" ) +public class DefaultToolchainsBuilder + implements ToolchainsBuilder +{ + + @Requirement + private Logger logger; + + /** + * The path to the user's toolchains file or null if not configured. + */ + private File userToolchainsFile; + + public PersistedToolchains build() + throws MisconfiguredToolchainException + { + PersistedToolchains toolchains = null; + + if ( userToolchainsFile != null && userToolchainsFile.isFile() ) + { + Reader in = null; + try + { + in = ReaderFactory.newXmlReader( userToolchainsFile ); + toolchains = new MavenToolchainsXpp3Reader().read( in ); + } + catch ( Exception e ) + { + throw new MisconfiguredToolchainException( "Cannot read toolchains file at " + + userToolchainsFile.getAbsolutePath(), e ); + } + finally + { + IOUtil.close( in ); + } + } + else if ( userToolchainsFile != null ) + { + logger.debug( "Toolchains configuration was not found at " + userToolchainsFile ); + } + + return toolchains; + } + + public void setUserToolchainsFile( File userToolchainsFile ) + { + this.userToolchainsFile = userToolchainsFile; + } + +} diff --git a/maven-toolchain/src/main/java/org/apache/maven/toolchain/ToolchainsBuilder.java b/maven-toolchain/src/main/java/org/apache/maven/toolchain/ToolchainsBuilder.java new file mode 100644 index 0000000000..3849d5f878 --- /dev/null +++ b/maven-toolchain/src/main/java/org/apache/maven/toolchain/ToolchainsBuilder.java @@ -0,0 +1,52 @@ +package org.apache.maven.toolchain; + +/* + * 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 org.apache.maven.toolchain.model.PersistedToolchains; + +/** + * Builds the toolchains model from a previously configured filesystem path to the toolchains file. + * Note: This is an internal component whose interface can change without prior notice. + * + * @author Benjamin Bentmann + */ +public interface ToolchainsBuilder +{ + + /** + * Builds the toolchains model from the configured toolchain files. + * + * @return The toolchains model or null if no toolchain file was configured or the configured files do + * not exist. + * @throws MisconfiguredToolchainException If the toolchain files exist but cannot be parsed. + */ + PersistedToolchains build() + throws MisconfiguredToolchainException; + + /** + * Sets the path to the file from which to read the available toolchains. + * + * @param userToolchainsFile The path to the toolchains file, may be null to disable parsing. + */ + void setUserToolchainsFile( File userToolchainsFile ); + +} diff --git a/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java b/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java index d3aa897486..55184b7724 100644 --- a/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java +++ b/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java @@ -35,7 +35,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; * * @author mkleint */ -@Component(role=ToolchainFactory.class) +@Component( role = ToolchainFactory.class, hint = "jdk" ) public class DefaultJavaToolchainFactory implements ToolchainFactory, LogEnabled {