1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.extension.internal.maven

File DefaultMavenExtensionDependency.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

2
11
7
1
119
47
8
0.73
1.57
7
1.14

Classes

Class Line # Actions
DefaultMavenExtensionDependency 33 11 0% 8 9
0.5555%
 

Contributing tests

This file is covered by 11 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.extension.internal.maven;
21   
22    import org.apache.maven.model.Dependency;
23    import org.xwiki.extension.DefaultExtensionDependency;
24    import org.xwiki.extension.ExtensionDependency;
25    import org.xwiki.extension.version.VersionConstraint;
26   
27    /**
28    * Default implementation of {@link MavenExtension}.
29    *
30    * @version $Id: 35bca01088bd4d4e3fe6d819d7046bc50caa294b $
31    * @since 7.3M1
32    */
 
33    public class DefaultMavenExtensionDependency extends DefaultExtensionDependency implements MavenExtensionDependency
34    {
35    /**
36    * The key associated to the Maven dependency object.
37    */
38    public static final String PKEY_MAVEN_DEPENDENCY = "maven.Dependency";
39   
40    /**
41    * The key associated to the Maven dependency object.
42    *
43    * @since 8.1M1
44    */
45    public static final String PKEY_MAVEN_DEPENDENCY_SCOPE = "maven.dependency.scope";
46   
47    /**
48    * The key associated to the Maven dependency object.
49    *
50    * @since 8.1M1
51    */
52    public static final String PKEY_MAVEN_DEPENDENCY_OPTIONAL = "maven.dependency.optional";
53   
54    /**
55    * Create new instance by cloning the provided one.
56    *
57    * @param dependency the extension dependency to copy
58    */
 
59  1033 toggle public DefaultMavenExtensionDependency(ExtensionDependency dependency)
60    {
61  1033 super(dependency);
62    }
63   
64    /**
65    * @param extensionId the id of the extension dependency
66    * @param constraint the version constraint of the extension dependency
67    * @param mavenDependency the Maven dependency object
68    */
 
69  722419 toggle public DefaultMavenExtensionDependency(String extensionId, VersionConstraint constraint, Dependency mavenDependency)
70    {
71  722419 super(extensionId, constraint);
72   
73  722419 if (mavenDependency != null) {
74    // custom properties lost when saving
75  722419 putProperty(PKEY_MAVEN_DEPENDENCY, mavenDependency);
76    // custom properties to remember
77  722419 putProperty(PKEY_MAVEN_DEPENDENCY_SCOPE, mavenDependency.getScope());
78  722419 putProperty(PKEY_MAVEN_DEPENDENCY_OPTIONAL, mavenDependency.isOptional());
79    }
80    }
81   
82    /**
83    * @param dependency the generic dependency
84    * @return the scope of dependency
85    * @since 8.1M1
86    */
 
87  0 toggle public static String getScope(ExtensionDependency dependency)
88    {
89  0 return (String) dependency.getProperty(PKEY_MAVEN_DEPENDENCY_SCOPE);
90    }
91   
92    /**
93    * @param dependency the generic dependency
94    * @return true is the dependency is optional
95    * @since 8.1M1
96    */
 
97  0 toggle public static boolean isOptional(ExtensionDependency dependency)
98    {
99  0 return dependency.getProperty(PKEY_MAVEN_DEPENDENCY_OPTIONAL, false);
100    }
101   
 
102  6465 toggle @Override
103    public Dependency getMavenDependency()
104    {
105  6465 return (Dependency) getProperty(PKEY_MAVEN_DEPENDENCY);
106    }
107   
 
108  0 toggle @Override
109    public String getScope()
110    {
111  0 return getScope(this);
112    }
113   
 
114  0 toggle @Override
115    public boolean isOptional()
116    {
117  0 return isOptional(this);
118    }
119    }