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

File AbstractMavenExtension.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

2
16
8
1
138
58
9
0.56
2
8
1.12

Classes

Class Line # Actions
AbstractMavenExtension 35 16 0% 9 7
0.730769273.1%
 

Contributing tests

This file is covered by 19 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.Model;
23    import org.xwiki.extension.AbstractExtension;
24    import org.xwiki.extension.Extension;
25    import org.xwiki.extension.ExtensionId;
26    import org.xwiki.extension.repository.ExtensionRepository;
27    import org.xwiki.extension.version.Version;
28   
29    /**
30    * Base class for all Maven specific {@link Extension}s.
31    *
32    * @version $Id: a2eca92f6125c95ef7c48d957dd397684234bb1a $
33    * @since 7.3M1
34    */
 
35    public abstract class AbstractMavenExtension extends AbstractExtension implements MavenExtension
36    {
37    /**
38    * The name of the property containing the source Model if any.
39    */
40    public static final String PKEY_MAVEN_MODEL = "maven.Model";
41   
42    /**
43    * The name of the property containing the artifact id.
44    */
45    public static final String PKEY_MAVEN_ARTIFACTID = "maven.artifactid";
46   
47    /**
48    * The name of the property containing the group id.
49    */
50    public static final String PKEY_MAVEN_GROUPID = "maven.groupid";
51   
52    /**
53    * @param repository the repository where this extension comes from
54    * @param groupId the maven artifact group id
55    * @param artifactId the maven artifact artifact id
56    * @param version the maven artifact version
57    * @param type the extension type
58    */
 
59  0 toggle public AbstractMavenExtension(ExtensionRepository repository, String groupId, String artifactId, String version,
60    String type)
61    {
62  0 super(repository, new ExtensionId(groupId + ':' + artifactId, version), type);
63   
64  0 setMavenGroupId(groupId);
65  0 setMavenArtifactId(artifactId);
66    }
67   
68    /**
69    * @param repository the repository where this extension comes from
70    * @param groupId the maven artifact group id
71    * @param artifactId the maven artifact artifact id
72    * @param version the maven artifact version
73    * @param type the extension type
74    * @since 8.4
75    */
 
76  24406 toggle public AbstractMavenExtension(ExtensionRepository repository, String groupId, String artifactId, Version version,
77    String type)
78    {
79  24406 super(repository, new ExtensionId(groupId + ':' + artifactId, version), type);
80   
81  24406 setMavenGroupId(groupId);
82  24406 setMavenArtifactId(artifactId);
83    }
84   
85    /**
86    * Create new Maven extension descriptor by copying provided one.
87    *
88    * @param repository the repository where this extension comes from
89    * @param extension the extension to copy
90    */
 
91  51 toggle public AbstractMavenExtension(ExtensionRepository repository, Extension extension)
92    {
93  51 super(repository, extension);
94   
95  51 if (extension instanceof MavenExtension) {
96  51 MavenExtension mavenExtension = (MavenExtension) extension;
97   
98  51 setMavenArtifactId(mavenExtension.getMavenArtifactId());
99  51 setMavenGroupId(mavenExtension.getMavenGroupId());
100    }
101    }
102   
 
103  51 toggle @Override
104    public String getMavenGroupId()
105    {
106  51 return getProperty(PKEY_MAVEN_GROUPID);
107    }
108   
109    /**
110    * @param groupId the Maven group id
111    */
 
112  24457 toggle public void setMavenGroupId(String groupId)
113    {
114  24457 putProperty(PKEY_MAVEN_GROUPID, groupId);
115    }
116   
 
117  51 toggle @Override
118    public String getMavenArtifactId()
119    {
120  51 return getProperty(PKEY_MAVEN_ARTIFACTID);
121    }
122   
123    /**
124    * @param artifactId the Maven artifact id
125    */
 
126  24457 toggle public void setMavenArtifactId(String artifactId)
127    {
128  24457 putProperty(PKEY_MAVEN_ARTIFACTID, artifactId);
129    }
130   
131    /**
132    * @return the Maven model object if any
133    */
 
134  0 toggle public Model getMavenModel()
135    {
136  0 return (Model) getProperty(PKEY_MAVEN_MODEL);
137    }
138    }