1 package org.apache.maven.toolchain;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.Map;
25
26 import org.apache.maven.execution.MavenSession;
27 import org.apache.maven.toolchain.model.ToolchainModel;
28 import org.codehaus.plexus.component.annotations.Component;
29
30
31
32
33
34 @Component( role = ToolchainManagerPrivate.class )
35 public class DefaultToolchainManagerPrivate
36 extends DefaultToolchainManager
37 implements ToolchainManagerPrivate
38 {
39
40 @Override
41 public ToolchainPrivate[] getToolchainsForType( String type, MavenSession context )
42 throws MisconfiguredToolchainException
43 {
44 List<ToolchainPrivate> toRet = new ArrayList<>();
45
46 ToolchainFactory fact = factories.get( type );
47 if ( fact == null )
48 {
49 logger.error( "Missing toolchain factory for type: " + type
50 + ". Possibly caused by misconfigured project." );
51 }
52 else
53 {
54 List<ToolchainModel> availableToolchains = context.getRequest().getToolchains().get( type );
55
56 if ( availableToolchains != null )
57 {
58 for ( ToolchainModel toolchainModel : availableToolchains )
59 {
60 toRet.add( fact.createToolchain( toolchainModel ) );
61 }
62 }
63
64
65 ToolchainPrivate tool = fact.createDefaultToolchain();
66 if ( tool != null )
67 {
68 toRet.add( tool );
69 }
70 }
71
72 return toRet.toArray( new ToolchainPrivate[0] );
73 }
74
75 @Override
76 public void storeToolchainToBuildContext( ToolchainPrivate toolchain, MavenSession session )
77 {
78 Map<String, Object> context = retrieveContext( session );
79 context.put( getStorageKey( toolchain.getType() ), toolchain.getModel() );
80 }
81
82 }