View Javadoc

1   /*
2    * #%L
3    * Native ARchive plugin for Maven
4    * %%
5    * Copyright (C) 2002 - 2014 NAR Maven Plugin developers.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   * http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.github.maven_nar;
21  
22  import org.apache.maven.plugin.MojoFailureException;
23  import org.apache.maven.plugins.annotations.Parameter;
24  import org.apache.tools.ant.Project;
25  
26  import com.github.maven_nar.cpptasks.CUtil;
27  import com.github.maven_nar.cpptasks.types.LibraryTypeEnum;
28  import com.github.maven_nar.cpptasks.types.SystemLibrarySet;
29  
30  /**
31   * Keeps info on a system library
32   *
33   * @author Mark Donszelmann
34   */
35  public class SysLib {
36    /**
37     * Name of the system library
38     */
39    @Parameter(required = true)
40    private String name;
41  
42    /**
43     * Type of linking for this system library
44     */
45    @Parameter(defaultValue = "shared")
46    private String type = Library.SHARED;
47  
48    public final SystemLibrarySet getSysLibSet(final Project antProject) throws MojoFailureException {
49      if (this.name == null) {
50        throw new MojoFailureException("NAR: Please specify <Name> as part of <SysLib>");
51      }
52      final SystemLibrarySet sysLibSet = new SystemLibrarySet();
53      sysLibSet.setProject(antProject);
54      sysLibSet.setLibs(new CUtil.StringArrayBuilder(this.name));
55      final LibraryTypeEnum sysLibType = new LibraryTypeEnum();
56      sysLibType.setValue(this.type);
57      sysLibSet.setType(sysLibType);
58      return sysLibSet;
59    }
60  
61    @Override
62    public String toString() {
63      return this.name + " (" + this.type + ")";
64    }
65  }