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 org.apache.maven.toolchain.model.PersistedToolchains;
23 import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
24 import org.codehaus.plexus.component.annotations.Component;
25 import org.codehaus.plexus.component.annotations.Requirement;
26 import org.codehaus.plexus.logging.Logger;
27 import org.codehaus.plexus.util.ReaderFactory;
28
29 import java.io.File;
30 import java.io.Reader;
31
32
33
34
35
36 @Deprecated
37 @Component( role = ToolchainsBuilder.class, hint = "default" )
38 public class DefaultToolchainsBuilder
39 implements ToolchainsBuilder
40 {
41
42 @Requirement
43 private Logger logger;
44
45 public PersistedToolchains build( File userToolchainsFile )
46 throws MisconfiguredToolchainException
47 {
48 PersistedToolchains toolchains = null;
49
50 if ( userToolchainsFile != null && userToolchainsFile.isFile() )
51 {
52 try ( Reader in = ReaderFactory.newXmlReader( userToolchainsFile ) )
53 {
54 toolchains = new MavenToolchainsXpp3Reader().read( in );
55 }
56 catch ( Exception e )
57 {
58 throw new MisconfiguredToolchainException(
59 "Cannot read toolchains file at " + userToolchainsFile.getAbsolutePath(), e );
60 }
61
62 }
63 else if ( userToolchainsFile != null )
64 {
65 logger.debug( "Toolchains configuration was not found at " + userToolchainsFile );
66 }
67
68 return toolchains;
69 }
70
71 }