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