| 1 |  | package org.apache.torque.mojo; | 
            
  
    | 2 |  |  | 
            
  
    | 3 |  | import org.apache.maven.execution.MavenSession; | 
            
  
    | 4 |  | import org.apache.maven.plugin.AbstractMojo; | 
            
  
    | 5 |  | import org.apache.maven.plugin.MojoExecutionException; | 
            
  
    | 6 |  | import org.apache.maven.plugin.MojoFailureException; | 
            
  
    | 7 |  | import org.apache.maven.project.MavenProject; | 
            
  
    | 8 |  | import org.apache.maven.settings.Settings; | 
            
  
    | 9 |  | import org.kuali.maven.mojo.MavenLogger; | 
            
  
    | 10 |  |  | 
            
  
    | 11 |  |  | 
            
  
    | 12 |  |  | 
            
  
    | 13 |  |  | 
            
  
    | 14 |  |  | 
            
  
    | 15 |  |  | 
            
  
    | 16 |  |  | 
            
  
    | 17 |  |  | 
               
        |  |  | 
           
           |  | 55.2% | Uncovered Elements: 26 (58) | Complexity: 25 | Complexity Density: 0.83 |  | 
  
  
    | 18 |  | public abstract class BaseMojo extends AbstractMojo { | 
            
  
    | 19 |  | public static final String FS = System.getProperty("file.separator"); | 
            
  
    | 20 |  | public static final String SKIP_PACKAGING_TYPE = "pom"; | 
            
  
    | 21 |  |  | 
            
  
    | 22 |  |  | 
            
  
    | 23 |  |  | 
            
  
    | 24 |  |  | 
            
  
    | 25 |  |  | 
            
  
    | 26 |  |  | 
            
  
    | 27 |  |  | 
            
  
    | 28 |  | private boolean startMavenLogger; | 
            
  
    | 29 |  |  | 
            
  
    | 30 |  |  | 
            
  
    | 31 |  |  | 
            
  
    | 32 |  |  | 
            
  
    | 33 |  |  | 
            
  
    | 34 |  |  | 
            
  
    | 35 |  | private boolean skip; | 
            
  
    | 36 |  |  | 
            
  
    | 37 |  |  | 
            
  
    | 38 |  |  | 
            
  
    | 39 |  |  | 
            
  
    | 40 |  |  | 
            
  
    | 41 |  |  | 
            
  
    | 42 |  |  | 
            
  
    | 43 |  |  | 
            
  
    | 44 |  | private boolean forceMojoExecution; | 
            
  
    | 45 |  |  | 
            
  
    | 46 |  |  | 
            
  
    | 47 |  |  | 
            
  
    | 48 |  |  | 
            
  
    | 49 |  |  | 
            
  
    | 50 |  |  | 
            
  
    | 51 |  |  | 
            
  
    | 52 |  |  | 
            
  
    | 53 |  |  | 
            
  
    | 54 |  | private String encoding; | 
            
  
    | 55 |  |  | 
            
  
    | 56 |  |  | 
            
  
    | 57 |  |  | 
            
  
    | 58 |  |  | 
            
  
    | 59 |  |  | 
            
  
    | 60 |  |  | 
            
  
    | 61 |  |  | 
            
  
    | 62 |  |  | 
            
  
    | 63 |  | private MavenProject project; | 
            
  
    | 64 |  |  | 
            
  
    | 65 |  |  | 
            
  
    | 66 |  |  | 
            
  
    | 67 |  |  | 
            
  
    | 68 |  | @since | 
            
  
    | 69 |  |  | 
            
  
    | 70 |  |  | 
            
  
    | 71 |  | private Settings settings; | 
            
  
    | 72 |  |  | 
            
  
    | 73 |  |  | 
            
  
    | 74 |  |  | 
            
  
    | 75 |  |  | 
            
  
    | 76 |  |  | 
            
  
    | 77 |  |  | 
            
  
    | 78 |  | private MavenSession mavenSession; | 
            
  
    | 79 |  |  | 
               
        |  |  | 
           
           |  | - | Uncovered Elements: 0 (0) | Complexity: 1 | Complexity Density: - |  | 
  
  
    | 80 | 1 |  protected void beforeExecution() throws MojoExecutionException, MojoFailureException {... | 
            
  
    | 81 |  | } | 
            
  
    | 82 |  |  | 
               
        |  |  | 
           
           |  | - | Uncovered Elements: 0 (0) | Complexity: 1 | Complexity Density: - |  | 
  
  
    | 83 | 1 |  protected void afterExecution() throws MojoExecutionException, MojoFailureException {... | 
            
  
    | 84 |  | } | 
            
  
    | 85 |  |  | 
               
        |  |  | 
           
           |  | 60% | Uncovered Elements: 6 (15) | Complexity: 4 | Complexity Density: 0.44 |  | 
  
  
    | 86 | 1 |  @Override... | 
            
  
    | 87 |  | public void execute() throws MojoExecutionException, MojoFailureException { | 
            
  
    | 88 | 1 | beforeExecution(); | 
            
  
    | 89 | 1 | if (isStartMavenLogger()) { | 
            
  
    | 90 | 0 | MavenLogger.startPluginLog(this); | 
            
  
    | 91 |  | } | 
            
  
    | 92 | 1 | if (skipMojo()) { | 
            
  
    | 93 | 0 | return; | 
            
  
    | 94 |  | } | 
            
  
    | 95 | 1 | executeMojo(); | 
            
  
    | 96 | 1 | if (isStartMavenLogger()) { | 
            
  
    | 97 | 0 | MavenLogger.endPluginLog(this); | 
            
  
    | 98 |  | } | 
            
  
    | 99 | 1 | afterExecution(); | 
            
  
    | 100 |  | } | 
            
  
    | 101 |  |  | 
            
  
    | 102 |  | protected abstract void executeMojo() throws MojoExecutionException, MojoFailureException; | 
            
  
    | 103 |  |  | 
            
  
    | 104 |  |  | 
            
  
    | 105 |  |  | 
            
  
    | 106 |  |  | 
            
  
    | 107 |  |  | 
            
  
    | 108 |  |  | 
            
  
    | 109 |  |  | 
            
  
    | 110 |  | @link | 
            
  
    | 111 |  |  | 
            
  
    | 112 |  | @link | 
            
  
    | 113 |  |  | 
            
  
    | 114 |  |  | 
            
  
    | 115 |  | @return | 
            
  
    | 116 |  |  | 
               
        |  |  | 
           
           |  | 45.5% | Uncovered Elements: 6 (11) | Complexity: 5 | Complexity Density: 0.71 |  | 
  
  
    | 117 | 1 |  protected boolean skipMojo() {... | 
            
  
    | 118 | 1 | if (skip) { | 
            
  
    | 119 | 0 | getLog().info("Skipping execution"); | 
            
  
    | 120 | 0 | return true; | 
            
  
    | 121 |  | } | 
            
  
    | 122 |  |  | 
            
  
    | 123 | 1 | if (!forceMojoExecution && project != null && SKIP_PACKAGING_TYPE.equals(project.getPackaging())) { | 
            
  
    | 124 | 0 | getLog().info("Skipping execution for project with packaging type '" + SKIP_PACKAGING_TYPE + "'"); | 
            
  
    | 125 | 0 | return true; | 
            
  
    | 126 |  | } | 
            
  
    | 127 |  |  | 
            
  
    | 128 | 1 | return false; | 
            
  
    | 129 |  | } | 
            
  
    | 130 |  |  | 
            
  
    | 131 |  |  | 
            
  
    | 132 |  |  | 
            
  
    | 133 |  |  | 
            
  
    | 134 |  | @return | 
            
  
    | 135 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 136 | 2 |  public MavenProject getProject() {... | 
            
  
    | 137 | 2 | return project; | 
            
  
    | 138 |  | } | 
            
  
    | 139 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 140 | 2 |  public String getEncoding() {... | 
            
  
    | 141 | 2 | return encoding; | 
            
  
    | 142 |  | } | 
            
  
    | 143 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 144 | 0 |  public void setEncoding(String encoding) {... | 
            
  
    | 145 | 0 | this.encoding = encoding; | 
            
  
    | 146 |  | } | 
            
  
    | 147 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 148 | 2 |  public boolean isSkip() {... | 
            
  
    | 149 | 2 | return skip; | 
            
  
    | 150 |  | } | 
            
  
    | 151 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 152 | 0 |  public void setSkip(boolean skip) {... | 
            
  
    | 153 | 0 | this.skip = skip; | 
            
  
    | 154 |  | } | 
            
  
    | 155 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 156 | 2 |  public boolean isForceMojoExecution() {... | 
            
  
    | 157 | 2 | return forceMojoExecution; | 
            
  
    | 158 |  | } | 
            
  
    | 159 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 160 | 0 |  public void setForceMojoExecution(boolean forceMojoExecution) {... | 
            
  
    | 161 | 0 | this.forceMojoExecution = forceMojoExecution; | 
            
  
    | 162 |  | } | 
            
  
    | 163 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 164 | 2 |  public Settings getSettings() {... | 
            
  
    | 165 | 2 | return settings; | 
            
  
    | 166 |  | } | 
            
  
    | 167 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 168 | 0 |  public void setSettings(Settings settings) {... | 
            
  
    | 169 | 0 | this.settings = settings; | 
            
  
    | 170 |  | } | 
            
  
    | 171 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 172 | 2 |  public MavenSession getMavenSession() {... | 
            
  
    | 173 | 2 | return mavenSession; | 
            
  
    | 174 |  | } | 
            
  
    | 175 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 176 | 0 |  public void setMavenSession(MavenSession mavenSession) {... | 
            
  
    | 177 | 0 | this.mavenSession = mavenSession; | 
            
  
    | 178 |  | } | 
            
  
    | 179 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 180 | 0 |  public void setProject(MavenProject project) {... | 
            
  
    | 181 | 0 | this.project = project; | 
            
  
    | 182 |  | } | 
            
  
    | 183 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 184 | 4 |  public boolean isStartMavenLogger() {... | 
            
  
    | 185 | 4 | return startMavenLogger; | 
            
  
    | 186 |  | } | 
            
  
    | 187 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 188 | 0 |  public void setStartMavenLogger(boolean startMavenLogger) {... | 
            
  
    | 189 | 0 | this.startMavenLogger = startMavenLogger; | 
            
  
    | 190 |  | } | 
            
  
    | 191 |  | } |