View Javadoc

1   package org.kuali.student.datadictionary.mojo;
2   
3   import java.io.File;
4   import java.util.Collection;
5   import java.util.List;
6   
7   import org.apache.maven.plugin.AbstractMojo;
8   import org.apache.maven.plugin.MojoExecutionException;
9   
10  import org.kuali.student.common.mojo.AbstractKSMojo;
11  import org.kuali.student.contract.model.ServiceContractModel;
12  import org.kuali.student.contract.model.impl.ServiceContractModelCache;
13  import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader;
14  import org.kuali.student.contract.model.validation.ServiceContractModelValidator;
15  import org.kuali.student.contract.writer.service.EachMethodServiceWriter;
16  
17  /**
18   * The plugin entrypoint which is used to generate a java interface file for each
19   * service method in the source files based on the contract definition
20   * @phase generate-sources
21   * @goal kseachmethodservicegenerator
22   */
23  public class KSEachMethodServiceGeneratorrMojo extends AbstractKSMojo {
24  
25      /**
26       * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources"
27       */
28      private File outputDirectory;
29  
30      public File getOutputDirectory() {
31          return outputDirectory;
32      }
33  
34     
35      public void setOutputDirectory(File htmlDirectory) {
36          this.outputDirectory = htmlDirectory;
37      }
38  
39         /**
40       * @parameter expression="${rootPackage}" default-value="org.kuali.student.enrollment"
41       */
42      private String rootPackage;
43  
44      public String getRootPackage() {
45          return rootPackage;
46      }
47  
48      public void setRootPackage(String rootPackage) {
49          this.rootPackage = rootPackage;
50      }
51  
52      
53      
54  
55      @Override
56      public void execute() throws MojoExecutionException {
57          getLog().info("generating separate java interface files for each method in the service contracts");
58          ServiceContractModel model = this.getModel();
59          this.validate(model);
60          if (!outputDirectory.exists()) {
61              if (!outputDirectory.mkdirs()) {
62  //                throw new MojoExecutionException("Could not create directory "
63                  throw new IllegalArgumentException("Could not create directory "
64                          + this.outputDirectory.getPath());
65              }
66          }
67          String targetDirectory = this.outputDirectory.toString();
68          EachMethodServiceWriter instance =
69                  new EachMethodServiceWriter(model,
70                  targetDirectory,
71                  rootPackage,
72                  null);
73          instance.write();
74  
75      }
76  }