1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3 <head><meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4 <title>AbstractSchemaMojo xref</title>
5 <link type="text/css" rel="stylesheet" href="../../../../stylesheet.css" />
8 <div id="overview"><a href="../../../../../apidocs/de/juplo/plugins/hibernate/AbstractSchemaMojo.html">View Javadoc</a></div><pre>
9 <a class="jxr_linenumber" name="L1" href="#L1">1</a> <strong class="jxr_keyword">package</strong> de.juplo.plugins.hibernate;
10 <a class="jxr_linenumber" name="L2" href="#L2">2</a>
11 <a class="jxr_linenumber" name="L3" href="#L3">3</a>
12 <a class="jxr_linenumber" name="L4" href="#L4">4</a> <strong class="jxr_keyword">import</strong> com.pyx4j.log4j.MavenLogAppender;
13 <a class="jxr_linenumber" name="L5" href="#L5">5</a> <strong class="jxr_keyword">import</strong> java.io.File;
14 <a class="jxr_linenumber" name="L6" href="#L6">6</a> <strong class="jxr_keyword">import</strong> java.io.FileInputStream;
15 <a class="jxr_linenumber" name="L7" href="#L7">7</a> <strong class="jxr_keyword">import</strong> java.io.FileOutputStream;
16 <a class="jxr_linenumber" name="L8" href="#L8">8</a> <strong class="jxr_keyword">import</strong> java.io.IOException;
17 <a class="jxr_linenumber" name="L9" href="#L9">9</a> <strong class="jxr_keyword">import</strong> java.io.InputStream;
18 <a class="jxr_linenumber" name="L10" href="#L10">10</a> <strong class="jxr_keyword">import</strong> java.net.MalformedURLException;
19 <a class="jxr_linenumber" name="L11" href="#L11">11</a> <strong class="jxr_keyword">import</strong> java.net.URL;
20 <a class="jxr_linenumber" name="L12" href="#L12">12</a> <strong class="jxr_keyword">import</strong> java.security.NoSuchAlgorithmException;
21 <a class="jxr_linenumber" name="L13" href="#L13">13</a> <strong class="jxr_keyword">import</strong> java.time.ZonedDateTime;
22 <a class="jxr_linenumber" name="L14" href="#L14">14</a> <strong class="jxr_keyword">import</strong> java.util.Collections;
23 <a class="jxr_linenumber" name="L15" href="#L15">15</a> <strong class="jxr_keyword">import</strong> java.util.EnumSet;
24 <a class="jxr_linenumber" name="L16" href="#L16">16</a> <strong class="jxr_keyword">import</strong> java.util.HashMap;
25 <a class="jxr_linenumber" name="L17" href="#L17">17</a> <strong class="jxr_keyword">import</strong> java.util.HashSet;
26 <a class="jxr_linenumber" name="L18" href="#L18">18</a> <strong class="jxr_keyword">import</strong> java.util.Iterator;
27 <a class="jxr_linenumber" name="L19" href="#L19">19</a> <strong class="jxr_keyword">import</strong> java.util.LinkedHashSet;
28 <a class="jxr_linenumber" name="L20" href="#L20">20</a> <strong class="jxr_keyword">import</strong> java.util.List;
29 <a class="jxr_linenumber" name="L21" href="#L21">21</a> <strong class="jxr_keyword">import</strong> java.util.Map;
30 <a class="jxr_linenumber" name="L22" href="#L22">22</a> <strong class="jxr_keyword">import</strong> java.util.Map.Entry;
31 <a class="jxr_linenumber" name="L23" href="#L23">23</a> <strong class="jxr_keyword">import</strong> java.util.Properties;
32 <a class="jxr_linenumber" name="L24" href="#L24">24</a> <strong class="jxr_keyword">import</strong> java.util.Set;
33 <a class="jxr_linenumber" name="L25" href="#L25">25</a> <strong class="jxr_keyword">import</strong> java.util.regex.Matcher;
34 <a class="jxr_linenumber" name="L26" href="#L26">26</a> <strong class="jxr_keyword">import</strong> java.util.regex.Pattern;
35 <a class="jxr_linenumber" name="L27" href="#L27">27</a> <strong class="jxr_keyword">import</strong> javax.persistence.Embeddable;
36 <a class="jxr_linenumber" name="L28" href="#L28">28</a> <strong class="jxr_keyword">import</strong> javax.persistence.Entity;
37 <a class="jxr_linenumber" name="L29" href="#L29">29</a> <strong class="jxr_keyword">import</strong> javax.persistence.MappedSuperclass;
38 <a class="jxr_linenumber" name="L30" href="#L30">30</a> <strong class="jxr_keyword">import</strong> javax.persistence.spi.PersistenceUnitTransactionType;
39 <a class="jxr_linenumber" name="L31" href="#L31">31</a> <strong class="jxr_keyword">import</strong> org.apache.maven.artifact.Artifact;
40 <a class="jxr_linenumber" name="L32" href="#L32">32</a> <strong class="jxr_keyword">import</strong> org.apache.maven.model.Resource;
41 <a class="jxr_linenumber" name="L33" href="#L33">33</a> <strong class="jxr_keyword">import</strong> org.apache.maven.plugin.AbstractMojo;
42 <a class="jxr_linenumber" name="L34" href="#L34">34</a> <strong class="jxr_keyword">import</strong> org.apache.maven.plugin.MojoExecutionException;
43 <a class="jxr_linenumber" name="L35" href="#L35">35</a> <strong class="jxr_keyword">import</strong> org.apache.maven.plugin.MojoFailureException;
44 <a class="jxr_linenumber" name="L36" href="#L36">36</a> <strong class="jxr_keyword">import</strong> org.apache.maven.project.MavenProject;
45 <a class="jxr_linenumber" name="L37" href="#L37">37</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.MetadataBuilder;
46 <a class="jxr_linenumber" name="L38" href="#L38">38</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.MetadataSources;
47 <a class="jxr_linenumber" name="L39" href="#L39">39</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.cfgxml.internal.ConfigLoader;
48 <a class="jxr_linenumber" name="L40" href="#L40">40</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.cfgxml.spi.LoadedConfig;
49 <a class="jxr_linenumber" name="L41" href="#L41">41</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.cfgxml.spi.MappingReference;
50 <a class="jxr_linenumber" name="L42" href="#L42">42</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.model.naming.ImplicitNamingStrategy;
51 <a class="jxr_linenumber" name="L43" href="#L43">43</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.model.naming.PhysicalNamingStrategy;
52 <a class="jxr_linenumber" name="L44" href="#L44">44</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.BootstrapServiceRegistry;
53 <a class="jxr_linenumber" name="L45" href="#L45">45</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
54 <a class="jxr_linenumber" name="L46" href="#L46">46</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.StandardServiceRegistry;
55 <a class="jxr_linenumber" name="L47" href="#L47">47</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.StandardServiceRegistryBuilder;
56 <a class="jxr_linenumber" name="L48" href="#L48">48</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
57 <a class="jxr_linenumber" name="L49" href="#L49">49</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
58 <a class="jxr_linenumber" name="L50" href="#L50">50</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.selector.spi.StrategySelector;
59 <a class="jxr_linenumber" name="L51" href="#L51">51</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.spi.MetadataImplementor;
60 <a class="jxr_linenumber" name="L52" href="#L52">52</a> <strong class="jxr_keyword">import</strong> org.hibernate.cfg.AvailableSettings;
61 <a class="jxr_linenumber" name="L53" href="#L53">53</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.DIALECT;
62 <a class="jxr_linenumber" name="L54" href="#L54">54</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.DRIVER;
63 <a class="jxr_linenumber" name="L55" href="#L55">55</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.FORMAT_SQL;
64 <a class="jxr_linenumber" name="L56" href="#L56">56</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.HBM2DDL_DELIMITER;
65 <a class="jxr_linenumber" name="L57" href="#L57">57</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.HBM2DLL_CREATE_NAMESPACES;
66 <a class="jxr_linenumber" name="L58" href="#L58">58</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.IMPLICIT_NAMING_STRATEGY;
67 <a class="jxr_linenumber" name="L59" href="#L59">59</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.JPA_JDBC_DRIVER;
68 <a class="jxr_linenumber" name="L60" href="#L60">60</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.JPA_JDBC_PASSWORD;
69 <a class="jxr_linenumber" name="L61" href="#L61">61</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.JPA_JDBC_URL;
70 <a class="jxr_linenumber" name="L62" href="#L62">62</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.JPA_JDBC_USER;
71 <a class="jxr_linenumber" name="L63" href="#L63">63</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.PASS;
72 <a class="jxr_linenumber" name="L64" href="#L64">64</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.PHYSICAL_NAMING_STRATEGY;
73 <a class="jxr_linenumber" name="L65" href="#L65">65</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.SHOW_SQL;
74 <a class="jxr_linenumber" name="L66" href="#L66">66</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.USER;
75 <a class="jxr_linenumber" name="L67" href="#L67">67</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.hibernate.cfg.AvailableSettings.URL;
76 <a class="jxr_linenumber" name="L68" href="#L68">68</a> <strong class="jxr_keyword">import</strong> org.hibernate.engine.config.spi.ConfigurationService;
77 <a class="jxr_linenumber" name="L69" href="#L69">69</a> <strong class="jxr_keyword">import</strong> org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
78 <a class="jxr_linenumber" name="L70" href="#L70">70</a> <strong class="jxr_keyword">import</strong> org.hibernate.internal.util.config.ConfigurationException;
79 <a class="jxr_linenumber" name="L71" href="#L71">71</a> <strong class="jxr_keyword">import</strong> org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
80 <a class="jxr_linenumber" name="L72" href="#L72">72</a> <strong class="jxr_keyword">import</strong> org.hibernate.jpa.boot.internal.PersistenceXmlParser;
81 <a class="jxr_linenumber" name="L73" href="#L73">73</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.schema.TargetType;
82 <a class="jxr_linenumber" name="L74" href="#L74">74</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.schema.internal.ExceptionHandlerCollectingImpl;
83 <a class="jxr_linenumber" name="L75" href="#L75">75</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.schema.internal.exec.ScriptTargetOutputToFile;
84 <a class="jxr_linenumber" name="L76" href="#L76">76</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.schema.spi.ExecutionOptions;
85 <a class="jxr_linenumber" name="L77" href="#L77">77</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
86 <a class="jxr_linenumber" name="L78" href="#L78">78</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.schema.spi.ScriptTargetOutput;
87 <a class="jxr_linenumber" name="L79" href="#L79">79</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.schema.spi.TargetDescriptor;
88 <a class="jxr_linenumber" name="L80" href="#L80">80</a> <strong class="jxr_keyword">import</strong> org.scannotation.AnnotationDB;
89 <a class="jxr_linenumber" name="L81" href="#L81">81</a>
90 <a class="jxr_linenumber" name="L82" href="#L82">82</a>
91 <a class="jxr_linenumber" name="L83" href="#L83">83</a> <em class="jxr_javadoccomment">/**</em>
92 <a class="jxr_linenumber" name="L84" href="#L84">84</a> <em class="jxr_javadoccomment"> * Baseclass with common attributes and methods.</em>
93 <a class="jxr_linenumber" name="L85" href="#L85">85</a> <em class="jxr_javadoccomment"> *</em>
94 <a class="jxr_linenumber" name="L86" href="#L86">86</a> <em class="jxr_javadoccomment"> * @phase process-classes</em>
95 <a class="jxr_linenumber" name="L87" href="#L87">87</a> <em class="jxr_javadoccomment"> * @threadSafe</em>
96 <a class="jxr_linenumber" name="L88" href="#L88">88</a> <em class="jxr_javadoccomment"> * @requiresDependencyResolution runtime</em>
97 <a class="jxr_linenumber" name="L89" href="#L89">89</a> <em class="jxr_javadoccomment"> */</em>
98 <a class="jxr_linenumber" name="L90" href="#L90">90</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">abstract</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../de/juplo/plugins/hibernate/AbstractSchemaMojo.html">AbstractSchemaMojo</a> <strong class="jxr_keyword">extends</strong> AbstractMojo
99 <a class="jxr_linenumber" name="L91" href="#L91">91</a> {
100 <a class="jxr_linenumber" name="L92" href="#L92">92</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String EXECUTE = <span class="jxr_string">"hibernate.schema.execute"</span>;
101 <a class="jxr_linenumber" name="L93" href="#L93">93</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String OUTPUTDIRECTORY = <span class="jxr_string">"project.build.outputDirectory"</span>;
102 <a class="jxr_linenumber" name="L94" href="#L94">94</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String SCAN_CLASSES = <span class="jxr_string">"hibernate.schema.scan.classes"</span>;
103 <a class="jxr_linenumber" name="L95" href="#L95">95</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String SCAN_DEPENDENCIES = <span class="jxr_string">"hibernate.schema.scan.dependencies"</span>;
104 <a class="jxr_linenumber" name="L96" href="#L96">96</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String SCAN_TESTCLASSES = <span class="jxr_string">"hibernate.schema.scan.test_classes"</span>;
105 <a class="jxr_linenumber" name="L97" href="#L97">97</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String TEST_OUTPUTDIRECTORY = <span class="jxr_string">"project.build.testOutputDirectory"</span>;
106 <a class="jxr_linenumber" name="L98" href="#L98">98</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String SKIPPED = <span class="jxr_string">"hibernate.schema.skipped"</span>;
107 <a class="jxr_linenumber" name="L99" href="#L99">99</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String SCRIPT = <span class="jxr_string">"hibernate.schema.script"</span>;
108 <a class="jxr_linenumber" name="L100" href="#L100">100</a>
109 <a class="jxr_linenumber" name="L101" href="#L101">101</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> Pattern SPLIT = Pattern.compile(<span class="jxr_string">"[^,\\s]+"</span>);
110 <a class="jxr_linenumber" name="L102" href="#L102">102</a>
111 <a class="jxr_linenumber" name="L103" href="#L103">103</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Set<String> packages = <strong class="jxr_keyword">new</strong> HashSet<String>();
112 <a class="jxr_linenumber" name="L104" href="#L104">104</a>
113 <a class="jxr_linenumber" name="L105" href="#L105">105</a>
114 <a class="jxr_linenumber" name="L106" href="#L106">106</a> <em class="jxr_javadoccomment">/**</em>
115 <a class="jxr_linenumber" name="L107" href="#L107">107</a> <em class="jxr_javadoccomment"> * The maven project.</em>
116 <a class="jxr_linenumber" name="L108" href="#L108">108</a> <em class="jxr_javadoccomment"> * <p></em>
117 <a class="jxr_linenumber" name="L109" href="#L109">109</a> <em class="jxr_javadoccomment"> * Only needed internally.</em>
118 <a class="jxr_linenumber" name="L110" href="#L110">110</a> <em class="jxr_javadoccomment"> *</em>
119 <a class="jxr_linenumber" name="L111" href="#L111">111</a> <em class="jxr_javadoccomment"> * @parameter property="project"</em>
120 <a class="jxr_linenumber" name="L112" href="#L112">112</a> <em class="jxr_javadoccomment"> * @required</em>
121 <a class="jxr_linenumber" name="L113" href="#L113">113</a> <em class="jxr_javadoccomment"> * @readonly</em>
122 <a class="jxr_linenumber" name="L114" href="#L114">114</a> <em class="jxr_javadoccomment"> */</em>
123 <a class="jxr_linenumber" name="L115" href="#L115">115</a> <strong class="jxr_keyword">private</strong> MavenProject project;
124 <a class="jxr_linenumber" name="L116" href="#L116">116</a>
125 <a class="jxr_linenumber" name="L117" href="#L117">117</a> <em class="jxr_javadoccomment">/**</em>
126 <a class="jxr_linenumber" name="L118" href="#L118">118</a> <em class="jxr_javadoccomment"> * Build-directory.</em>
127 <a class="jxr_linenumber" name="L119" href="#L119">119</a> <em class="jxr_javadoccomment"> * <p></em>
128 <a class="jxr_linenumber" name="L120" href="#L120">120</a> <em class="jxr_javadoccomment"> * Only needed internally.</em>
129 <a class="jxr_linenumber" name="L121" href="#L121">121</a> <em class="jxr_javadoccomment"> *</em>
130 <a class="jxr_linenumber" name="L122" href="#L122">122</a> <em class="jxr_javadoccomment"> * @parameter property="project.build.directory"</em>
131 <a class="jxr_linenumber" name="L123" href="#L123">123</a> <em class="jxr_javadoccomment"> * @required</em>
132 <a class="jxr_linenumber" name="L124" href="#L124">124</a> <em class="jxr_javadoccomment"> * @readonly</em>
133 <a class="jxr_linenumber" name="L125" href="#L125">125</a> <em class="jxr_javadoccomment"> */</em>
134 <a class="jxr_linenumber" name="L126" href="#L126">126</a> <strong class="jxr_keyword">private</strong> String buildDirectory;
135 <a class="jxr_linenumber" name="L127" href="#L127">127</a>
136 <a class="jxr_linenumber" name="L128" href="#L128">128</a>
137 <a class="jxr_linenumber" name="L129" href="#L129">129</a> <em class="jxr_javadoccomment">/** Parameters to configure the genaration of the SQL *********************/</em>
138 <a class="jxr_linenumber" name="L130" href="#L130">130</a>
139 <a class="jxr_linenumber" name="L131" href="#L131">131</a> <em class="jxr_javadoccomment">/**</em>
140 <a class="jxr_linenumber" name="L132" href="#L132">132</a> <em class="jxr_javadoccomment"> * Excecute the generated SQL.</em>
141 <a class="jxr_linenumber" name="L133" href="#L133">133</a> <em class="jxr_javadoccomment"> * If set to <code>false</code>, only the SQL-script is created and the</em>
142 <a class="jxr_linenumber" name="L134" href="#L134">134</a> <em class="jxr_javadoccomment"> * database is not touched.</em>
143 <a class="jxr_linenumber" name="L135" href="#L135">135</a> <em class="jxr_javadoccomment"> * <p></em>
144 <a class="jxr_linenumber" name="L136" href="#L136">136</a> <em class="jxr_javadoccomment"> * <strong>Important:</strong></em>
145 <a class="jxr_linenumber" name="L137" href="#L137">137</a> <em class="jxr_javadoccomment"> * This configuration value can only be configured through the</em>
146 <a class="jxr_linenumber" name="L138" href="#L138">138</a> <em class="jxr_javadoccomment"> * <code>pom.xml</code>, or by the definition of a system-property, because</em>
147 <a class="jxr_linenumber" name="L139" href="#L139">139</a> <em class="jxr_javadoccomment"> * it is not known by Hibernate nor JPA and, hence, not picked up from</em>
148 <a class="jxr_linenumber" name="L140" href="#L140">140</a> <em class="jxr_javadoccomment"> * their configuration!</em>
149 <a class="jxr_linenumber" name="L141" href="#L141">141</a> <em class="jxr_javadoccomment"> *</em>
150 <a class="jxr_linenumber" name="L142" href="#L142">142</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.schema.execute" default-value="true"</em>
151 <a class="jxr_linenumber" name="L143" href="#L143">143</a> <em class="jxr_javadoccomment"> * @since 2.0</em>
152 <a class="jxr_linenumber" name="L144" href="#L144">144</a> <em class="jxr_javadoccomment"> */</em>
153 <a class="jxr_linenumber" name="L145" href="#L145">145</a> <strong class="jxr_keyword">private</strong> Boolean execute;
154 <a class="jxr_linenumber" name="L146" href="#L146">146</a>
155 <a class="jxr_linenumber" name="L147" href="#L147">147</a> <em class="jxr_javadoccomment">/**</em>
156 <a class="jxr_linenumber" name="L148" href="#L148">148</a> <em class="jxr_javadoccomment"> * Skip execution</em>
157 <a class="jxr_linenumber" name="L149" href="#L149">149</a> <em class="jxr_javadoccomment"> * <p></em>
158 <a class="jxr_linenumber" name="L150" href="#L150">150</a> <em class="jxr_javadoccomment"> * If set to <code>true</code>, the execution is skipped.</em>
159 <a class="jxr_linenumber" name="L151" href="#L151">151</a> <em class="jxr_javadoccomment"> * <p></em>
160 <a class="jxr_linenumber" name="L152" href="#L152">152</a> <em class="jxr_javadoccomment"> * A skipped execution is signaled via the maven-property</em>
161 <a class="jxr_linenumber" name="L153" href="#L153">153</a> <em class="jxr_javadoccomment"> * <code>${hibernate.schema.skipped}</code>.</em>
162 <a class="jxr_linenumber" name="L154" href="#L154">154</a> <em class="jxr_javadoccomment"> * <p></em>
163 <a class="jxr_linenumber" name="L155" href="#L155">155</a> <em class="jxr_javadoccomment"> * The execution is skipped automatically, if no modified or newly added</em>
164 <a class="jxr_linenumber" name="L156" href="#L156">156</a> <em class="jxr_javadoccomment"> * annotated classes are found and the dialect was not changed.</em>
165 <a class="jxr_linenumber" name="L157" href="#L157">157</a> <em class="jxr_javadoccomment"> * <p></em>
166 <a class="jxr_linenumber" name="L158" href="#L158">158</a> <em class="jxr_javadoccomment"> * <strong>Important:</strong></em>
167 <a class="jxr_linenumber" name="L159" href="#L159">159</a> <em class="jxr_javadoccomment"> * This configuration value can only be configured through the</em>
168 <a class="jxr_linenumber" name="L160" href="#L160">160</a> <em class="jxr_javadoccomment"> * <code>pom.xml</code>, or by the definition of a system-property, because</em>
169 <a class="jxr_linenumber" name="L161" href="#L161">161</a> <em class="jxr_javadoccomment"> * it is not known by Hibernate nor JPA and, hence, not picked up from</em>
170 <a class="jxr_linenumber" name="L162" href="#L162">162</a> <em class="jxr_javadoccomment"> * their configuration!</em>
171 <a class="jxr_linenumber" name="L163" href="#L163">163</a> <em class="jxr_javadoccomment"> *</em>
172 <a class="jxr_linenumber" name="L164" href="#L164">164</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.schema.skip" default-value="${maven.test.skip}"</em>
173 <a class="jxr_linenumber" name="L165" href="#L165">165</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
174 <a class="jxr_linenumber" name="L166" href="#L166">166</a> <em class="jxr_javadoccomment"> */</em>
175 <a class="jxr_linenumber" name="L167" href="#L167">167</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> skip;
176 <a class="jxr_linenumber" name="L168" href="#L168">168</a>
177 <a class="jxr_linenumber" name="L169" href="#L169">169</a> <em class="jxr_javadoccomment">/**</em>
178 <a class="jxr_linenumber" name="L170" href="#L170">170</a> <em class="jxr_javadoccomment"> * Force generation/execution</em>
179 <a class="jxr_linenumber" name="L171" href="#L171">171</a> <em class="jxr_javadoccomment"> * <p></em>
180 <a class="jxr_linenumber" name="L172" href="#L172">172</a> <em class="jxr_javadoccomment"> * Force the generation and (if configured) the execution of the SQL, even if</em>
181 <a class="jxr_linenumber" name="L173" href="#L173">173</a> <em class="jxr_javadoccomment"> * no modified or newly added annotated classes where found and the</em>
182 <a class="jxr_linenumber" name="L174" href="#L174">174</a> <em class="jxr_javadoccomment"> * configuration was not changed.</em>
183 <a class="jxr_linenumber" name="L175" href="#L175">175</a> <em class="jxr_javadoccomment"> * <p></em>
184 <a class="jxr_linenumber" name="L176" href="#L176">176</a> <em class="jxr_javadoccomment"> * <code>skip</code> takes precedence over <code>force</code>.</em>
185 <a class="jxr_linenumber" name="L177" href="#L177">177</a> <em class="jxr_javadoccomment"> * <p></em>
186 <a class="jxr_linenumber" name="L178" href="#L178">178</a> <em class="jxr_javadoccomment"> * <strong>Important:</strong></em>
187 <a class="jxr_linenumber" name="L179" href="#L179">179</a> <em class="jxr_javadoccomment"> * This configuration value can only be configured through the</em>
188 <a class="jxr_linenumber" name="L180" href="#L180">180</a> <em class="jxr_javadoccomment"> * <code>pom.xml</code>, or by the definition of a system-property, because</em>
189 <a class="jxr_linenumber" name="L181" href="#L181">181</a> <em class="jxr_javadoccomment"> * it is not known by Hibernate nor JPA and, hence, not picked up from</em>
190 <a class="jxr_linenumber" name="L182" href="#L182">182</a> <em class="jxr_javadoccomment"> * their configuration!</em>
191 <a class="jxr_linenumber" name="L183" href="#L183">183</a> <em class="jxr_javadoccomment"> *</em>
192 <a class="jxr_linenumber" name="L184" href="#L184">184</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.schema.force" default-value="false"</em>
193 <a class="jxr_linenumber" name="L185" href="#L185">185</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
194 <a class="jxr_linenumber" name="L186" href="#L186">186</a> <em class="jxr_javadoccomment"> */</em>
195 <a class="jxr_linenumber" name="L187" href="#L187">187</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> force;
196 <a class="jxr_linenumber" name="L188" href="#L188">188</a>
197 <a class="jxr_linenumber" name="L189" href="#L189">189</a> <em class="jxr_javadoccomment">/**</em>
198 <a class="jxr_linenumber" name="L190" href="#L190">190</a> <em class="jxr_javadoccomment"> * Hibernate dialect.</em>
199 <a class="jxr_linenumber" name="L191" href="#L191">191</a> <em class="jxr_javadoccomment"> *</em>
200 <a class="jxr_linenumber" name="L192" href="#L192">192</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.dialect"</em>
201 <a class="jxr_linenumber" name="L193" href="#L193">193</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
202 <a class="jxr_linenumber" name="L194" href="#L194">194</a> <em class="jxr_javadoccomment"> */</em>
203 <a class="jxr_linenumber" name="L195" href="#L195">195</a> <strong class="jxr_keyword">private</strong> String dialect;
204 <a class="jxr_linenumber" name="L196" href="#L196">196</a>
205 <a class="jxr_linenumber" name="L197" href="#L197">197</a> <em class="jxr_javadoccomment">/**</em>
206 <a class="jxr_linenumber" name="L198" href="#L198">198</a> <em class="jxr_javadoccomment"> * Delimiter in output-file.</em>
207 <a class="jxr_linenumber" name="L199" href="#L199">199</a> <em class="jxr_javadoccomment"> * <p></em>
208 <a class="jxr_linenumber" name="L200" href="#L200">200</a> <em class="jxr_javadoccomment"> * <strong>Important:</strong></em>
209 <a class="jxr_linenumber" name="L201" href="#L201">201</a> <em class="jxr_javadoccomment"> * This configuration value can only be configured through the</em>
210 <a class="jxr_linenumber" name="L202" href="#L202">202</a> <em class="jxr_javadoccomment"> * <code>pom.xml</code>, or by the definition of a system-property, because</em>
211 <a class="jxr_linenumber" name="L203" href="#L203">203</a> <em class="jxr_javadoccomment"> * it is not known by Hibernate nor JPA and, hence, not picked up from</em>
212 <a class="jxr_linenumber" name="L204" href="#L204">204</a> <em class="jxr_javadoccomment"> * their configuration!</em>
213 <a class="jxr_linenumber" name="L205" href="#L205">205</a> <em class="jxr_javadoccomment"> *</em>
214 <a class="jxr_linenumber" name="L206" href="#L206">206</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.hbm2ddl.delimiter" default-value=";"</em>
215 <a class="jxr_linenumber" name="L207" href="#L207">207</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
216 <a class="jxr_linenumber" name="L208" href="#L208">208</a> <em class="jxr_javadoccomment"> */</em>
217 <a class="jxr_linenumber" name="L209" href="#L209">209</a> <strong class="jxr_keyword">private</strong> String delimiter;
218 <a class="jxr_linenumber" name="L210" href="#L210">210</a>
219 <a class="jxr_linenumber" name="L211" href="#L211">211</a> <em class="jxr_javadoccomment">/**</em>
220 <a class="jxr_linenumber" name="L212" href="#L212">212</a> <em class="jxr_javadoccomment"> * Show the generated SQL in the command-line output.</em>
221 <a class="jxr_linenumber" name="L213" href="#L213">213</a> <em class="jxr_javadoccomment"> *</em>
222 <a class="jxr_linenumber" name="L214" href="#L214">214</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.show_sql"</em>
223 <a class="jxr_linenumber" name="L215" href="#L215">215</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
224 <a class="jxr_linenumber" name="L216" href="#L216">216</a> <em class="jxr_javadoccomment"> */</em>
225 <a class="jxr_linenumber" name="L217" href="#L217">217</a> <strong class="jxr_keyword">private</strong> Boolean show;
226 <a class="jxr_linenumber" name="L218" href="#L218">218</a>
227 <a class="jxr_linenumber" name="L219" href="#L219">219</a> <em class="jxr_javadoccomment">/**</em>
228 <a class="jxr_linenumber" name="L220" href="#L220">220</a> <em class="jxr_javadoccomment"> * Format output-file.</em>
229 <a class="jxr_linenumber" name="L221" href="#L221">221</a> <em class="jxr_javadoccomment"> *</em>
230 <a class="jxr_linenumber" name="L222" href="#L222">222</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.format_sql"</em>
231 <a class="jxr_linenumber" name="L223" href="#L223">223</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
232 <a class="jxr_linenumber" name="L224" href="#L224">224</a> <em class="jxr_javadoccomment"> */</em>
233 <a class="jxr_linenumber" name="L225" href="#L225">225</a> <strong class="jxr_keyword">private</strong> Boolean format;
234 <a class="jxr_linenumber" name="L226" href="#L226">226</a>
235 <a class="jxr_linenumber" name="L227" href="#L227">227</a> <em class="jxr_javadoccomment">/**</em>
236 <a class="jxr_linenumber" name="L228" href="#L228">228</a> <em class="jxr_javadoccomment"> * Specifies whether to automatically create also the database schema/catalog.</em>
237 <a class="jxr_linenumber" name="L229" href="#L229">229</a> <em class="jxr_javadoccomment"> *</em>
238 <a class="jxr_linenumber" name="L230" href="#L230">230</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.hbm2dll.create_namespaces" default-value="false"</em>
239 <a class="jxr_linenumber" name="L231" href="#L231">231</a> <em class="jxr_javadoccomment"> * @since 2.0</em>
240 <a class="jxr_linenumber" name="L232" href="#L232">232</a> <em class="jxr_javadoccomment"> */</em>
241 <a class="jxr_linenumber" name="L233" href="#L233">233</a> <strong class="jxr_keyword">private</strong> Boolean createNamespaces;
242 <a class="jxr_linenumber" name="L234" href="#L234">234</a>
243 <a class="jxr_linenumber" name="L235" href="#L235">235</a> <em class="jxr_javadoccomment">/**</em>
244 <a class="jxr_linenumber" name="L236" href="#L236">236</a> <em class="jxr_javadoccomment"> * Implicit naming strategy</em>
245 <a class="jxr_linenumber" name="L237" href="#L237">237</a> <em class="jxr_javadoccomment"> *</em>
246 <a class="jxr_linenumber" name="L238" href="#L238">238</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.implicit_naming_strategy"</em>
247 <a class="jxr_linenumber" name="L239" href="#L239">239</a> <em class="jxr_javadoccomment"> * @since 2.0</em>
248 <a class="jxr_linenumber" name="L240" href="#L240">240</a> <em class="jxr_javadoccomment"> */</em>
249 <a class="jxr_linenumber" name="L241" href="#L241">241</a> <strong class="jxr_keyword">private</strong> String implicitNamingStrategy;
250 <a class="jxr_linenumber" name="L242" href="#L242">242</a>
251 <a class="jxr_linenumber" name="L243" href="#L243">243</a> <em class="jxr_javadoccomment">/**</em>
252 <a class="jxr_linenumber" name="L244" href="#L244">244</a> <em class="jxr_javadoccomment"> * Physical naming strategy</em>
253 <a class="jxr_linenumber" name="L245" href="#L245">245</a> <em class="jxr_javadoccomment"> *</em>
254 <a class="jxr_linenumber" name="L246" href="#L246">246</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.physical_naming_strategy"</em>
255 <a class="jxr_linenumber" name="L247" href="#L247">247</a> <em class="jxr_javadoccomment"> * @since 2.0</em>
256 <a class="jxr_linenumber" name="L248" href="#L248">248</a> <em class="jxr_javadoccomment"> */</em>
257 <a class="jxr_linenumber" name="L249" href="#L249">249</a> <strong class="jxr_keyword">private</strong> String physicalNamingStrategy;
258 <a class="jxr_linenumber" name="L250" href="#L250">250</a>
259 <a class="jxr_linenumber" name="L251" href="#L251">251</a> <em class="jxr_javadoccomment">/**</em>
260 <a class="jxr_linenumber" name="L252" href="#L252">252</a> <em class="jxr_javadoccomment"> * Wether the project should be scanned for annotated-classes, or not</em>
261 <a class="jxr_linenumber" name="L253" href="#L253">253</a> <em class="jxr_javadoccomment"> * <p></em>
262 <a class="jxr_linenumber" name="L254" href="#L254">254</a> <em class="jxr_javadoccomment"> * This parameter is intended to allow overwriting of the parameter</em>
263 <a class="jxr_linenumber" name="L255" href="#L255">255</a> <em class="jxr_javadoccomment"> * <code>exclude-unlisted-classes</code> of a <code>persistence-unit</code>.</em>
264 <a class="jxr_linenumber" name="L256" href="#L256">256</a> <em class="jxr_javadoccomment"> * If not specified, it defaults to <code>true</code></em>
265 <a class="jxr_linenumber" name="L257" href="#L257">257</a> <em class="jxr_javadoccomment"> *</em>
266 <a class="jxr_linenumber" name="L258" href="#L258">258</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.schema.scan.classes"</em>
267 <a class="jxr_linenumber" name="L259" href="#L259">259</a> <em class="jxr_javadoccomment"> * @since 2.0</em>
268 <a class="jxr_linenumber" name="L260" href="#L260">260</a> <em class="jxr_javadoccomment"> */</em>
269 <a class="jxr_linenumber" name="L261" href="#L261">261</a> <strong class="jxr_keyword">private</strong> Boolean scanClasses;
270 <a class="jxr_linenumber" name="L262" href="#L262">262</a>
271 <a class="jxr_linenumber" name="L263" href="#L263">263</a> <em class="jxr_javadoccomment">/**</em>
272 <a class="jxr_linenumber" name="L264" href="#L264">264</a> <em class="jxr_javadoccomment"> * Classes-Directory to scan.</em>
273 <a class="jxr_linenumber" name="L265" href="#L265">265</a> <em class="jxr_javadoccomment"> * <p></em>
274 <a class="jxr_linenumber" name="L266" href="#L266">266</a> <em class="jxr_javadoccomment"> * This parameter defaults to the maven build-output-directory for classes.</em>
275 <a class="jxr_linenumber" name="L267" href="#L267">267</a> <em class="jxr_javadoccomment"> * Additionally, all dependencies are scanned for annotated classes.</em>
276 <a class="jxr_linenumber" name="L268" href="#L268">268</a> <em class="jxr_javadoccomment"> * <p></em>
277 <a class="jxr_linenumber" name="L269" href="#L269">269</a> <em class="jxr_javadoccomment"> * <strong>Important:</strong></em>
278 <a class="jxr_linenumber" name="L270" href="#L270">270</a> <em class="jxr_javadoccomment"> * This configuration value can only be configured through the</em>
279 <a class="jxr_linenumber" name="L271" href="#L271">271</a> <em class="jxr_javadoccomment"> * <code>pom.xml</code>, or by the definition of a system-property, because</em>
280 <a class="jxr_linenumber" name="L272" href="#L272">272</a> <em class="jxr_javadoccomment"> * it is not known by Hibernate nor JPA and, hence, not picked up from</em>
281 <a class="jxr_linenumber" name="L273" href="#L273">273</a> <em class="jxr_javadoccomment"> * their configuration!</em>
282 <a class="jxr_linenumber" name="L274" href="#L274">274</a> <em class="jxr_javadoccomment"> *</em>
283 <a class="jxr_linenumber" name="L275" href="#L275">275</a> <em class="jxr_javadoccomment"> * @parameter property="project.build.outputDirectory"</em>
284 <a class="jxr_linenumber" name="L276" href="#L276">276</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
285 <a class="jxr_linenumber" name="L277" href="#L277">277</a> <em class="jxr_javadoccomment"> */</em>
286 <a class="jxr_linenumber" name="L278" href="#L278">278</a> <strong class="jxr_keyword">private</strong> String outputDirectory;
287 <a class="jxr_linenumber" name="L279" href="#L279">279</a>
288 <a class="jxr_linenumber" name="L280" href="#L280">280</a> <em class="jxr_javadoccomment">/**</em>
289 <a class="jxr_linenumber" name="L281" href="#L281">281</a> <em class="jxr_javadoccomment"> * Dependency-Scopes, that should be scanned for annotated classes.</em>
290 <a class="jxr_linenumber" name="L282" href="#L282">282</a> <em class="jxr_javadoccomment"> * <p></em>
291 <a class="jxr_linenumber" name="L283" href="#L283">283</a> <em class="jxr_javadoccomment"> * By default, only dependencies in the scope <code>compile</code> are</em>
292 <a class="jxr_linenumber" name="L284" href="#L284">284</a> <em class="jxr_javadoccomment"> * scanned for annotated classes. Multiple scopes can be seperated by</em>
293 <a class="jxr_linenumber" name="L285" href="#L285">285</a> <em class="jxr_javadoccomment"> * white space or commas.</em>
294 <a class="jxr_linenumber" name="L286" href="#L286">286</a> <em class="jxr_javadoccomment"> * <p></em>
295 <a class="jxr_linenumber" name="L287" href="#L287">287</a> <em class="jxr_javadoccomment"> * If you do not want any dependencies to be scanned for annotated</em>
296 <a class="jxr_linenumber" name="L288" href="#L288">288</a> <em class="jxr_javadoccomment"> * classes, set this parameter to <code>none</code>.</em>
297 <a class="jxr_linenumber" name="L289" href="#L289">289</a> <em class="jxr_javadoccomment"> * <p></em>
298 <a class="jxr_linenumber" name="L290" href="#L290">290</a> <em class="jxr_javadoccomment"> * The plugin does not scan for annotated classes in transitive</em>
299 <a class="jxr_linenumber" name="L291" href="#L291">291</a> <em class="jxr_javadoccomment"> * dependencies. If some of your annotated classes are hidden in a</em>
300 <a class="jxr_linenumber" name="L292" href="#L292">292</a> <em class="jxr_javadoccomment"> * transitive dependency, you can simply add that dependency explicitly.</em>
301 <a class="jxr_linenumber" name="L293" href="#L293">293</a> <em class="jxr_javadoccomment"> *</em>
302 <a class="jxr_linenumber" name="L294" href="#L294">294</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.schema.scan.dependencies" default-value="compile"</em>
303 <a class="jxr_linenumber" name="L295" href="#L295">295</a> <em class="jxr_javadoccomment"> * @since 1.0.3</em>
304 <a class="jxr_linenumber" name="L296" href="#L296">296</a> <em class="jxr_javadoccomment"> */</em>
305 <a class="jxr_linenumber" name="L297" href="#L297">297</a> <strong class="jxr_keyword">private</strong> String scanDependencies;
306 <a class="jxr_linenumber" name="L298" href="#L298">298</a>
307 <a class="jxr_linenumber" name="L299" href="#L299">299</a> <em class="jxr_javadoccomment">/**</em>
308 <a class="jxr_linenumber" name="L300" href="#L300">300</a> <em class="jxr_javadoccomment"> * Whether to scan the test-branch of the project for annotated classes, or</em>
309 <a class="jxr_linenumber" name="L301" href="#L301">301</a> <em class="jxr_javadoccomment"> * not.</em>
310 <a class="jxr_linenumber" name="L302" href="#L302">302</a> <em class="jxr_javadoccomment"> * <p></em>
311 <a class="jxr_linenumber" name="L303" href="#L303">303</a> <em class="jxr_javadoccomment"> * If this parameter is set to <code>true</code> the test-classes of the</em>
312 <a class="jxr_linenumber" name="L304" href="#L304">304</a> <em class="jxr_javadoccomment"> * artifact will be scanned for hibernate-annotated classes additionally.</em>
313 <a class="jxr_linenumber" name="L305" href="#L305">305</a> <em class="jxr_javadoccomment"> * <p></em>
314 <a class="jxr_linenumber" name="L306" href="#L306">306</a> <em class="jxr_javadoccomment"> * <strong>Important:</strong></em>
315 <a class="jxr_linenumber" name="L307" href="#L307">307</a> <em class="jxr_javadoccomment"> * This configuration value can only be configured through the</em>
316 <a class="jxr_linenumber" name="L308" href="#L308">308</a> <em class="jxr_javadoccomment"> * <code>pom.xml</code>, or by the definition of a system-property, because</em>
317 <a class="jxr_linenumber" name="L309" href="#L309">309</a> <em class="jxr_javadoccomment"> * it is not known by Hibernate nor JPA and, hence, not picked up from</em>
318 <a class="jxr_linenumber" name="L310" href="#L310">310</a> <em class="jxr_javadoccomment"> * their configuration!</em>
319 <a class="jxr_linenumber" name="L311" href="#L311">311</a> <em class="jxr_javadoccomment"> *</em>
320 <a class="jxr_linenumber" name="L312" href="#L312">312</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.schema.scan.test_classes" default-value="false"</em>
321 <a class="jxr_linenumber" name="L313" href="#L313">313</a> <em class="jxr_javadoccomment"> * @since 1.0.1</em>
322 <a class="jxr_linenumber" name="L314" href="#L314">314</a> <em class="jxr_javadoccomment"> */</em>
323 <a class="jxr_linenumber" name="L315" href="#L315">315</a> <strong class="jxr_keyword">private</strong> Boolean scanTestClasses;
324 <a class="jxr_linenumber" name="L316" href="#L316">316</a>
325 <a class="jxr_linenumber" name="L317" href="#L317">317</a> <em class="jxr_javadoccomment">/**</em>
326 <a class="jxr_linenumber" name="L318" href="#L318">318</a> <em class="jxr_javadoccomment"> * Test-Classes-Directory to scan.</em>
327 <a class="jxr_linenumber" name="L319" href="#L319">319</a> <em class="jxr_javadoccomment"> * <p></em>
328 <a class="jxr_linenumber" name="L320" href="#L320">320</a> <em class="jxr_javadoccomment"> * This parameter defaults to the maven build-output-directory for</em>
329 <a class="jxr_linenumber" name="L321" href="#L321">321</a> <em class="jxr_javadoccomment"> * test-classes.</em>
330 <a class="jxr_linenumber" name="L322" href="#L322">322</a> <em class="jxr_javadoccomment"> * <p></em>
331 <a class="jxr_linenumber" name="L323" href="#L323">323</a> <em class="jxr_javadoccomment"> * This parameter is only used, when <code>scanTestClasses</code> is set</em>
332 <a class="jxr_linenumber" name="L324" href="#L324">324</a> <em class="jxr_javadoccomment"> * to <code>true</code>!</em>
333 <a class="jxr_linenumber" name="L325" href="#L325">325</a> <em class="jxr_javadoccomment"> * <p></em>
334 <a class="jxr_linenumber" name="L326" href="#L326">326</a> <em class="jxr_javadoccomment"> * <strong>Important:</strong></em>
335 <a class="jxr_linenumber" name="L327" href="#L327">327</a> <em class="jxr_javadoccomment"> * This configuration value can only be configured through the</em>
336 <a class="jxr_linenumber" name="L328" href="#L328">328</a> <em class="jxr_javadoccomment"> * <code>pom.xml</code>, or by the definition of a system-property, because</em>
337 <a class="jxr_linenumber" name="L329" href="#L329">329</a> <em class="jxr_javadoccomment"> * it is not known by Hibernate nor JPA and, hence, not picked up from</em>
338 <a class="jxr_linenumber" name="L330" href="#L330">330</a> <em class="jxr_javadoccomment"> * their configuration!</em>
339 <a class="jxr_linenumber" name="L331" href="#L331">331</a> <em class="jxr_javadoccomment"> *</em>
340 <a class="jxr_linenumber" name="L332" href="#L332">332</a> <em class="jxr_javadoccomment"> * @parameter property="project.build.testOutputDirectory"</em>
341 <a class="jxr_linenumber" name="L333" href="#L333">333</a> <em class="jxr_javadoccomment"> * @since 1.0.2</em>
342 <a class="jxr_linenumber" name="L334" href="#L334">334</a> <em class="jxr_javadoccomment"> */</em>
343 <a class="jxr_linenumber" name="L335" href="#L335">335</a> <strong class="jxr_keyword">private</strong> String testOutputDirectory;
344 <a class="jxr_linenumber" name="L336" href="#L336">336</a>
345 <a class="jxr_linenumber" name="L337" href="#L337">337</a>
346 <a class="jxr_linenumber" name="L338" href="#L338">338</a> <em class="jxr_javadoccomment">/** Conection parameters *************************************************/</em>
347 <a class="jxr_linenumber" name="L339" href="#L339">339</a>
348 <a class="jxr_linenumber" name="L340" href="#L340">340</a> <em class="jxr_javadoccomment">/**</em>
349 <a class="jxr_linenumber" name="L341" href="#L341">341</a> <em class="jxr_javadoccomment"> * SQL-Driver name.</em>
350 <a class="jxr_linenumber" name="L342" href="#L342">342</a> <em class="jxr_javadoccomment"> *</em>
351 <a class="jxr_linenumber" name="L343" href="#L343">343</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.connection.driver_class"</em>
352 <a class="jxr_linenumber" name="L344" href="#L344">344</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
353 <a class="jxr_linenumber" name="L345" href="#L345">345</a> <em class="jxr_javadoccomment"> */</em>
354 <a class="jxr_linenumber" name="L346" href="#L346">346</a> <strong class="jxr_keyword">private</strong> String driver;
355 <a class="jxr_linenumber" name="L347" href="#L347">347</a>
356 <a class="jxr_linenumber" name="L348" href="#L348">348</a> <em class="jxr_javadoccomment">/**</em>
357 <a class="jxr_linenumber" name="L349" href="#L349">349</a> <em class="jxr_javadoccomment"> * Database URL.</em>
358 <a class="jxr_linenumber" name="L350" href="#L350">350</a> <em class="jxr_javadoccomment"> *</em>
359 <a class="jxr_linenumber" name="L351" href="#L351">351</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.connection.url"</em>
360 <a class="jxr_linenumber" name="L352" href="#L352">352</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
361 <a class="jxr_linenumber" name="L353" href="#L353">353</a> <em class="jxr_javadoccomment"> */</em>
362 <a class="jxr_linenumber" name="L354" href="#L354">354</a> <strong class="jxr_keyword">private</strong> String url;
363 <a class="jxr_linenumber" name="L355" href="#L355">355</a>
364 <a class="jxr_linenumber" name="L356" href="#L356">356</a> <em class="jxr_javadoccomment">/**</em>
365 <a class="jxr_linenumber" name="L357" href="#L357">357</a> <em class="jxr_javadoccomment"> * Database username</em>
366 <a class="jxr_linenumber" name="L358" href="#L358">358</a> <em class="jxr_javadoccomment"> *</em>
367 <a class="jxr_linenumber" name="L359" href="#L359">359</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.connection.username"</em>
368 <a class="jxr_linenumber" name="L360" href="#L360">360</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
369 <a class="jxr_linenumber" name="L361" href="#L361">361</a> <em class="jxr_javadoccomment"> */</em>
370 <a class="jxr_linenumber" name="L362" href="#L362">362</a> <strong class="jxr_keyword">private</strong> String username;
371 <a class="jxr_linenumber" name="L363" href="#L363">363</a>
372 <a class="jxr_linenumber" name="L364" href="#L364">364</a> <em class="jxr_javadoccomment">/**</em>
373 <a class="jxr_linenumber" name="L365" href="#L365">365</a> <em class="jxr_javadoccomment"> * Database password</em>
374 <a class="jxr_linenumber" name="L366" href="#L366">366</a> <em class="jxr_javadoccomment"> *</em>
375 <a class="jxr_linenumber" name="L367" href="#L367">367</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.connection.password"</em>
376 <a class="jxr_linenumber" name="L368" href="#L368">368</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
377 <a class="jxr_linenumber" name="L369" href="#L369">369</a> <em class="jxr_javadoccomment"> */</em>
378 <a class="jxr_linenumber" name="L370" href="#L370">370</a> <strong class="jxr_keyword">private</strong> String password;
379 <a class="jxr_linenumber" name="L371" href="#L371">371</a>
380 <a class="jxr_linenumber" name="L372" href="#L372">372</a>
381 <a class="jxr_linenumber" name="L373" href="#L373">373</a> <em class="jxr_javadoccomment">/** Parameters to locate configuration sources ****************************/</em>
382 <a class="jxr_linenumber" name="L374" href="#L374">374</a>
383 <a class="jxr_linenumber" name="L375" href="#L375">375</a> <em class="jxr_javadoccomment">/**</em>
384 <a class="jxr_linenumber" name="L376" href="#L376">376</a> <em class="jxr_javadoccomment"> * Path to a file or name of a ressource with hibernate properties.</em>
385 <a class="jxr_linenumber" name="L377" href="#L377">377</a> <em class="jxr_javadoccomment"> * If this parameter is specified, the plugin will try to load configuration</em>
386 <a class="jxr_linenumber" name="L378" href="#L378">378</a> <em class="jxr_javadoccomment"> * values from a file with the given path or a ressource on the classpath with</em>
387 <a class="jxr_linenumber" name="L379" href="#L379">379</a> <em class="jxr_javadoccomment"> * the given name. If both fails, the execution of the plugin will fail.</em>
388 <a class="jxr_linenumber" name="L380" href="#L380">380</a> <em class="jxr_javadoccomment"> * <p></em>
389 <a class="jxr_linenumber" name="L381" href="#L381">381</a> <em class="jxr_javadoccomment"> * If this parameter is not set the plugin will load configuration values</em>
390 <a class="jxr_linenumber" name="L382" href="#L382">382</a> <em class="jxr_javadoccomment"> * from a ressource named <code>hibernate.properties</code> on the classpath,</em>
391 <a class="jxr_linenumber" name="L383" href="#L383">383</a> <em class="jxr_javadoccomment"> * if it is present, but will not fail if there is no such ressource.</em>
392 <a class="jxr_linenumber" name="L384" href="#L384">384</a> <em class="jxr_javadoccomment"> * <p></em>
393 <a class="jxr_linenumber" name="L385" href="#L385">385</a> <em class="jxr_javadoccomment"> * During ressource-lookup, the test-classpath takes precedence.</em>
394 <a class="jxr_linenumber" name="L386" href="#L386">386</a> <em class="jxr_javadoccomment"> *</em>
395 <a class="jxr_linenumber" name="L387" href="#L387">387</a> <em class="jxr_javadoccomment"> * @parameter</em>
396 <a class="jxr_linenumber" name="L388" href="#L388">388</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
397 <a class="jxr_linenumber" name="L389" href="#L389">389</a> <em class="jxr_javadoccomment"> */</em>
398 <a class="jxr_linenumber" name="L390" href="#L390">390</a> <strong class="jxr_keyword">private</strong> String hibernateProperties;
399 <a class="jxr_linenumber" name="L391" href="#L391">391</a>
400 <a class="jxr_linenumber" name="L392" href="#L392">392</a> <em class="jxr_javadoccomment">/**</em>
401 <a class="jxr_linenumber" name="L393" href="#L393">393</a> <em class="jxr_javadoccomment"> * Path to Hibernate configuration file (.cfg.xml).</em>
402 <a class="jxr_linenumber" name="L394" href="#L394">394</a> <em class="jxr_javadoccomment"> * If this parameter is specified, the plugin will try to load configuration</em>
403 <a class="jxr_linenumber" name="L395" href="#L395">395</a> <em class="jxr_javadoccomment"> * values from a file with the given path or a ressource on the classpath with</em>
404 <a class="jxr_linenumber" name="L396" href="#L396">396</a> <em class="jxr_javadoccomment"> * the given name. If both fails, the execution of the plugin will fail.</em>
405 <a class="jxr_linenumber" name="L397" href="#L397">397</a> <em class="jxr_javadoccomment"> * <p></em>
406 <a class="jxr_linenumber" name="L398" href="#L398">398</a> <em class="jxr_javadoccomment"> * If this parameter is not set the plugin will load configuration values</em>
407 <a class="jxr_linenumber" name="L399" href="#L399">399</a> <em class="jxr_javadoccomment"> * from a ressource named <code>hibernate.cfg.xml</code> on the classpath,</em>
408 <a class="jxr_linenumber" name="L400" href="#L400">400</a> <em class="jxr_javadoccomment"> * if it is present, but will not fail if there is no such ressource.</em>
409 <a class="jxr_linenumber" name="L401" href="#L401">401</a> <em class="jxr_javadoccomment"> * <p></em>
410 <a class="jxr_linenumber" name="L402" href="#L402">402</a> <em class="jxr_javadoccomment"> * During ressource-lookup, the test-classpath takes precedence.</em>
411 <a class="jxr_linenumber" name="L403" href="#L403">403</a> <em class="jxr_javadoccomment"> * <p></em>
412 <a class="jxr_linenumber" name="L404" href="#L404">404</a> <em class="jxr_javadoccomment"> * Settings in this file will overwrite settings in the properties file.</em>
413 <a class="jxr_linenumber" name="L405" href="#L405">405</a> <em class="jxr_javadoccomment"> *</em>
414 <a class="jxr_linenumber" name="L406" href="#L406">406</a> <em class="jxr_javadoccomment"> * @parameter</em>
415 <a class="jxr_linenumber" name="L407" href="#L407">407</a> <em class="jxr_javadoccomment"> * @since 1.1.0</em>
416 <a class="jxr_linenumber" name="L408" href="#L408">408</a> <em class="jxr_javadoccomment"> */</em>
417 <a class="jxr_linenumber" name="L409" href="#L409">409</a> <strong class="jxr_keyword">private</strong> String hibernateConfig;
418 <a class="jxr_linenumber" name="L410" href="#L410">410</a>
419 <a class="jxr_linenumber" name="L411" href="#L411">411</a> <em class="jxr_javadoccomment">/**</em>
420 <a class="jxr_linenumber" name="L412" href="#L412">412</a> <em class="jxr_javadoccomment"> * Name of the persistence-unit.</em>
421 <a class="jxr_linenumber" name="L413" href="#L413">413</a> <em class="jxr_javadoccomment"> * If this parameter is specified, the plugin will try to load configuration</em>
422 <a class="jxr_linenumber" name="L414" href="#L414">414</a> <em class="jxr_javadoccomment"> * values from a persistence-unit with the specified name. If no such</em>
423 <a class="jxr_linenumber" name="L415" href="#L415">415</a> <em class="jxr_javadoccomment"> * persistence-unit can be found, the plugin will throw an exception.</em>
424 <a class="jxr_linenumber" name="L416" href="#L416">416</a> <em class="jxr_javadoccomment"> * <p></em>
425 <a class="jxr_linenumber" name="L417" href="#L417">417</a> <em class="jxr_javadoccomment"> * If this parameter is not set and there is only one persistence-unit</em>
426 <a class="jxr_linenumber" name="L418" href="#L418">418</a> <em class="jxr_javadoccomment"> * available, that unit will be used automatically. But if this parameter is</em>
427 <a class="jxr_linenumber" name="L419" href="#L419">419</a> <em class="jxr_javadoccomment"> * not set and there are multiple persistence-units available on,</em>
428 <a class="jxr_linenumber" name="L420" href="#L420">420</a> <em class="jxr_javadoccomment"> * the class-path, the execution of the plugin will fail.</em>
429 <a class="jxr_linenumber" name="L421" href="#L421">421</a> <em class="jxr_javadoccomment"> * <p></em>
430 <a class="jxr_linenumber" name="L422" href="#L422">422</a> <em class="jxr_javadoccomment"> * Settings in this file will overwrite settings in the properties or the</em>
431 <a class="jxr_linenumber" name="L423" href="#L423">423</a> <em class="jxr_javadoccomment"> * configuration file.</em>
432 <a class="jxr_linenumber" name="L424" href="#L424">424</a> <em class="jxr_javadoccomment"> *</em>
433 <a class="jxr_linenumber" name="L425" href="#L425">425</a> <em class="jxr_javadoccomment"> * @parameter</em>
434 <a class="jxr_linenumber" name="L426" href="#L426">426</a> <em class="jxr_javadoccomment"> * @since 1.1.0</em>
435 <a class="jxr_linenumber" name="L427" href="#L427">427</a> <em class="jxr_javadoccomment"> */</em>
436 <a class="jxr_linenumber" name="L428" href="#L428">428</a> <strong class="jxr_keyword">private</strong> String persistenceUnit;
437 <a class="jxr_linenumber" name="L429" href="#L429">429</a>
438 <a class="jxr_linenumber" name="L430" href="#L430">430</a> <em class="jxr_javadoccomment">/**</em>
439 <a class="jxr_linenumber" name="L431" href="#L431">431</a> <em class="jxr_javadoccomment"> * List of Hibernate-Mapping-Files (XML).</em>
440 <a class="jxr_linenumber" name="L432" href="#L432">432</a> <em class="jxr_javadoccomment"> * Multiple files can be separated with white-spaces and/or commas.</em>
441 <a class="jxr_linenumber" name="L433" href="#L433">433</a> <em class="jxr_javadoccomment"> *</em>
442 <a class="jxr_linenumber" name="L434" href="#L434">434</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.mapping"</em>
443 <a class="jxr_linenumber" name="L435" href="#L435">435</a> <em class="jxr_javadoccomment"> * @since 1.0.2</em>
444 <a class="jxr_linenumber" name="L436" href="#L436">436</a> <em class="jxr_javadoccomment"> */</em>
445 <a class="jxr_linenumber" name="L437" href="#L437">437</a> <strong class="jxr_keyword">private</strong> String mappings;
446 <a class="jxr_linenumber" name="L438" href="#L438">438</a>
447 <a class="jxr_linenumber" name="L439" href="#L439">439</a>
448 <a class="jxr_linenumber" name="L440" href="#L440">440</a>
449 <a class="jxr_linenumber" name="L441" href="#L441">441</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> execute(String filename)
450 <a class="jxr_linenumber" name="L442" href="#L442">442</a> <strong class="jxr_keyword">throws</strong>
451 <a class="jxr_linenumber" name="L443" href="#L443">443</a> MojoFailureException,
452 <a class="jxr_linenumber" name="L444" href="#L444">444</a> MojoExecutionException
453 <a class="jxr_linenumber" name="L445" href="#L445">445</a> {
454 <a class="jxr_linenumber" name="L446" href="#L446">446</a> <strong class="jxr_keyword">if</strong> (skip)
455 <a class="jxr_linenumber" name="L447" href="#L447">447</a> {
456 <a class="jxr_linenumber" name="L448" href="#L448">448</a> getLog().info(<span class="jxr_string">"Execution of hibernate-maven-plugin was skipped!"</span>);
457 <a class="jxr_linenumber" name="L449" href="#L449">449</a> project.getProperties().setProperty(SKIPPED, <span class="jxr_string">"true"</span>);
458 <a class="jxr_linenumber" name="L450" href="#L450">450</a> <strong class="jxr_keyword">return</strong>;
459 <a class="jxr_linenumber" name="L451" href="#L451">451</a> }
460 <a class="jxr_linenumber" name="L452" href="#L452">452</a>
461 <a class="jxr_linenumber" name="L453" href="#L453">453</a> <a href="../../../../de/juplo/plugins/hibernate/ModificationTracker.html">ModificationTracker</a> tracker;
462 <a class="jxr_linenumber" name="L454" href="#L454">454</a> <strong class="jxr_keyword">try</strong>
463 <a class="jxr_linenumber" name="L455" href="#L455">455</a> {
464 <a class="jxr_linenumber" name="L456" href="#L456">456</a> tracker = <strong class="jxr_keyword">new</strong> <a href="../../../../de/juplo/plugins/hibernate/ModificationTracker.html">ModificationTracker</a>(buildDirectory, filename, getLog());
465 <a class="jxr_linenumber" name="L457" href="#L457">457</a> }
466 <a class="jxr_linenumber" name="L458" href="#L458">458</a> <strong class="jxr_keyword">catch</strong> (NoSuchAlgorithmException e)
467 <a class="jxr_linenumber" name="L459" href="#L459">459</a> {
468 <a class="jxr_linenumber" name="L460" href="#L460">460</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"Digest-Algorithm MD5 is missing!"</span>, e);
469 <a class="jxr_linenumber" name="L461" href="#L461">461</a> }
470 <a class="jxr_linenumber" name="L462" href="#L462">462</a>
471 <a class="jxr_linenumber" name="L463" href="#L463">463</a> <strong class="jxr_keyword">final</strong> <a href="../../../../de/juplo/plugins/hibernate/SimpleConnectionProvider.html">SimpleConnectionProvider</a> connectionProvider =
472 <a class="jxr_linenumber" name="L464" href="#L464">464</a> <strong class="jxr_keyword">new</strong> <a href="../../../../de/juplo/plugins/hibernate/SimpleConnectionProvider.html">SimpleConnectionProvider</a>(getLog());
473 <a class="jxr_linenumber" name="L465" href="#L465">465</a>
474 <a class="jxr_linenumber" name="L466" href="#L466">466</a> <strong class="jxr_keyword">try</strong>
475 <a class="jxr_linenumber" name="L467" href="#L467">467</a> {
476 <a class="jxr_linenumber" name="L468" href="#L468">468</a> <em class="jxr_javadoccomment">/** Start extended logging */</em>
477 <a class="jxr_linenumber" name="L469" href="#L469">469</a> MavenLogAppender.startPluginLog(<strong class="jxr_keyword">this</strong>);
478 <a class="jxr_linenumber" name="L470" href="#L470">470</a>
479 <a class="jxr_linenumber" name="L471" href="#L471">471</a> <em class="jxr_javadoccomment">/** Load checksums for old mapping and configuration */</em>
480 <a class="jxr_linenumber" name="L472" href="#L472">472</a> tracker.load();
481 <a class="jxr_linenumber" name="L473" href="#L473">473</a>
482 <a class="jxr_linenumber" name="L474" href="#L474">474</a> <em class="jxr_javadoccomment">/** Create the ClassLoader */</em>
483 <a class="jxr_linenumber" name="L475" href="#L475">475</a> <a href="../../../../de/juplo/plugins/hibernate/MutableClassLoader.html">MutableClassLoader</a> classLoader = createClassLoader();
484 <a class="jxr_linenumber" name="L476" href="#L476">476</a>
485 <a class="jxr_linenumber" name="L477" href="#L477">477</a> <em class="jxr_javadoccomment">/** Create a BootstrapServiceRegistry with the created ClassLoader */</em>
486 <a class="jxr_linenumber" name="L478" href="#L478">478</a> BootstrapServiceRegistry bootstrapServiceRegitry =
487 <a class="jxr_linenumber" name="L479" href="#L479">479</a> <strong class="jxr_keyword">new</strong> BootstrapServiceRegistryBuilder()
488 <a class="jxr_linenumber" name="L480" href="#L480">480</a> .applyClassLoader(classLoader)
489 <a class="jxr_linenumber" name="L481" href="#L481">481</a> .build();
490 <a class="jxr_linenumber" name="L482" href="#L482">482</a> ClassLoaderService classLoaderService =
491 <a class="jxr_linenumber" name="L483" href="#L483">483</a> bootstrapServiceRegitry.getService(ClassLoaderService.<strong class="jxr_keyword">class</strong>);
492 <a class="jxr_linenumber" name="L484" href="#L484">484</a>
493 <a class="jxr_linenumber" name="L485" href="#L485">485</a> Properties properties = <strong class="jxr_keyword">new</strong> Properties();
494 <a class="jxr_linenumber" name="L486" href="#L486">486</a> ConfigLoader configLoader = <strong class="jxr_keyword">new</strong> ConfigLoader(bootstrapServiceRegitry);
495 <a class="jxr_linenumber" name="L487" href="#L487">487</a>
496 <a class="jxr_linenumber" name="L488" href="#L488">488</a> <em class="jxr_javadoccomment">/** Loading and merging configuration */</em>
497 <a class="jxr_linenumber" name="L489" href="#L489">489</a> properties.putAll(loadProperties(configLoader));
498 <a class="jxr_linenumber" name="L490" href="#L490">490</a> LoadedConfig config = loadConfig(configLoader);
499 <a class="jxr_linenumber" name="L491" href="#L491">491</a> <strong class="jxr_keyword">if</strong> (config != <strong class="jxr_keyword">null</strong>)
500 <a class="jxr_linenumber" name="L492" href="#L492">492</a> properties.putAll(config.getConfigurationValues());
501 <a class="jxr_linenumber" name="L493" href="#L493">493</a> ParsedPersistenceXmlDescriptor unit =
502 <a class="jxr_linenumber" name="L494" href="#L494">494</a> loadPersistenceUnit(classLoaderService, properties);
503 <a class="jxr_linenumber" name="L495" href="#L495">495</a> <strong class="jxr_keyword">if</strong> (unit != <strong class="jxr_keyword">null</strong>)
504 <a class="jxr_linenumber" name="L496" href="#L496">496</a> properties.putAll(unit.getProperties());
505 <a class="jxr_linenumber" name="L497" href="#L497">497</a>
506 <a class="jxr_linenumber" name="L498" href="#L498">498</a> <em class="jxr_javadoccomment">/** Overwriting/Completing configuration */</em>
507 <a class="jxr_linenumber" name="L499" href="#L499">499</a> configure(properties, tracker);
508 <a class="jxr_linenumber" name="L500" href="#L500">500</a>
509 <a class="jxr_linenumber" name="L501" href="#L501">501</a> <em class="jxr_javadoccomment">/** Check configuration for modifications */</em>
510 <a class="jxr_linenumber" name="L502" href="#L502">502</a> <strong class="jxr_keyword">if</strong>(tracker.track(properties))
511 <a class="jxr_linenumber" name="L503" href="#L503">503</a> getLog().debug(<span class="jxr_string">"Configuration has changed."</span>);
512 <a class="jxr_linenumber" name="L504" href="#L504">504</a> <strong class="jxr_keyword">else</strong>
513 <a class="jxr_linenumber" name="L505" href="#L505">505</a> getLog().debug(<span class="jxr_string">"Configuration unchanged."</span>);
514 <a class="jxr_linenumber" name="L506" href="#L506">506</a>
515 <a class="jxr_linenumber" name="L507" href="#L507">507</a> <em class="jxr_javadoccomment">/** Check, that the outputfile is writable */</em>
516 <a class="jxr_linenumber" name="L508" href="#L508">508</a> <strong class="jxr_keyword">final</strong> File output = getOutputFile(filename);
517 <a class="jxr_linenumber" name="L509" href="#L509">509</a> <em class="jxr_javadoccomment">/** Check, if the outputfile is missing or was changed */</em>
518 <a class="jxr_linenumber" name="L510" href="#L510">510</a> checkOutputFile(output, tracker);
519 <a class="jxr_linenumber" name="L511" href="#L511">511</a>
520 <a class="jxr_linenumber" name="L512" href="#L512">512</a> <em class="jxr_javadoccomment">/** Configure Hibernate */</em>
521 <a class="jxr_linenumber" name="L513" href="#L513">513</a> <strong class="jxr_keyword">final</strong> StandardServiceRegistry serviceRegistry =
522 <a class="jxr_linenumber" name="L514" href="#L514">514</a> <strong class="jxr_keyword">new</strong> StandardServiceRegistryBuilder(bootstrapServiceRegitry)
523 <a class="jxr_linenumber" name="L515" href="#L515">515</a> .applySettings(properties)
524 <a class="jxr_linenumber" name="L516" href="#L516">516</a> .addService(ConnectionProvider.<strong class="jxr_keyword">class</strong>, connectionProvider)
525 <a class="jxr_linenumber" name="L517" href="#L517">517</a> .build();
526 <a class="jxr_linenumber" name="L518" href="#L518">518</a> <strong class="jxr_keyword">final</strong> MetadataSources sources = <strong class="jxr_keyword">new</strong> MetadataSources(serviceRegistry);
527 <a class="jxr_linenumber" name="L519" href="#L519">519</a>
528 <a class="jxr_linenumber" name="L520" href="#L520">520</a> <em class="jxr_javadoccomment">/** Add the remaining class-path-elements */</em>
529 <a class="jxr_linenumber" name="L521" href="#L521">521</a> completeClassPath(classLoader);
530 <a class="jxr_linenumber" name="L522" href="#L522">522</a>
531 <a class="jxr_linenumber" name="L523" href="#L523">523</a> <em class="jxr_javadoccomment">/** Apply mappings from hibernate-configuration, if present */</em>
532 <a class="jxr_linenumber" name="L524" href="#L524">524</a> <strong class="jxr_keyword">if</strong> (config != <strong class="jxr_keyword">null</strong>)
533 <a class="jxr_linenumber" name="L525" href="#L525">525</a> {
534 <a class="jxr_linenumber" name="L526" href="#L526">526</a> <strong class="jxr_keyword">for</strong> (MappingReference mapping : config.getMappingReferences())
535 <a class="jxr_linenumber" name="L527" href="#L527">527</a> mapping.apply(sources);
536 <a class="jxr_linenumber" name="L528" href="#L528">528</a> }
537 <a class="jxr_linenumber" name="L529" href="#L529">529</a>
538 <a class="jxr_linenumber" name="L530" href="#L530">530</a> Set<String> classes;
539 <a class="jxr_linenumber" name="L531" href="#L531">531</a> <strong class="jxr_keyword">if</strong> (unit == <strong class="jxr_keyword">null</strong>)
540 <a class="jxr_linenumber" name="L532" href="#L532">532</a> {
541 <a class="jxr_linenumber" name="L533" href="#L533">533</a> <em class="jxr_javadoccomment">/** No persistent unit: default behaviour */</em>
542 <a class="jxr_linenumber" name="L534" href="#L534">534</a> <strong class="jxr_keyword">if</strong> (scanClasses == <strong class="jxr_keyword">null</strong>)
543 <a class="jxr_linenumber" name="L535" href="#L535">535</a> scanClasses = <strong class="jxr_keyword">true</strong>;
544 <a class="jxr_linenumber" name="L536" href="#L536">536</a> Set<URL> urls = <strong class="jxr_keyword">new</strong> HashSet<URL>();
545 <a class="jxr_linenumber" name="L537" href="#L537">537</a> <strong class="jxr_keyword">if</strong> (scanClasses)
546 <a class="jxr_linenumber" name="L538" href="#L538">538</a> addRoot(urls, outputDirectory);
547 <a class="jxr_linenumber" name="L539" href="#L539">539</a> <strong class="jxr_keyword">if</strong> (scanTestClasses)
548 <a class="jxr_linenumber" name="L540" href="#L540">540</a> addRoot(urls, testOutputDirectory);
549 <a class="jxr_linenumber" name="L541" href="#L541">541</a> addDependencies(urls);
550 <a class="jxr_linenumber" name="L542" href="#L542">542</a> classes = scanUrls(urls);
551 <a class="jxr_linenumber" name="L543" href="#L543">543</a> }
552 <a class="jxr_linenumber" name="L544" href="#L544">544</a> <strong class="jxr_keyword">else</strong>
553 <a class="jxr_linenumber" name="L545" href="#L545">545</a> {
554 <a class="jxr_linenumber" name="L546" href="#L546">546</a> <em class="jxr_javadoccomment">/** Follow configuration in persisten unit */</em>
555 <a class="jxr_linenumber" name="L547" href="#L547">547</a> <strong class="jxr_keyword">if</strong> (scanClasses == <strong class="jxr_keyword">null</strong>)
556 <a class="jxr_linenumber" name="L548" href="#L548">548</a> scanClasses = !unit.isExcludeUnlistedClasses();
557 <a class="jxr_linenumber" name="L549" href="#L549">549</a> Set<URL> urls = <strong class="jxr_keyword">new</strong> HashSet<URL>();
558 <a class="jxr_linenumber" name="L550" href="#L550">550</a> <strong class="jxr_keyword">if</strong> (scanClasses)
559 <a class="jxr_linenumber" name="L551" href="#L551">551</a> {
560 <a class="jxr_linenumber" name="L552" href="#L552">552</a> <em class="jxr_javadoccomment">/**</em>
561 <a class="jxr_linenumber" name="L553" href="#L553">553</a> <em class="jxr_javadoccomment"> * Scan the root of the persiten unit and configured jars for</em>
562 <a class="jxr_linenumber" name="L554" href="#L554">554</a> <em class="jxr_javadoccomment"> * annotated classes</em>
563 <a class="jxr_linenumber" name="L555" href="#L555">555</a> <em class="jxr_javadoccomment"> */</em>
564 <a class="jxr_linenumber" name="L556" href="#L556">556</a> urls.add(unit.getPersistenceUnitRootUrl());
565 <a class="jxr_linenumber" name="L557" href="#L557">557</a> <strong class="jxr_keyword">for</strong> (URL url : unit.getJarFileUrls())
566 <a class="jxr_linenumber" name="L558" href="#L558">558</a> urls.add(url);
567 <a class="jxr_linenumber" name="L559" href="#L559">559</a> }
568 <a class="jxr_linenumber" name="L560" href="#L560">560</a> <strong class="jxr_keyword">if</strong> (scanTestClasses)
569 <a class="jxr_linenumber" name="L561" href="#L561">561</a> addRoot(urls, testOutputDirectory);
570 <a class="jxr_linenumber" name="L562" href="#L562">562</a> classes = scanUrls(urls);
571 <a class="jxr_linenumber" name="L563" href="#L563">563</a> <strong class="jxr_keyword">for</strong> (String className : unit.getManagedClassNames())
572 <a class="jxr_linenumber" name="L564" href="#L564">564</a> classes.add(className);
573 <a class="jxr_linenumber" name="L565" href="#L565">565</a> <em class="jxr_javadoccomment">/**</em>
574 <a class="jxr_linenumber" name="L566" href="#L566">566</a> <em class="jxr_javadoccomment"> * Add mappings from the default mapping-file</em>
575 <a class="jxr_linenumber" name="L567" href="#L567">567</a> <em class="jxr_javadoccomment"> * <code>META-INF/orm.xml</code>, if present</em>
576 <a class="jxr_linenumber" name="L568" href="#L568">568</a> <em class="jxr_javadoccomment"> */</em>
577 <a class="jxr_linenumber" name="L569" href="#L569">569</a> <strong class="jxr_keyword">boolean</strong> error = false;
578 <a class="jxr_linenumber" name="L570" href="#L570">570</a> InputStream is;
579 <a class="jxr_linenumber" name="L571" href="#L571">571</a> is = classLoader.getResourceAsStream(<span class="jxr_string">"META-INF/orm.xml"</span>);
580 <a class="jxr_linenumber" name="L572" href="#L572">572</a> <strong class="jxr_keyword">if</strong> (is != <strong class="jxr_keyword">null</strong>)
581 <a class="jxr_linenumber" name="L573" href="#L573">573</a> {
582 <a class="jxr_linenumber" name="L574" href="#L574">574</a> getLog().info(<span class="jxr_string">"Adding default JPA-XML-mapping from META-INF/orm.xml"</span>);
583 <a class="jxr_linenumber" name="L575" href="#L575">575</a> <strong class="jxr_keyword">try</strong>
584 <a class="jxr_linenumber" name="L576" href="#L576">576</a> {
585 <a class="jxr_linenumber" name="L577" href="#L577">577</a> tracker.track(<span class="jxr_string">"META-INF/orm.xml"</span>, is);
586 <a class="jxr_linenumber" name="L578" href="#L578">578</a> sources.addResource(<span class="jxr_string">"META-INF/orm.xml"</span>);
587 <a class="jxr_linenumber" name="L579" href="#L579">579</a> }
588 <a class="jxr_linenumber" name="L580" href="#L580">580</a> <strong class="jxr_keyword">catch</strong> (IOException e)
589 <a class="jxr_linenumber" name="L581" href="#L581">581</a> {
590 <a class="jxr_linenumber" name="L582" href="#L582">582</a> getLog().error(<span class="jxr_string">"cannot read META-INF/orm.xml: "</span> + e);
591 <a class="jxr_linenumber" name="L583" href="#L583">583</a> error = <strong class="jxr_keyword">true</strong>;
592 <a class="jxr_linenumber" name="L584" href="#L584">584</a> }
593 <a class="jxr_linenumber" name="L585" href="#L585">585</a> }
594 <a class="jxr_linenumber" name="L586" href="#L586">586</a> <strong class="jxr_keyword">else</strong>
595 <a class="jxr_linenumber" name="L587" href="#L587">587</a> {
596 <a class="jxr_linenumber" name="L588" href="#L588">588</a> getLog().debug(<span class="jxr_string">"no META-INF/orm.xml found"</span>);
597 <a class="jxr_linenumber" name="L589" href="#L589">589</a> }
598 <a class="jxr_linenumber" name="L590" href="#L590">590</a> <em class="jxr_javadoccomment">/**</em>
599 <a class="jxr_linenumber" name="L591" href="#L591">591</a> <em class="jxr_javadoccomment"> * Add mappings from files, that are explicitly configured in the</em>
600 <a class="jxr_linenumber" name="L592" href="#L592">592</a> <em class="jxr_javadoccomment"> * persistence unit</em>
601 <a class="jxr_linenumber" name="L593" href="#L593">593</a> <em class="jxr_javadoccomment"> */</em>
602 <a class="jxr_linenumber" name="L594" href="#L594">594</a> <strong class="jxr_keyword">for</strong> (String mapping : unit.getMappingFileNames())
603 <a class="jxr_linenumber" name="L595" href="#L595">595</a> {
604 <a class="jxr_linenumber" name="L596" href="#L596">596</a> getLog().info(<span class="jxr_string">"Adding explicitly configured mapping from "</span> + mapping);
605 <a class="jxr_linenumber" name="L597" href="#L597">597</a> is = classLoader.getResourceAsStream(mapping);
606 <a class="jxr_linenumber" name="L598" href="#L598">598</a> <strong class="jxr_keyword">if</strong> (is != <strong class="jxr_keyword">null</strong>)
607 <a class="jxr_linenumber" name="L599" href="#L599">599</a> {
608 <a class="jxr_linenumber" name="L600" href="#L600">600</a> <strong class="jxr_keyword">try</strong>
609 <a class="jxr_linenumber" name="L601" href="#L601">601</a> {
610 <a class="jxr_linenumber" name="L602" href="#L602">602</a> tracker.track(mapping, is);
611 <a class="jxr_linenumber" name="L603" href="#L603">603</a> sources.addResource(mapping);
612 <a class="jxr_linenumber" name="L604" href="#L604">604</a> }
613 <a class="jxr_linenumber" name="L605" href="#L605">605</a> <strong class="jxr_keyword">catch</strong> (IOException e)
614 <a class="jxr_linenumber" name="L606" href="#L606">606</a> {
615 <a class="jxr_linenumber" name="L607" href="#L607">607</a> getLog().info(<span class="jxr_string">"cannot read mapping-file "</span> + mapping + <span class="jxr_string">": "</span> + e);
616 <a class="jxr_linenumber" name="L608" href="#L608">608</a> error = <strong class="jxr_keyword">true</strong>;
617 <a class="jxr_linenumber" name="L609" href="#L609">609</a> }
618 <a class="jxr_linenumber" name="L610" href="#L610">610</a> }
619 <a class="jxr_linenumber" name="L611" href="#L611">611</a> <strong class="jxr_keyword">else</strong>
620 <a class="jxr_linenumber" name="L612" href="#L612">612</a> {
621 <a class="jxr_linenumber" name="L613" href="#L613">613</a> getLog().error(<span class="jxr_string">"cannot find mapping-file "</span> + mapping);
622 <a class="jxr_linenumber" name="L614" href="#L614">614</a> error = <strong class="jxr_keyword">true</strong>;
623 <a class="jxr_linenumber" name="L615" href="#L615">615</a> }
624 <a class="jxr_linenumber" name="L616" href="#L616">616</a> }
625 <a class="jxr_linenumber" name="L617" href="#L617">617</a> <strong class="jxr_keyword">if</strong> (error)
626 <a class="jxr_linenumber" name="L618" href="#L618">618</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(
627 <a class="jxr_linenumber" name="L619" href="#L619">619</a> <span class="jxr_string">"error, while reading mappings configured in persistence-unit \""</span> +
628 <a class="jxr_linenumber" name="L620" href="#L620">620</a> unit.getName() +
629 <a class="jxr_linenumber" name="L621" href="#L621">621</a> <span class="jxr_string">"\""</span>
630 <a class="jxr_linenumber" name="L622" href="#L622">622</a> );
631 <a class="jxr_linenumber" name="L623" href="#L623">623</a> }
632 <a class="jxr_linenumber" name="L624" href="#L624">624</a>
633 <a class="jxr_linenumber" name="L625" href="#L625">625</a> <em class="jxr_javadoccomment">/** Add the configured/collected annotated classes */</em>
634 <a class="jxr_linenumber" name="L626" href="#L626">626</a> <strong class="jxr_keyword">for</strong> (String className : classes)
635 <a class="jxr_linenumber" name="L627" href="#L627">627</a> addAnnotated(className, sources, classLoaderService, tracker);
636 <a class="jxr_linenumber" name="L628" href="#L628">628</a>
637 <a class="jxr_linenumber" name="L629" href="#L629">629</a> <em class="jxr_javadoccomment">/** Add explicitly configured classes */</em>
638 <a class="jxr_linenumber" name="L630" href="#L630">630</a> addMappings(sources, tracker);
639 <a class="jxr_linenumber" name="L631" href="#L631">631</a>
640 <a class="jxr_linenumber" name="L632" href="#L632">632</a> <em class="jxr_javadoccomment">/** Skip execution, if mapping and configuration is unchanged */</em>
641 <a class="jxr_linenumber" name="L633" href="#L633">633</a> <strong class="jxr_keyword">if</strong> (!tracker.modified())
642 <a class="jxr_linenumber" name="L634" href="#L634">634</a> {
643 <a class="jxr_linenumber" name="L635" href="#L635">635</a> getLog().info(<span class="jxr_string">"Mapping and configuration unchanged."</span>);
644 <a class="jxr_linenumber" name="L636" href="#L636">636</a> <strong class="jxr_keyword">if</strong> (force)
645 <a class="jxr_linenumber" name="L637" href="#L637">637</a> getLog().info(<span class="jxr_string">"Generation/execution is forced!"</span>);
646 <a class="jxr_linenumber" name="L638" href="#L638">638</a> <strong class="jxr_keyword">else</strong>
647 <a class="jxr_linenumber" name="L639" href="#L639">639</a> {
648 <a class="jxr_linenumber" name="L640" href="#L640">640</a> getLog().info(<span class="jxr_string">"Skipping schema generation!"</span>);
649 <a class="jxr_linenumber" name="L641" href="#L641">641</a> project.getProperties().setProperty(SKIPPED, <span class="jxr_string">"true"</span>);
650 <a class="jxr_linenumber" name="L642" href="#L642">642</a> <strong class="jxr_keyword">return</strong>;
651 <a class="jxr_linenumber" name="L643" href="#L643">643</a> }
652 <a class="jxr_linenumber" name="L644" href="#L644">644</a> }
653 <a class="jxr_linenumber" name="L645" href="#L645">645</a>
654 <a class="jxr_linenumber" name="L646" href="#L646">646</a>
655 <a class="jxr_linenumber" name="L647" href="#L647">647</a> <em class="jxr_javadoccomment">/** Truncate output file */</em>
656 <a class="jxr_linenumber" name="L648" href="#L648">648</a> <strong class="jxr_keyword">try</strong>
657 <a class="jxr_linenumber" name="L649" href="#L649">649</a> {
658 <a class="jxr_linenumber" name="L650" href="#L650">650</a> <strong class="jxr_keyword">new</strong> FileOutputStream(output).getChannel().truncate(0).close();
659 <a class="jxr_linenumber" name="L651" href="#L651">651</a> }
660 <a class="jxr_linenumber" name="L652" href="#L652">652</a> <strong class="jxr_keyword">catch</strong> (IOException e)
661 <a class="jxr_linenumber" name="L653" href="#L653">653</a> {
662 <a class="jxr_linenumber" name="L654" href="#L654">654</a> String error =
663 <a class="jxr_linenumber" name="L655" href="#L655">655</a> <span class="jxr_string">"Error while truncating "</span> + output.getAbsolutePath() + <span class="jxr_string">": "</span>
664 <a class="jxr_linenumber" name="L656" href="#L656">656</a> + e.getMessage();
665 <a class="jxr_linenumber" name="L657" href="#L657">657</a> getLog().warn(error);
666 <a class="jxr_linenumber" name="L658" href="#L658">658</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(error);
667 <a class="jxr_linenumber" name="L659" href="#L659">659</a> }
668 <a class="jxr_linenumber" name="L660" href="#L660">660</a>
669 <a class="jxr_linenumber" name="L661" href="#L661">661</a> <em class="jxr_javadoccomment">/** Create a connection, if sufficient configuration infromation is available */</em>
670 <a class="jxr_linenumber" name="L662" href="#L662">662</a> connectionProvider.open(classLoaderService, properties);
671 <a class="jxr_linenumber" name="L663" href="#L663">663</a>
672 <a class="jxr_linenumber" name="L664" href="#L664">664</a> MetadataBuilder metadataBuilder = sources.getMetadataBuilder();
673 <a class="jxr_linenumber" name="L665" href="#L665">665</a>
674 <a class="jxr_linenumber" name="L666" href="#L666">666</a> StrategySelector strategySelector =
675 <a class="jxr_linenumber" name="L667" href="#L667">667</a> serviceRegistry.getService(StrategySelector.<strong class="jxr_keyword">class</strong>);
676 <a class="jxr_linenumber" name="L668" href="#L668">668</a>
677 <a class="jxr_linenumber" name="L669" href="#L669">669</a> <strong class="jxr_keyword">if</strong> (properties.containsKey(IMPLICIT_NAMING_STRATEGY))
678 <a class="jxr_linenumber" name="L670" href="#L670">670</a> {
679 <a class="jxr_linenumber" name="L671" href="#L671">671</a> metadataBuilder.applyImplicitNamingStrategy(
680 <a class="jxr_linenumber" name="L672" href="#L672">672</a> strategySelector.resolveStrategy(
681 <a class="jxr_linenumber" name="L673" href="#L673">673</a> ImplicitNamingStrategy.<strong class="jxr_keyword">class</strong>,
682 <a class="jxr_linenumber" name="L674" href="#L674">674</a> properties.getProperty(IMPLICIT_NAMING_STRATEGY)
683 <a class="jxr_linenumber" name="L675" href="#L675">675</a> )
684 <a class="jxr_linenumber" name="L676" href="#L676">676</a> );
685 <a class="jxr_linenumber" name="L677" href="#L677">677</a> }
686 <a class="jxr_linenumber" name="L678" href="#L678">678</a>
687 <a class="jxr_linenumber" name="L679" href="#L679">679</a> <strong class="jxr_keyword">if</strong> (properties.containsKey(PHYSICAL_NAMING_STRATEGY))
688 <a class="jxr_linenumber" name="L680" href="#L680">680</a> {
689 <a class="jxr_linenumber" name="L681" href="#L681">681</a> metadataBuilder.applyPhysicalNamingStrategy(
690 <a class="jxr_linenumber" name="L682" href="#L682">682</a> strategySelector.resolveStrategy(
691 <a class="jxr_linenumber" name="L683" href="#L683">683</a> PhysicalNamingStrategy.<strong class="jxr_keyword">class</strong>,
692 <a class="jxr_linenumber" name="L684" href="#L684">684</a> properties.getProperty(PHYSICAL_NAMING_STRATEGY)
693 <a class="jxr_linenumber" name="L685" href="#L685">685</a> )
694 <a class="jxr_linenumber" name="L686" href="#L686">686</a> );
695 <a class="jxr_linenumber" name="L687" href="#L687">687</a> }
696 <a class="jxr_linenumber" name="L688" href="#L688">688</a>
697 <a class="jxr_linenumber" name="L689" href="#L689">689</a> <em class="jxr_javadoccomment">/** Prepare the generation of the SQL */</em>
698 <a class="jxr_linenumber" name="L690" href="#L690">690</a> Map settings = <strong class="jxr_keyword">new</strong> HashMap();
699 <a class="jxr_linenumber" name="L691" href="#L691">691</a> settings.putAll(
700 <a class="jxr_linenumber" name="L692" href="#L692">692</a> serviceRegistry
701 <a class="jxr_linenumber" name="L693" href="#L693">693</a> .getService(ConfigurationService.<strong class="jxr_keyword">class</strong>)
702 <a class="jxr_linenumber" name="L694" href="#L694">694</a> .getSettings()
703 <a class="jxr_linenumber" name="L695" href="#L695">695</a> );
704 <a class="jxr_linenumber" name="L696" href="#L696">696</a> ExceptionHandlerCollectingImpl handler =
705 <a class="jxr_linenumber" name="L697" href="#L697">697</a> <strong class="jxr_keyword">new</strong> ExceptionHandlerCollectingImpl();
706 <a class="jxr_linenumber" name="L698" href="#L698">698</a> ExecutionOptions options =
707 <a class="jxr_linenumber" name="L699" href="#L699">699</a> SchemaManagementToolCoordinator
708 <a class="jxr_linenumber" name="L700" href="#L700">700</a> .buildExecutionOptions(settings, handler);
709 <a class="jxr_linenumber" name="L701" href="#L701">701</a> <strong class="jxr_keyword">final</strong> EnumSet<TargetType> targetTypes = EnumSet.of(TargetType.SCRIPT);
710 <a class="jxr_linenumber" name="L702" href="#L702">702</a> <strong class="jxr_keyword">if</strong> (execute)
711 <a class="jxr_linenumber" name="L703" href="#L703">703</a> targetTypes.add(TargetType.DATABASE);
712 <a class="jxr_linenumber" name="L704" href="#L704">704</a> TargetDescriptor target = <strong class="jxr_keyword">new</strong> TargetDescriptor()
713 <a class="jxr_linenumber" name="L705" href="#L705">705</a> {
714 <a class="jxr_linenumber" name="L706" href="#L706">706</a> @Override
715 <a class="jxr_linenumber" name="L707" href="#L707">707</a> <strong class="jxr_keyword">public</strong> EnumSet<TargetType> getTargetTypes()
716 <a class="jxr_linenumber" name="L708" href="#L708">708</a> {
717 <a class="jxr_linenumber" name="L709" href="#L709">709</a> <strong class="jxr_keyword">return</strong> targetTypes;
718 <a class="jxr_linenumber" name="L710" href="#L710">710</a> }
719 <a class="jxr_linenumber" name="L711" href="#L711">711</a>
720 <a class="jxr_linenumber" name="L712" href="#L712">712</a> @Override
721 <a class="jxr_linenumber" name="L713" href="#L713">713</a> <strong class="jxr_keyword">public</strong> ScriptTargetOutput getScriptTargetOutput()
722 <a class="jxr_linenumber" name="L714" href="#L714">714</a> {
723 <a class="jxr_linenumber" name="L715" href="#L715">715</a> String charset =
724 <a class="jxr_linenumber" name="L716" href="#L716">716</a> (String)
725 <a class="jxr_linenumber" name="L717" href="#L717">717</a> serviceRegistry
726 <a class="jxr_linenumber" name="L718" href="#L718">718</a> .getService(ConfigurationService.<strong class="jxr_keyword">class</strong>)
727 <a class="jxr_linenumber" name="L719" href="#L719">719</a> .getSettings()
728 <a class="jxr_linenumber" name="L720" href="#L720">720</a> .get(AvailableSettings.HBM2DDL_CHARSET_NAME);
729 <a class="jxr_linenumber" name="L721" href="#L721">721</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> ScriptTargetOutputToFile(output, charset);
730 <a class="jxr_linenumber" name="L722" href="#L722">722</a> }
731 <a class="jxr_linenumber" name="L723" href="#L723">723</a> };
732 <a class="jxr_linenumber" name="L724" href="#L724">724</a>
733 <a class="jxr_linenumber" name="L725" href="#L725">725</a> <em class="jxr_javadoccomment">/**</em>
734 <a class="jxr_linenumber" name="L726" href="#L726">726</a> <em class="jxr_javadoccomment"> * Change class-loader of current thread.</em>
735 <a class="jxr_linenumber" name="L727" href="#L727">727</a> <em class="jxr_javadoccomment"> * This is necessary, because still not all parts of Hibernate 5 use</em>
736 <a class="jxr_linenumber" name="L728" href="#L728">728</a> <em class="jxr_javadoccomment"> * the newly introduced ClassLoaderService and will fail otherwise!</em>
737 <a class="jxr_linenumber" name="L729" href="#L729">729</a> <em class="jxr_javadoccomment"> */</em>
738 <a class="jxr_linenumber" name="L730" href="#L730">730</a> Thread thread = Thread.currentThread();
739 <a class="jxr_linenumber" name="L731" href="#L731">731</a> ClassLoader contextClassLoader = thread.getContextClassLoader();
740 <a class="jxr_linenumber" name="L732" href="#L732">732</a> <strong class="jxr_keyword">try</strong>
741 <a class="jxr_linenumber" name="L733" href="#L733">733</a> {
742 <a class="jxr_linenumber" name="L734" href="#L734">734</a> thread.setContextClassLoader(classLoader);
743 <a class="jxr_linenumber" name="L735" href="#L735">735</a> build((MetadataImplementor)metadataBuilder.build(), options, target);
744 <a class="jxr_linenumber" name="L736" href="#L736">736</a> <strong class="jxr_keyword">if</strong> (handler.getExceptions().size() > 0)
745 <a class="jxr_linenumber" name="L737" href="#L737">737</a> {
746 <a class="jxr_linenumber" name="L738" href="#L738">738</a> StringBuilder builder = <strong class="jxr_keyword">new</strong> StringBuilder();
747 <a class="jxr_linenumber" name="L739" href="#L739">739</a> builder.append(<span class="jxr_string">"Hibernate failed:"</span>);
748 <a class="jxr_linenumber" name="L740" href="#L740">740</a> <strong class="jxr_keyword">for</strong> (Exception e : handler.getExceptions())
749 <a class="jxr_linenumber" name="L741" href="#L741">741</a> {
750 <a class="jxr_linenumber" name="L742" href="#L742">742</a> builder.append(<span class="jxr_string">"\n * "</span>);
751 <a class="jxr_linenumber" name="L743" href="#L743">743</a> builder.append(e.getMessage());
752 <a class="jxr_linenumber" name="L744" href="#L744">744</a> AbstractSchemaMojo.printStrackTrace(builder, e);
753 <a class="jxr_linenumber" name="L745" href="#L745">745</a> builder.append(<span class="jxr_string">"\n"</span>);
754 <a class="jxr_linenumber" name="L746" href="#L746">746</a> }
755 <a class="jxr_linenumber" name="L747" href="#L747">747</a> String error = builder.toString();
756 <a class="jxr_linenumber" name="L748" href="#L748">748</a> getLog().error(error);
757 <a class="jxr_linenumber" name="L749" href="#L749">749</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(error);
758 <a class="jxr_linenumber" name="L750" href="#L750">750</a> }
759 <a class="jxr_linenumber" name="L751" href="#L751">751</a> }
760 <a class="jxr_linenumber" name="L752" href="#L752">752</a> <strong class="jxr_keyword">finally</strong>
761 <a class="jxr_linenumber" name="L753" href="#L753">753</a> {
762 <a class="jxr_linenumber" name="L754" href="#L754">754</a> thread.setContextClassLoader(contextClassLoader);
763 <a class="jxr_linenumber" name="L755" href="#L755">755</a> <em class="jxr_javadoccomment">/** Track, the content of the generated script */</em>
764 <a class="jxr_linenumber" name="L756" href="#L756">756</a> checkOutputFile(output, tracker);
765 <a class="jxr_linenumber" name="L757" href="#L757">757</a> }
766 <a class="jxr_linenumber" name="L758" href="#L758">758</a> }
767 <a class="jxr_linenumber" name="L759" href="#L759">759</a> <strong class="jxr_keyword">catch</strong> (MojoExecutionException e)
768 <a class="jxr_linenumber" name="L760" href="#L760">760</a> {
769 <a class="jxr_linenumber" name="L761" href="#L761">761</a> tracker.failed();
770 <a class="jxr_linenumber" name="L762" href="#L762">762</a> <strong class="jxr_keyword">throw</strong> e;
771 <a class="jxr_linenumber" name="L763" href="#L763">763</a> }
772 <a class="jxr_linenumber" name="L764" href="#L764">764</a> <strong class="jxr_keyword">catch</strong> (MojoFailureException e)
773 <a class="jxr_linenumber" name="L765" href="#L765">765</a> {
774 <a class="jxr_linenumber" name="L766" href="#L766">766</a> tracker.failed();
775 <a class="jxr_linenumber" name="L767" href="#L767">767</a> <strong class="jxr_keyword">throw</strong> e;
776 <a class="jxr_linenumber" name="L768" href="#L768">768</a> }
777 <a class="jxr_linenumber" name="L769" href="#L769">769</a> <strong class="jxr_keyword">catch</strong> (RuntimeException e)
778 <a class="jxr_linenumber" name="L770" href="#L770">770</a> {
779 <a class="jxr_linenumber" name="L771" href="#L771">771</a> tracker.failed();
780 <a class="jxr_linenumber" name="L772" href="#L772">772</a> <strong class="jxr_keyword">throw</strong> e;
781 <a class="jxr_linenumber" name="L773" href="#L773">773</a> }
782 <a class="jxr_linenumber" name="L774" href="#L774">774</a> <strong class="jxr_keyword">finally</strong>
783 <a class="jxr_linenumber" name="L775" href="#L775">775</a> {
784 <a class="jxr_linenumber" name="L776" href="#L776">776</a> <em class="jxr_javadoccomment">/** Remember mappings and configuration */</em>
785 <a class="jxr_linenumber" name="L777" href="#L777">777</a> tracker.save();
786 <a class="jxr_linenumber" name="L778" href="#L778">778</a>
787 <a class="jxr_linenumber" name="L779" href="#L779">779</a> <em class="jxr_javadoccomment">/** Close the connection - if one was opened */</em>
788 <a class="jxr_linenumber" name="L780" href="#L780">780</a> connectionProvider.close();
789 <a class="jxr_linenumber" name="L781" href="#L781">781</a>
790 <a class="jxr_linenumber" name="L782" href="#L782">782</a> <em class="jxr_javadoccomment">/** Stop Log-Capturing */</em>
791 <a class="jxr_linenumber" name="L783" href="#L783">783</a> MavenLogAppender.endPluginLog(<strong class="jxr_keyword">this</strong>);
792 <a class="jxr_linenumber" name="L784" href="#L784">784</a> }
793 <a class="jxr_linenumber" name="L785" href="#L785">785</a> }
794 <a class="jxr_linenumber" name="L786" href="#L786">786</a>
795 <a class="jxr_linenumber" name="L787" href="#L787">787</a>
796 <a class="jxr_linenumber" name="L788" href="#L788">788</a> <strong class="jxr_keyword">abstract</strong> <strong class="jxr_keyword">void</strong> build(
797 <a class="jxr_linenumber" name="L789" href="#L789">789</a> MetadataImplementor metadata,
798 <a class="jxr_linenumber" name="L790" href="#L790">790</a> ExecutionOptions options,
799 <a class="jxr_linenumber" name="L791" href="#L791">791</a> TargetDescriptor target
800 <a class="jxr_linenumber" name="L792" href="#L792">792</a> )
801 <a class="jxr_linenumber" name="L793" href="#L793">793</a> <strong class="jxr_keyword">throws</strong>
802 <a class="jxr_linenumber" name="L794" href="#L794">794</a> MojoFailureException,
803 <a class="jxr_linenumber" name="L795" href="#L795">795</a> MojoExecutionException;
804 <a class="jxr_linenumber" name="L796" href="#L796">796</a>
805 <a class="jxr_linenumber" name="L797" href="#L797">797</a>
806 <a class="jxr_linenumber" name="L798" href="#L798">798</a> <strong class="jxr_keyword">private</strong> <a href="../../../../de/juplo/plugins/hibernate/MutableClassLoader.html">MutableClassLoader</a> createClassLoader() <strong class="jxr_keyword">throws</strong> MojoExecutionException
807 <a class="jxr_linenumber" name="L799" href="#L799">799</a> {
808 <a class="jxr_linenumber" name="L800" href="#L800">800</a> <strong class="jxr_keyword">try</strong>
809 <a class="jxr_linenumber" name="L801" href="#L801">801</a> {
810 <a class="jxr_linenumber" name="L802" href="#L802">802</a> getLog().debug(<span class="jxr_string">"Creating ClassLoader for project-dependencies..."</span>);
811 <a class="jxr_linenumber" name="L803" href="#L803">803</a> LinkedHashSet<URL> urls = <strong class="jxr_keyword">new</strong> LinkedHashSet<URL>();
812 <a class="jxr_linenumber" name="L804" href="#L804">804</a> File file;
813 <a class="jxr_linenumber" name="L805" href="#L805">805</a>
814 <a class="jxr_linenumber" name="L806" href="#L806">806</a> file = <strong class="jxr_keyword">new</strong> File(testOutputDirectory);
815 <a class="jxr_linenumber" name="L807" href="#L807">807</a> <strong class="jxr_keyword">if</strong> (!file.exists())
816 <a class="jxr_linenumber" name="L808" href="#L808">808</a> {
817 <a class="jxr_linenumber" name="L809" href="#L809">809</a> getLog().info(<span class="jxr_string">"Creating test-output-directory: "</span> + testOutputDirectory);
818 <a class="jxr_linenumber" name="L810" href="#L810">810</a> file.mkdirs();
819 <a class="jxr_linenumber" name="L811" href="#L811">811</a> }
820 <a class="jxr_linenumber" name="L812" href="#L812">812</a> urls.add(file.toURI().toURL());
821 <a class="jxr_linenumber" name="L813" href="#L813">813</a>
822 <a class="jxr_linenumber" name="L814" href="#L814">814</a> file = <strong class="jxr_keyword">new</strong> File(outputDirectory);
823 <a class="jxr_linenumber" name="L815" href="#L815">815</a> <strong class="jxr_keyword">if</strong> (!file.exists())
824 <a class="jxr_linenumber" name="L816" href="#L816">816</a> {
825 <a class="jxr_linenumber" name="L817" href="#L817">817</a> getLog().info(<span class="jxr_string">"Creating output-directory: "</span> + outputDirectory);
826 <a class="jxr_linenumber" name="L818" href="#L818">818</a> file.mkdirs();
827 <a class="jxr_linenumber" name="L819" href="#L819">819</a> }
828 <a class="jxr_linenumber" name="L820" href="#L820">820</a> urls.add(file.toURI().toURL());
829 <a class="jxr_linenumber" name="L821" href="#L821">821</a>
830 <a class="jxr_linenumber" name="L822" href="#L822">822</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../de/juplo/plugins/hibernate/MutableClassLoader.html">MutableClassLoader</a>(urls, getLog());
831 <a class="jxr_linenumber" name="L823" href="#L823">823</a> }
832 <a class="jxr_linenumber" name="L824" href="#L824">824</a> <strong class="jxr_keyword">catch</strong> (Exception e)
833 <a class="jxr_linenumber" name="L825" href="#L825">825</a> {
834 <a class="jxr_linenumber" name="L826" href="#L826">826</a> getLog().error(<span class="jxr_string">"Error while creating ClassLoader!"</span>, e);
835 <a class="jxr_linenumber" name="L827" href="#L827">827</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(e.getMessage());
836 <a class="jxr_linenumber" name="L828" href="#L828">828</a> }
837 <a class="jxr_linenumber" name="L829" href="#L829">829</a> }
838 <a class="jxr_linenumber" name="L830" href="#L830">830</a>
839 <a class="jxr_linenumber" name="L831" href="#L831">831</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> completeClassPath(<a href="../../../../de/juplo/plugins/hibernate/MutableClassLoader.html">MutableClassLoader</a> classLoader)
840 <a class="jxr_linenumber" name="L832" href="#L832">832</a> <strong class="jxr_keyword">throws</strong>
841 <a class="jxr_linenumber" name="L833" href="#L833">833</a> MojoExecutionException
842 <a class="jxr_linenumber" name="L834" href="#L834">834</a> {
843 <a class="jxr_linenumber" name="L835" href="#L835">835</a> <strong class="jxr_keyword">try</strong>
844 <a class="jxr_linenumber" name="L836" href="#L836">836</a> {
845 <a class="jxr_linenumber" name="L837" href="#L837">837</a> getLog().debug(<span class="jxr_string">"Completing class-paths of the ClassLoader for project-dependencies..."</span>);
846 <a class="jxr_linenumber" name="L838" href="#L838">838</a> List<String> classpathFiles = project.getCompileClasspathElements();
847 <a class="jxr_linenumber" name="L839" href="#L839">839</a> <strong class="jxr_keyword">if</strong> (scanTestClasses)
848 <a class="jxr_linenumber" name="L840" href="#L840">840</a> classpathFiles.addAll(project.getTestClasspathElements());
849 <a class="jxr_linenumber" name="L841" href="#L841">841</a> LinkedHashSet<URL> urls = <strong class="jxr_keyword">new</strong> LinkedHashSet<URL>();
850 <a class="jxr_linenumber" name="L842" href="#L842">842</a> <strong class="jxr_keyword">for</strong> (String pathElement : classpathFiles)
851 <a class="jxr_linenumber" name="L843" href="#L843">843</a> {
852 <a class="jxr_linenumber" name="L844" href="#L844">844</a> getLog().debug(<span class="jxr_string">"Dependency: "</span> + pathElement);
853 <a class="jxr_linenumber" name="L845" href="#L845">845</a> urls.add(<strong class="jxr_keyword">new</strong> File(pathElement).toURI().toURL());
854 <a class="jxr_linenumber" name="L846" href="#L846">846</a> }
855 <a class="jxr_linenumber" name="L847" href="#L847">847</a> classLoader.add(urls);
856 <a class="jxr_linenumber" name="L848" href="#L848">848</a> }
857 <a class="jxr_linenumber" name="L849" href="#L849">849</a> <strong class="jxr_keyword">catch</strong> (Exception e)
858 <a class="jxr_linenumber" name="L850" href="#L850">850</a> {
859 <a class="jxr_linenumber" name="L851" href="#L851">851</a> getLog().error(<span class="jxr_string">"Error while creating ClassLoader!"</span>, e);
860 <a class="jxr_linenumber" name="L852" href="#L852">852</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(e.getMessage());
861 <a class="jxr_linenumber" name="L853" href="#L853">853</a> }
862 <a class="jxr_linenumber" name="L854" href="#L854">854</a> }
863 <a class="jxr_linenumber" name="L855" href="#L855">855</a>
864 <a class="jxr_linenumber" name="L856" href="#L856">856</a> <strong class="jxr_keyword">private</strong> Map loadProperties(ConfigLoader configLoader)
865 <a class="jxr_linenumber" name="L857" href="#L857">857</a> <strong class="jxr_keyword">throws</strong>
866 <a class="jxr_linenumber" name="L858" href="#L858">858</a> MojoExecutionException
867 <a class="jxr_linenumber" name="L859" href="#L859">859</a> {
868 <a class="jxr_linenumber" name="L860" href="#L860">860</a> <em class="jxr_javadoccomment">/** Try to read configuration from properties-file */</em>
869 <a class="jxr_linenumber" name="L861" href="#L861">861</a> <strong class="jxr_keyword">if</strong> (hibernateProperties == <strong class="jxr_keyword">null</strong>)
870 <a class="jxr_linenumber" name="L862" href="#L862">862</a> {
871 <a class="jxr_linenumber" name="L863" href="#L863">863</a> <strong class="jxr_keyword">try</strong>
872 <a class="jxr_linenumber" name="L864" href="#L864">864</a> {
873 <a class="jxr_linenumber" name="L865" href="#L865">865</a> <strong class="jxr_keyword">return</strong> configLoader.loadProperties(<span class="jxr_string">"hibernate.properties"</span>);
874 <a class="jxr_linenumber" name="L866" href="#L866">866</a> }
875 <a class="jxr_linenumber" name="L867" href="#L867">867</a> <strong class="jxr_keyword">catch</strong> (ConfigurationException e)
876 <a class="jxr_linenumber" name="L868" href="#L868">868</a> {
877 <a class="jxr_linenumber" name="L869" href="#L869">869</a> getLog().debug(e.getMessage());
878 <a class="jxr_linenumber" name="L870" href="#L870">870</a> <strong class="jxr_keyword">return</strong> Collections.EMPTY_MAP;
879 <a class="jxr_linenumber" name="L871" href="#L871">871</a> }
880 <a class="jxr_linenumber" name="L872" href="#L872">872</a> }
881 <a class="jxr_linenumber" name="L873" href="#L873">873</a> <strong class="jxr_keyword">else</strong>
882 <a class="jxr_linenumber" name="L874" href="#L874">874</a> {
883 <a class="jxr_linenumber" name="L875" href="#L875">875</a> <strong class="jxr_keyword">try</strong>
884 <a class="jxr_linenumber" name="L876" href="#L876">876</a> {
885 <a class="jxr_linenumber" name="L877" href="#L877">877</a> File file = <strong class="jxr_keyword">new</strong> File(hibernateProperties);
886 <a class="jxr_linenumber" name="L878" href="#L878">878</a> <strong class="jxr_keyword">if</strong> (file.exists())
887 <a class="jxr_linenumber" name="L879" href="#L879">879</a> {
888 <a class="jxr_linenumber" name="L880" href="#L880">880</a> getLog().info(<span class="jxr_string">"Reading settings from file "</span> + hibernateProperties + <span class="jxr_string">"..."</span>);
889 <a class="jxr_linenumber" name="L881" href="#L881">881</a> <strong class="jxr_keyword">return</strong> configLoader.loadProperties(file);
890 <a class="jxr_linenumber" name="L882" href="#L882">882</a> }
891 <a class="jxr_linenumber" name="L883" href="#L883">883</a> <strong class="jxr_keyword">else</strong>
892 <a class="jxr_linenumber" name="L884" href="#L884">884</a> <strong class="jxr_keyword">return</strong> configLoader.loadProperties(hibernateProperties);
893 <a class="jxr_linenumber" name="L885" href="#L885">885</a> }
894 <a class="jxr_linenumber" name="L886" href="#L886">886</a> <strong class="jxr_keyword">catch</strong> (ConfigurationException e)
895 <a class="jxr_linenumber" name="L887" href="#L887">887</a> {
896 <a class="jxr_linenumber" name="L888" href="#L888">888</a> getLog().error(<span class="jxr_string">"Error while reading properties!"</span>, e);
897 <a class="jxr_linenumber" name="L889" href="#L889">889</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(e.getMessage());
898 <a class="jxr_linenumber" name="L890" href="#L890">890</a> }
899 <a class="jxr_linenumber" name="L891" href="#L891">891</a> }
900 <a class="jxr_linenumber" name="L892" href="#L892">892</a> }
901 <a class="jxr_linenumber" name="L893" href="#L893">893</a>
902 <a class="jxr_linenumber" name="L894" href="#L894">894</a> <strong class="jxr_keyword">private</strong> LoadedConfig loadConfig(ConfigLoader configLoader)
903 <a class="jxr_linenumber" name="L895" href="#L895">895</a> <strong class="jxr_keyword">throws</strong> MojoExecutionException
904 <a class="jxr_linenumber" name="L896" href="#L896">896</a> {
905 <a class="jxr_linenumber" name="L897" href="#L897">897</a> <em class="jxr_javadoccomment">/** Try to read configuration from configuration-file */</em>
906 <a class="jxr_linenumber" name="L898" href="#L898">898</a> <strong class="jxr_keyword">if</strong> (hibernateConfig == <strong class="jxr_keyword">null</strong>)
907 <a class="jxr_linenumber" name="L899" href="#L899">899</a> {
908 <a class="jxr_linenumber" name="L900" href="#L900">900</a> <strong class="jxr_keyword">try</strong>
909 <a class="jxr_linenumber" name="L901" href="#L901">901</a> {
910 <a class="jxr_linenumber" name="L902" href="#L902">902</a> <strong class="jxr_keyword">return</strong> configLoader.loadConfigXmlResource(<span class="jxr_string">"hibernate.cfg.xml"</span>);
911 <a class="jxr_linenumber" name="L903" href="#L903">903</a> }
912 <a class="jxr_linenumber" name="L904" href="#L904">904</a> <strong class="jxr_keyword">catch</strong> (ConfigurationException e)
913 <a class="jxr_linenumber" name="L905" href="#L905">905</a> {
914 <a class="jxr_linenumber" name="L906" href="#L906">906</a> getLog().debug(e.getMessage());
915 <a class="jxr_linenumber" name="L907" href="#L907">907</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
916 <a class="jxr_linenumber" name="L908" href="#L908">908</a> }
917 <a class="jxr_linenumber" name="L909" href="#L909">909</a> }
918 <a class="jxr_linenumber" name="L910" href="#L910">910</a> <strong class="jxr_keyword">else</strong>
919 <a class="jxr_linenumber" name="L911" href="#L911">911</a> {
920 <a class="jxr_linenumber" name="L912" href="#L912">912</a> <strong class="jxr_keyword">try</strong>
921 <a class="jxr_linenumber" name="L913" href="#L913">913</a> {
922 <a class="jxr_linenumber" name="L914" href="#L914">914</a> File file = <strong class="jxr_keyword">new</strong> File(hibernateConfig);
923 <a class="jxr_linenumber" name="L915" href="#L915">915</a> <strong class="jxr_keyword">if</strong> (file.exists())
924 <a class="jxr_linenumber" name="L916" href="#L916">916</a> {
925 <a class="jxr_linenumber" name="L917" href="#L917">917</a> getLog().info(<span class="jxr_string">"Reading configuration from file "</span> + hibernateConfig + <span class="jxr_string">"..."</span>);
926 <a class="jxr_linenumber" name="L918" href="#L918">918</a> <strong class="jxr_keyword">return</strong> configLoader.loadConfigXmlFile(file);
927 <a class="jxr_linenumber" name="L919" href="#L919">919</a> }
928 <a class="jxr_linenumber" name="L920" href="#L920">920</a> <strong class="jxr_keyword">else</strong>
929 <a class="jxr_linenumber" name="L921" href="#L921">921</a> {
930 <a class="jxr_linenumber" name="L922" href="#L922">922</a> <strong class="jxr_keyword">return</strong> configLoader.loadConfigXmlResource(hibernateConfig);
931 <a class="jxr_linenumber" name="L923" href="#L923">923</a> }
932 <a class="jxr_linenumber" name="L924" href="#L924">924</a> }
933 <a class="jxr_linenumber" name="L925" href="#L925">925</a> <strong class="jxr_keyword">catch</strong> (ConfigurationException e)
934 <a class="jxr_linenumber" name="L926" href="#L926">926</a> {
935 <a class="jxr_linenumber" name="L927" href="#L927">927</a> getLog().error(<span class="jxr_string">"Error while reading configuration!"</span>, e);
936 <a class="jxr_linenumber" name="L928" href="#L928">928</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(e.getMessage());
937 <a class="jxr_linenumber" name="L929" href="#L929">929</a> }
938 <a class="jxr_linenumber" name="L930" href="#L930">930</a> }
939 <a class="jxr_linenumber" name="L931" href="#L931">931</a> }
940 <a class="jxr_linenumber" name="L932" href="#L932">932</a>
941 <a class="jxr_linenumber" name="L933" href="#L933">933</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> configure(Properties properties, <a href="../../../../de/juplo/plugins/hibernate/ModificationTracker.html">ModificationTracker</a> tracker)
942 <a class="jxr_linenumber" name="L934" href="#L934">934</a> <strong class="jxr_keyword">throws</strong> MojoFailureException
943 <a class="jxr_linenumber" name="L935" href="#L935">935</a> {
944 <a class="jxr_linenumber" name="L936" href="#L936">936</a> <em class="jxr_javadoccomment">/**</em>
945 <a class="jxr_linenumber" name="L937" href="#L937">937</a> <em class="jxr_javadoccomment"> * Special treatment for the configuration-value "execute": if it is</em>
946 <a class="jxr_linenumber" name="L938" href="#L938">938</a> <em class="jxr_javadoccomment"> * switched to "true", the genearation fo the schema should be forced!</em>
947 <a class="jxr_linenumber" name="L939" href="#L939">939</a> <em class="jxr_javadoccomment"> */</em>
948 <a class="jxr_linenumber" name="L940" href="#L940">940</a> <strong class="jxr_keyword">if</strong> (tracker.check(EXECUTE, execute.toString()) && execute)
949 <a class="jxr_linenumber" name="L941" href="#L941">941</a> {
950 <a class="jxr_linenumber" name="L942" href="#L942">942</a> getLog().info(
951 <a class="jxr_linenumber" name="L943" href="#L943">943</a> <span class="jxr_string">"hibernate.schema.execute was switched on: "</span> +
952 <a class="jxr_linenumber" name="L944" href="#L944">944</a> <span class="jxr_string">"forcing generation/execution of SQL"</span>
953 <a class="jxr_linenumber" name="L945" href="#L945">945</a> );
954 <a class="jxr_linenumber" name="L946" href="#L946">946</a> tracker.touch();
955 <a class="jxr_linenumber" name="L947" href="#L947">947</a> }
956 <a class="jxr_linenumber" name="L948" href="#L948">948</a> configure(properties, execute, EXECUTE);
957 <a class="jxr_linenumber" name="L949" href="#L949">949</a>
958 <a class="jxr_linenumber" name="L950" href="#L950">950</a> <em class="jxr_javadoccomment">/**</em>
959 <a class="jxr_linenumber" name="L951" href="#L951">951</a> <em class="jxr_javadoccomment"> * Configure the generation of the SQL.</em>
960 <a class="jxr_linenumber" name="L952" href="#L952">952</a> <em class="jxr_javadoccomment"> * Overwrite values from properties-file if the configuration parameter is</em>
961 <a class="jxr_linenumber" name="L953" href="#L953">953</a> <em class="jxr_javadoccomment"> * known to Hibernate.</em>
962 <a class="jxr_linenumber" name="L954" href="#L954">954</a> <em class="jxr_javadoccomment"> */</em>
963 <a class="jxr_linenumber" name="L955" href="#L955">955</a> configure(properties, dialect, DIALECT);
964 <a class="jxr_linenumber" name="L956" href="#L956">956</a> configure(properties, delimiter, HBM2DDL_DELIMITER);
965 <a class="jxr_linenumber" name="L957" href="#L957">957</a> configure(properties, format, FORMAT_SQL);
966 <a class="jxr_linenumber" name="L958" href="#L958">958</a> configure(properties, createNamespaces, HBM2DLL_CREATE_NAMESPACES);
967 <a class="jxr_linenumber" name="L959" href="#L959">959</a> configure(properties, implicitNamingStrategy, IMPLICIT_NAMING_STRATEGY);
968 <a class="jxr_linenumber" name="L960" href="#L960">960</a> configure(properties, physicalNamingStrategy, PHYSICAL_NAMING_STRATEGY);
969 <a class="jxr_linenumber" name="L961" href="#L961">961</a> configure(properties, outputDirectory, OUTPUTDIRECTORY);
970 <a class="jxr_linenumber" name="L962" href="#L962">962</a> configure(properties, scanDependencies, SCAN_DEPENDENCIES);
971 <a class="jxr_linenumber" name="L963" href="#L963">963</a> configure(properties, scanTestClasses, SCAN_TESTCLASSES);
972 <a class="jxr_linenumber" name="L964" href="#L964">964</a> configure(properties, testOutputDirectory, TEST_OUTPUTDIRECTORY);
973 <a class="jxr_linenumber" name="L965" href="#L965">965</a>
974 <a class="jxr_linenumber" name="L966" href="#L966">966</a> <em class="jxr_javadoccomment">/**</em>
975 <a class="jxr_linenumber" name="L967" href="#L967">967</a> <em class="jxr_javadoccomment"> * Special treatment for the configuration-value "show": a change of its</em>
976 <a class="jxr_linenumber" name="L968" href="#L968">968</a> <em class="jxr_javadoccomment"> * configured value should not lead to a regeneration of the database</em>
977 <a class="jxr_linenumber" name="L969" href="#L969">969</a> <em class="jxr_javadoccomment"> * schama!</em>
978 <a class="jxr_linenumber" name="L970" href="#L970">970</a> <em class="jxr_javadoccomment"> */</em>
979 <a class="jxr_linenumber" name="L971" href="#L971">971</a> <strong class="jxr_keyword">if</strong> (show == <strong class="jxr_keyword">null</strong>)
980 <a class="jxr_linenumber" name="L972" href="#L972">972</a> show = Boolean.valueOf(properties.getProperty(SHOW_SQL));
981 <a class="jxr_linenumber" name="L973" href="#L973">973</a> <strong class="jxr_keyword">else</strong>
982 <a class="jxr_linenumber" name="L974" href="#L974">974</a> properties.setProperty(SHOW_SQL, show.toString());
983 <a class="jxr_linenumber" name="L975" href="#L975">975</a>
984 <a class="jxr_linenumber" name="L976" href="#L976">976</a> <em class="jxr_javadoccomment">/**</em>
985 <a class="jxr_linenumber" name="L977" href="#L977">977</a> <em class="jxr_javadoccomment"> * Configure the connection parameters.</em>
986 <a class="jxr_linenumber" name="L978" href="#L978">978</a> <em class="jxr_javadoccomment"> * Overwrite values from properties-file.</em>
987 <a class="jxr_linenumber" name="L979" href="#L979">979</a> <em class="jxr_javadoccomment"> */</em>
988 <a class="jxr_linenumber" name="L980" href="#L980">980</a> configure(properties, driver, DRIVER, JPA_JDBC_DRIVER);
989 <a class="jxr_linenumber" name="L981" href="#L981">981</a> configure(properties, url, URL, JPA_JDBC_URL);
990 <a class="jxr_linenumber" name="L982" href="#L982">982</a> configure(properties, username, USER, JPA_JDBC_USER);
991 <a class="jxr_linenumber" name="L983" href="#L983">983</a> configure(properties, password, PASS, JPA_JDBC_PASSWORD);
992 <a class="jxr_linenumber" name="L984" href="#L984">984</a>
993 <a class="jxr_linenumber" name="L985" href="#L985">985</a> <strong class="jxr_keyword">if</strong> (properties.isEmpty())
994 <a class="jxr_linenumber" name="L986" href="#L986">986</a> {
995 <a class="jxr_linenumber" name="L987" href="#L987">987</a> getLog().error(<span class="jxr_string">"No properties set!"</span>);
996 <a class="jxr_linenumber" name="L988" href="#L988">988</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"Hibernate configuration is missing!"</span>);
997 <a class="jxr_linenumber" name="L989" href="#L989">989</a> }
998 <a class="jxr_linenumber" name="L990" href="#L990">990</a>
999 <a class="jxr_linenumber" name="L991" href="#L991">991</a> getLog().info(<span class="jxr_string">"Gathered configuration:"</span>);
1000 <a class="jxr_linenumber" name="L992" href="#L992">992</a> <strong class="jxr_keyword">for</strong> (Entry<Object,Object> entry : properties.entrySet())
1001 <a class="jxr_linenumber" name="L993" href="#L993">993</a> getLog().info(<span class="jxr_string">" "</span> + entry.getKey() + <span class="jxr_string">" = "</span> + entry.getValue());
1002 <a class="jxr_linenumber" name="L994" href="#L994">994</a> }
1003 <a class="jxr_linenumber" name="L995" href="#L995">995</a>
1004 <a class="jxr_linenumber" name="L996" href="#L996">996</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> configure(
1005 <a class="jxr_linenumber" name="L997" href="#L997">997</a> Properties properties,
1006 <a class="jxr_linenumber" name="L998" href="#L998">998</a> String value,
1007 <a class="jxr_linenumber" name="L999" href="#L999">999</a> String key,
1008 <a class="jxr_linenumber" name="L1000" href="#L1000">1000</a> String alternativeKey
1009 <a class="jxr_linenumber" name="L1001" href="#L1001">1001</a> )
1010 <a class="jxr_linenumber" name="L1002" href="#L1002">1002</a> {
1011 <a class="jxr_linenumber" name="L1003" href="#L1003">1003</a> configure(properties, value, key);
1012 <a class="jxr_linenumber" name="L1004" href="#L1004">1004</a>
1013 <a class="jxr_linenumber" name="L1005" href="#L1005">1005</a> <strong class="jxr_keyword">if</strong> (properties.containsKey(alternativeKey))
1014 <a class="jxr_linenumber" name="L1006" href="#L1006">1006</a> {
1015 <a class="jxr_linenumber" name="L1007" href="#L1007">1007</a> <strong class="jxr_keyword">if</strong> (properties.containsKey(key))
1016 <a class="jxr_linenumber" name="L1008" href="#L1008">1008</a> {
1017 <a class="jxr_linenumber" name="L1009" href="#L1009">1009</a> getLog().warn(
1018 <a class="jxr_linenumber" name="L1010" href="#L1010">1010</a> <span class="jxr_string">"Ignoring property "</span> + alternativeKey + <span class="jxr_string">"=\""</span> +
1019 <a class="jxr_linenumber" name="L1011" href="#L1011">1011</a> properties.getProperty(alternativeKey) +
1020 <a class="jxr_linenumber" name="L1012" href="#L1012">1012</a> <span class="jxr_string">"\" in favour for property "</span> + key + <span class="jxr_string">"=\""</span> +
1021 <a class="jxr_linenumber" name="L1013" href="#L1013">1013</a> properties.getProperty(key) + <span class="jxr_string">"\""</span>
1022 <a class="jxr_linenumber" name="L1014" href="#L1014">1014</a> );
1023 <a class="jxr_linenumber" name="L1015" href="#L1015">1015</a> properties.remove(alternativeKey);
1024 <a class="jxr_linenumber" name="L1016" href="#L1016">1016</a> }
1025 <a class="jxr_linenumber" name="L1017" href="#L1017">1017</a> <strong class="jxr_keyword">else</strong>
1026 <a class="jxr_linenumber" name="L1018" href="#L1018">1018</a> {
1027 <a class="jxr_linenumber" name="L1019" href="#L1019">1019</a> value = properties.getProperty(alternativeKey);
1028 <a class="jxr_linenumber" name="L1020" href="#L1020">1020</a> properties.remove(alternativeKey);
1029 <a class="jxr_linenumber" name="L1021" href="#L1021">1021</a> getLog().info(
1030 <a class="jxr_linenumber" name="L1022" href="#L1022">1022</a> <span class="jxr_string">"Using value \""</span> + value + <span class="jxr_string">"\" from property "</span> + alternativeKey +
1031 <a class="jxr_linenumber" name="L1023" href="#L1023">1023</a> <span class="jxr_string">" for property "</span> + key
1032 <a class="jxr_linenumber" name="L1024" href="#L1024">1024</a> );
1033 <a class="jxr_linenumber" name="L1025" href="#L1025">1025</a> properties.setProperty(key, value);
1034 <a class="jxr_linenumber" name="L1026" href="#L1026">1026</a> }
1035 <a class="jxr_linenumber" name="L1027" href="#L1027">1027</a> }
1036 <a class="jxr_linenumber" name="L1028" href="#L1028">1028</a> }
1037 <a class="jxr_linenumber" name="L1029" href="#L1029">1029</a>
1038 <a class="jxr_linenumber" name="L1030" href="#L1030">1030</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> configure(Properties properties, String value, String key)
1039 <a class="jxr_linenumber" name="L1031" href="#L1031">1031</a> {
1040 <a class="jxr_linenumber" name="L1032" href="#L1032">1032</a> <strong class="jxr_keyword">if</strong> (value != <strong class="jxr_keyword">null</strong>)
1041 <a class="jxr_linenumber" name="L1033" href="#L1033">1033</a> {
1042 <a class="jxr_linenumber" name="L1034" href="#L1034">1034</a> <strong class="jxr_keyword">if</strong> (properties.containsKey(key))
1043 <a class="jxr_linenumber" name="L1035" href="#L1035">1035</a> {
1044 <a class="jxr_linenumber" name="L1036" href="#L1036">1036</a> <strong class="jxr_keyword">if</strong> (!properties.getProperty(key).equals(value))
1045 <a class="jxr_linenumber" name="L1037" href="#L1037">1037</a> {
1046 <a class="jxr_linenumber" name="L1038" href="#L1038">1038</a> getLog().info(
1047 <a class="jxr_linenumber" name="L1039" href="#L1039">1039</a> <span class="jxr_string">"Overwriting property "</span> + key + <span class="jxr_string">"=\""</span> +
1048 <a class="jxr_linenumber" name="L1040" href="#L1040">1040</a> properties.getProperty(key) +
1049 <a class="jxr_linenumber" name="L1041" href="#L1041">1041</a> <span class="jxr_string">"\" with value \""</span> + value + <span class="jxr_string">"\""</span>
1050 <a class="jxr_linenumber" name="L1042" href="#L1042">1042</a> );
1051 <a class="jxr_linenumber" name="L1043" href="#L1043">1043</a> properties.setProperty(key, value);
1052 <a class="jxr_linenumber" name="L1044" href="#L1044">1044</a> }
1053 <a class="jxr_linenumber" name="L1045" href="#L1045">1045</a> }
1054 <a class="jxr_linenumber" name="L1046" href="#L1046">1046</a> <strong class="jxr_keyword">else</strong>
1055 <a class="jxr_linenumber" name="L1047" href="#L1047">1047</a> {
1056 <a class="jxr_linenumber" name="L1048" href="#L1048">1048</a> getLog().debug(<span class="jxr_string">"Using value \""</span> + value + <span class="jxr_string">"\" for property "</span> + key);
1057 <a class="jxr_linenumber" name="L1049" href="#L1049">1049</a> properties.setProperty(key, value);
1058 <a class="jxr_linenumber" name="L1050" href="#L1050">1050</a> }
1059 <a class="jxr_linenumber" name="L1051" href="#L1051">1051</a> }
1060 <a class="jxr_linenumber" name="L1052" href="#L1052">1052</a> }
1061 <a class="jxr_linenumber" name="L1053" href="#L1053">1053</a>
1062 <a class="jxr_linenumber" name="L1054" href="#L1054">1054</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> configure(Properties properties, Boolean value, String key)
1063 <a class="jxr_linenumber" name="L1055" href="#L1055">1055</a> {
1064 <a class="jxr_linenumber" name="L1056" href="#L1056">1056</a> configure(properties, value == <strong class="jxr_keyword">null</strong> ? <strong class="jxr_keyword">null</strong> : value.toString(), key);
1065 <a class="jxr_linenumber" name="L1057" href="#L1057">1057</a> }
1066 <a class="jxr_linenumber" name="L1058" href="#L1058">1058</a>
1067 <a class="jxr_linenumber" name="L1059" href="#L1059">1059</a> <strong class="jxr_keyword">private</strong> File getOutputFile(String filename)
1068 <a class="jxr_linenumber" name="L1060" href="#L1060">1060</a> <strong class="jxr_keyword">throws</strong>
1069 <a class="jxr_linenumber" name="L1061" href="#L1061">1061</a> MojoExecutionException
1070 <a class="jxr_linenumber" name="L1062" href="#L1062">1062</a> {
1071 <a class="jxr_linenumber" name="L1063" href="#L1063">1063</a> File output = <strong class="jxr_keyword">new</strong> File(filename);
1072 <a class="jxr_linenumber" name="L1064" href="#L1064">1064</a>
1073 <a class="jxr_linenumber" name="L1065" href="#L1065">1065</a> <strong class="jxr_keyword">if</strong> (!output.isAbsolute())
1074 <a class="jxr_linenumber" name="L1066" href="#L1066">1066</a> {
1075 <a class="jxr_linenumber" name="L1067" href="#L1067">1067</a> <em class="jxr_comment">// Interpret relative file path relative to build directory</em>
1076 <a class="jxr_linenumber" name="L1068" href="#L1068">1068</a> output = <strong class="jxr_keyword">new</strong> File(buildDirectory, filename);
1077 <a class="jxr_linenumber" name="L1069" href="#L1069">1069</a> }
1078 <a class="jxr_linenumber" name="L1070" href="#L1070">1070</a> getLog().debug(<span class="jxr_string">"Output file: "</span> + output.getPath());
1079 <a class="jxr_linenumber" name="L1071" href="#L1071">1071</a>
1080 <a class="jxr_linenumber" name="L1072" href="#L1072">1072</a> <em class="jxr_comment">// Ensure that directory path for specified file exists</em>
1081 <a class="jxr_linenumber" name="L1073" href="#L1073">1073</a> File outFileParentDir = output.getParentFile();
1082 <a class="jxr_linenumber" name="L1074" href="#L1074">1074</a> <strong class="jxr_keyword">if</strong> (<strong class="jxr_keyword">null</strong> != outFileParentDir && !outFileParentDir.exists())
1083 <a class="jxr_linenumber" name="L1075" href="#L1075">1075</a> {
1084 <a class="jxr_linenumber" name="L1076" href="#L1076">1076</a> <strong class="jxr_keyword">try</strong>
1085 <a class="jxr_linenumber" name="L1077" href="#L1077">1077</a> {
1086 <a class="jxr_linenumber" name="L1078" href="#L1078">1078</a> getLog().info(
1087 <a class="jxr_linenumber" name="L1079" href="#L1079">1079</a> <span class="jxr_string">"Creating directory path for output file:"</span> +
1088 <a class="jxr_linenumber" name="L1080" href="#L1080">1080</a> outFileParentDir.getPath()
1089 <a class="jxr_linenumber" name="L1081" href="#L1081">1081</a> );
1090 <a class="jxr_linenumber" name="L1082" href="#L1082">1082</a> outFileParentDir.mkdirs();
1091 <a class="jxr_linenumber" name="L1083" href="#L1083">1083</a> }
1092 <a class="jxr_linenumber" name="L1084" href="#L1084">1084</a> <strong class="jxr_keyword">catch</strong> (Exception e)
1093 <a class="jxr_linenumber" name="L1085" href="#L1085">1085</a> {
1094 <a class="jxr_linenumber" name="L1086" href="#L1086">1086</a> String error =
1095 <a class="jxr_linenumber" name="L1087" href="#L1087">1087</a> <span class="jxr_string">"Error creating directory path for output file: "</span> + e.getMessage();
1096 <a class="jxr_linenumber" name="L1088" href="#L1088">1088</a> getLog().error(error);
1097 <a class="jxr_linenumber" name="L1089" href="#L1089">1089</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(error);
1098 <a class="jxr_linenumber" name="L1090" href="#L1090">1090</a> }
1099 <a class="jxr_linenumber" name="L1091" href="#L1091">1091</a> }
1100 <a class="jxr_linenumber" name="L1092" href="#L1092">1092</a>
1101 <a class="jxr_linenumber" name="L1093" href="#L1093">1093</a> <strong class="jxr_keyword">try</strong>
1102 <a class="jxr_linenumber" name="L1094" href="#L1094">1094</a> {
1103 <a class="jxr_linenumber" name="L1095" href="#L1095">1095</a> output.createNewFile();
1104 <a class="jxr_linenumber" name="L1096" href="#L1096">1096</a> }
1105 <a class="jxr_linenumber" name="L1097" href="#L1097">1097</a> <strong class="jxr_keyword">catch</strong> (IOException e)
1106 <a class="jxr_linenumber" name="L1098" href="#L1098">1098</a> {
1107 <a class="jxr_linenumber" name="L1099" href="#L1099">1099</a> String error = <span class="jxr_string">"Error creating output file: "</span> + e.getMessage();
1108 <a class="jxr_linenumber" name="L1100" href="#L1100">1100</a> getLog().error(error);
1109 <a class="jxr_linenumber" name="L1101" href="#L1101">1101</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(error);
1110 <a class="jxr_linenumber" name="L1102" href="#L1102">1102</a> }
1111 <a class="jxr_linenumber" name="L1103" href="#L1103">1103</a>
1112 <a class="jxr_linenumber" name="L1104" href="#L1104">1104</a> <strong class="jxr_keyword">if</strong> (!output.canWrite())
1113 <a class="jxr_linenumber" name="L1105" href="#L1105">1105</a> {
1114 <a class="jxr_linenumber" name="L1106" href="#L1106">1106</a> String error =
1115 <a class="jxr_linenumber" name="L1107" href="#L1107">1107</a> <span class="jxr_string">"Output file "</span> + output.getAbsolutePath() + <span class="jxr_string">" is not writable!"</span>;
1116 <a class="jxr_linenumber" name="L1108" href="#L1108">1108</a> getLog().error(error);
1117 <a class="jxr_linenumber" name="L1109" href="#L1109">1109</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(error);
1118 <a class="jxr_linenumber" name="L1110" href="#L1110">1110</a> }
1119 <a class="jxr_linenumber" name="L1111" href="#L1111">1111</a>
1120 <a class="jxr_linenumber" name="L1112" href="#L1112">1112</a> <strong class="jxr_keyword">return</strong> output;
1121 <a class="jxr_linenumber" name="L1113" href="#L1113">1113</a> }
1122 <a class="jxr_linenumber" name="L1114" href="#L1114">1114</a>
1123 <a class="jxr_linenumber" name="L1115" href="#L1115">1115</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> checkOutputFile(File output, <a href="../../../../de/juplo/plugins/hibernate/ModificationTracker.html">ModificationTracker</a> tracker)
1124 <a class="jxr_linenumber" name="L1116" href="#L1116">1116</a> <strong class="jxr_keyword">throws</strong>
1125 <a class="jxr_linenumber" name="L1117" href="#L1117">1117</a> MojoExecutionException
1126 <a class="jxr_linenumber" name="L1118" href="#L1118">1118</a> {
1127 <a class="jxr_linenumber" name="L1119" href="#L1119">1119</a> <strong class="jxr_keyword">try</strong>
1128 <a class="jxr_linenumber" name="L1120" href="#L1120">1120</a> {
1129 <a class="jxr_linenumber" name="L1121" href="#L1121">1121</a> <strong class="jxr_keyword">if</strong> (output.exists())
1130 <a class="jxr_linenumber" name="L1122" href="#L1122">1122</a> tracker.track(SCRIPT, <strong class="jxr_keyword">new</strong> FileInputStream(output));
1131 <a class="jxr_linenumber" name="L1123" href="#L1123">1123</a> <strong class="jxr_keyword">else</strong>
1132 <a class="jxr_linenumber" name="L1124" href="#L1124">1124</a> tracker.track(SCRIPT, ZonedDateTime.now().toString());
1133 <a class="jxr_linenumber" name="L1125" href="#L1125">1125</a> }
1134 <a class="jxr_linenumber" name="L1126" href="#L1126">1126</a> <strong class="jxr_keyword">catch</strong> (IOException e)
1135 <a class="jxr_linenumber" name="L1127" href="#L1127">1127</a> {
1136 <a class="jxr_linenumber" name="L1128" href="#L1128">1128</a> String error =
1137 <a class="jxr_linenumber" name="L1129" href="#L1129">1129</a> <span class="jxr_string">"Error while checking the generated script: "</span> + e.getMessage();
1138 <a class="jxr_linenumber" name="L1130" href="#L1130">1130</a> getLog().error(error);
1139 <a class="jxr_linenumber" name="L1131" href="#L1131">1131</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(error);
1140 <a class="jxr_linenumber" name="L1132" href="#L1132">1132</a> }
1141 <a class="jxr_linenumber" name="L1133" href="#L1133">1133</a> }
1142 <a class="jxr_linenumber" name="L1134" href="#L1134">1134</a>
1143 <a class="jxr_linenumber" name="L1135" href="#L1135">1135</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> addMappings(MetadataSources sources, <a href="../../../../de/juplo/plugins/hibernate/ModificationTracker.html">ModificationTracker</a> tracker)
1144 <a class="jxr_linenumber" name="L1136" href="#L1136">1136</a> <strong class="jxr_keyword">throws</strong> MojoFailureException
1145 <a class="jxr_linenumber" name="L1137" href="#L1137">1137</a> {
1146 <a class="jxr_linenumber" name="L1138" href="#L1138">1138</a> getLog().debug(<span class="jxr_string">"Adding explicitly configured mappings..."</span>);
1147 <a class="jxr_linenumber" name="L1139" href="#L1139">1139</a> <strong class="jxr_keyword">if</strong> (mappings != <strong class="jxr_keyword">null</strong>)
1148 <a class="jxr_linenumber" name="L1140" href="#L1140">1140</a> {
1149 <a class="jxr_linenumber" name="L1141" href="#L1141">1141</a> <strong class="jxr_keyword">try</strong>
1150 <a class="jxr_linenumber" name="L1142" href="#L1142">1142</a> {
1151 <a class="jxr_linenumber" name="L1143" href="#L1143">1143</a> <strong class="jxr_keyword">for</strong> (String filename : mappings.split(<span class="jxr_string">"[\\s,]+"</span>))
1152 <a class="jxr_linenumber" name="L1144" href="#L1144">1144</a> {
1153 <a class="jxr_linenumber" name="L1145" href="#L1145">1145</a> <em class="jxr_comment">// First try the filename as absolute/relative path</em>
1154 <a class="jxr_linenumber" name="L1146" href="#L1146">1146</a> File file = <strong class="jxr_keyword">new</strong> File(filename);
1155 <a class="jxr_linenumber" name="L1147" href="#L1147">1147</a> <strong class="jxr_keyword">if</strong> (!file.exists())
1156 <a class="jxr_linenumber" name="L1148" href="#L1148">1148</a> {
1157 <a class="jxr_linenumber" name="L1149" href="#L1149">1149</a> <em class="jxr_comment">// If the file was not found, search for it in the resource-directories</em>
1158 <a class="jxr_linenumber" name="L1150" href="#L1150">1150</a> <strong class="jxr_keyword">for</strong> (Resource resource : project.getResources())
1159 <a class="jxr_linenumber" name="L1151" href="#L1151">1151</a> {
1160 <a class="jxr_linenumber" name="L1152" href="#L1152">1152</a> file = <strong class="jxr_keyword">new</strong> File(resource.getDirectory() + File.separator + filename);
1161 <a class="jxr_linenumber" name="L1153" href="#L1153">1153</a> <strong class="jxr_keyword">if</strong> (file.exists())
1162 <a class="jxr_linenumber" name="L1154" href="#L1154">1154</a> <strong class="jxr_keyword">break</strong>;
1163 <a class="jxr_linenumber" name="L1155" href="#L1155">1155</a> }
1164 <a class="jxr_linenumber" name="L1156" href="#L1156">1156</a> }
1165 <a class="jxr_linenumber" name="L1157" href="#L1157">1157</a> <strong class="jxr_keyword">if</strong> (file.exists())
1166 <a class="jxr_linenumber" name="L1158" href="#L1158">1158</a> {
1167 <a class="jxr_linenumber" name="L1159" href="#L1159">1159</a> <strong class="jxr_keyword">if</strong> (file.isDirectory())
1168 <a class="jxr_linenumber" name="L1160" href="#L1160">1160</a> <em class="jxr_comment">// TODO: add support to read all mappings under a directory</em>
1169 <a class="jxr_linenumber" name="L1161" href="#L1161">1161</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(file.getAbsolutePath() + <span class="jxr_string">" is a directory"</span>);
1170 <a class="jxr_linenumber" name="L1162" href="#L1162">1162</a> <strong class="jxr_keyword">if</strong> (tracker.track(filename, <strong class="jxr_keyword">new</strong> FileInputStream(file)))
1171 <a class="jxr_linenumber" name="L1163" href="#L1163">1163</a> getLog().debug(<span class="jxr_string">"Found new or modified mapping-file: "</span> + filename);
1172 <a class="jxr_linenumber" name="L1164" href="#L1164">1164</a> <strong class="jxr_keyword">else</strong>
1173 <a class="jxr_linenumber" name="L1165" href="#L1165">1165</a> getLog().debug(<span class="jxr_string">"Mapping-file unchanged: "</span> + filename);
1174 <a class="jxr_linenumber" name="L1166" href="#L1166">1166</a>
1175 <a class="jxr_linenumber" name="L1167" href="#L1167">1167</a> sources.addFile(file);
1176 <a class="jxr_linenumber" name="L1168" href="#L1168">1168</a> }
1177 <a class="jxr_linenumber" name="L1169" href="#L1169">1169</a> <strong class="jxr_keyword">else</strong>
1178 <a class="jxr_linenumber" name="L1170" href="#L1170">1170</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"File "</span> + filename + <span class="jxr_string">" could not be found in any of the configured resource-directories!"</span>);
1179 <a class="jxr_linenumber" name="L1171" href="#L1171">1171</a> }
1180 <a class="jxr_linenumber" name="L1172" href="#L1172">1172</a> }
1181 <a class="jxr_linenumber" name="L1173" href="#L1173">1173</a> <strong class="jxr_keyword">catch</strong> (IOException e)
1182 <a class="jxr_linenumber" name="L1174" href="#L1174">1174</a> {
1183 <a class="jxr_linenumber" name="L1175" href="#L1175">1175</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"Cannot calculate MD5 sums!"</span>, e);
1184 <a class="jxr_linenumber" name="L1176" href="#L1176">1176</a> }
1185 <a class="jxr_linenumber" name="L1177" href="#L1177">1177</a> }
1186 <a class="jxr_linenumber" name="L1178" href="#L1178">1178</a> }
1187 <a class="jxr_linenumber" name="L1179" href="#L1179">1179</a>
1188 <a class="jxr_linenumber" name="L1180" href="#L1180">1180</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> addRoot(Set<URL> urls, String path) <strong class="jxr_keyword">throws</strong> MojoFailureException
1189 <a class="jxr_linenumber" name="L1181" href="#L1181">1181</a> {
1190 <a class="jxr_linenumber" name="L1182" href="#L1182">1182</a> <strong class="jxr_keyword">try</strong>
1191 <a class="jxr_linenumber" name="L1183" href="#L1183">1183</a> {
1192 <a class="jxr_linenumber" name="L1184" href="#L1184">1184</a> File dir = <strong class="jxr_keyword">new</strong> File(path);
1193 <a class="jxr_linenumber" name="L1185" href="#L1185">1185</a> <strong class="jxr_keyword">if</strong> (dir.exists())
1194 <a class="jxr_linenumber" name="L1186" href="#L1186">1186</a> {
1195 <a class="jxr_linenumber" name="L1187" href="#L1187">1187</a> getLog().info(<span class="jxr_string">"Adding "</span> + dir.getAbsolutePath() + <span class="jxr_string">" to the list of roots to scan..."</span>);
1196 <a class="jxr_linenumber" name="L1188" href="#L1188">1188</a> urls.add(dir.toURI().toURL());
1197 <a class="jxr_linenumber" name="L1189" href="#L1189">1189</a> }
1198 <a class="jxr_linenumber" name="L1190" href="#L1190">1190</a> <strong class="jxr_keyword">else</strong>
1199 <a class="jxr_linenumber" name="L1191" href="#L1191">1191</a> getLog().warn(
1200 <a class="jxr_linenumber" name="L1192" href="#L1192">1192</a> <span class="jxr_string">"the directory cannot be scanned for annotated classes, "</span> +
1201 <a class="jxr_linenumber" name="L1193" href="#L1193">1193</a> <span class="jxr_string">"because it does not exist: "</span> +
1202 <a class="jxr_linenumber" name="L1194" href="#L1194">1194</a> dir.getAbsolutePath()
1203 <a class="jxr_linenumber" name="L1195" href="#L1195">1195</a> );
1204 <a class="jxr_linenumber" name="L1196" href="#L1196">1196</a> }
1205 <a class="jxr_linenumber" name="L1197" href="#L1197">1197</a> <strong class="jxr_keyword">catch</strong> (MalformedURLException e)
1206 <a class="jxr_linenumber" name="L1198" href="#L1198">1198</a> {
1207 <a class="jxr_linenumber" name="L1199" href="#L1199">1199</a> getLog().error(<span class="jxr_string">"error while adding the project-root to the list of roots to scan!"</span>, e);
1208 <a class="jxr_linenumber" name="L1200" href="#L1200">1200</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(e.getMessage());
1209 <a class="jxr_linenumber" name="L1201" href="#L1201">1201</a> }
1210 <a class="jxr_linenumber" name="L1202" href="#L1202">1202</a> }
1211 <a class="jxr_linenumber" name="L1203" href="#L1203">1203</a>
1212 <a class="jxr_linenumber" name="L1204" href="#L1204">1204</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> addDependencies(Set<URL> urls) <strong class="jxr_keyword">throws</strong> MojoFailureException
1213 <a class="jxr_linenumber" name="L1205" href="#L1205">1205</a> {
1214 <a class="jxr_linenumber" name="L1206" href="#L1206">1206</a> <strong class="jxr_keyword">try</strong>
1215 <a class="jxr_linenumber" name="L1207" href="#L1207">1207</a> {
1216 <a class="jxr_linenumber" name="L1208" href="#L1208">1208</a> <strong class="jxr_keyword">if</strong> (scanDependencies != <strong class="jxr_keyword">null</strong>)
1217 <a class="jxr_linenumber" name="L1209" href="#L1209">1209</a> {
1218 <a class="jxr_linenumber" name="L1210" href="#L1210">1210</a> Matcher matcher = SPLIT.matcher(scanDependencies);
1219 <a class="jxr_linenumber" name="L1211" href="#L1211">1211</a> <strong class="jxr_keyword">while</strong> (matcher.find())
1220 <a class="jxr_linenumber" name="L1212" href="#L1212">1212</a> {
1221 <a class="jxr_linenumber" name="L1213" href="#L1213">1213</a> getLog().info(<span class="jxr_string">"Adding dependencies from scope "</span> + matcher.group() + <span class="jxr_string">" to the list of roots to scan"</span>);
1222 <a class="jxr_linenumber" name="L1214" href="#L1214">1214</a> <strong class="jxr_keyword">for</strong> (Artifact artifact : project.getDependencyArtifacts())
1223 <a class="jxr_linenumber" name="L1215" href="#L1215">1215</a> {
1224 <a class="jxr_linenumber" name="L1216" href="#L1216">1216</a> <strong class="jxr_keyword">if</strong> (!artifact.getScope().equalsIgnoreCase(matcher.group()))
1225 <a class="jxr_linenumber" name="L1217" href="#L1217">1217</a> <strong class="jxr_keyword">continue</strong>;
1226 <a class="jxr_linenumber" name="L1218" href="#L1218">1218</a> <strong class="jxr_keyword">if</strong> (artifact.getFile() == <strong class="jxr_keyword">null</strong>)
1227 <a class="jxr_linenumber" name="L1219" href="#L1219">1219</a> {
1228 <a class="jxr_linenumber" name="L1220" href="#L1220">1220</a> getLog().warn(<span class="jxr_string">"Cannot add dependency "</span> + artifact.getId() + <span class="jxr_string">": no JAR-file available!"</span>);
1229 <a class="jxr_linenumber" name="L1221" href="#L1221">1221</a> <strong class="jxr_keyword">continue</strong>;
1230 <a class="jxr_linenumber" name="L1222" href="#L1222">1222</a> }
1231 <a class="jxr_linenumber" name="L1223" href="#L1223">1223</a> getLog().info(<span class="jxr_string">"Adding dependencies from scope "</span> + artifact.getId() + <span class="jxr_string">" to the list of roots to scan"</span>);
1232 <a class="jxr_linenumber" name="L1224" href="#L1224">1224</a> urls.add(artifact.getFile().toURI().toURL());
1233 <a class="jxr_linenumber" name="L1225" href="#L1225">1225</a> }
1234 <a class="jxr_linenumber" name="L1226" href="#L1226">1226</a> }
1235 <a class="jxr_linenumber" name="L1227" href="#L1227">1227</a> }
1236 <a class="jxr_linenumber" name="L1228" href="#L1228">1228</a> }
1237 <a class="jxr_linenumber" name="L1229" href="#L1229">1229</a> <strong class="jxr_keyword">catch</strong> (MalformedURLException e)
1238 <a class="jxr_linenumber" name="L1230" href="#L1230">1230</a> {
1239 <a class="jxr_linenumber" name="L1231" href="#L1231">1231</a> getLog().error(<span class="jxr_string">"Error while adding dependencies to the list of roots to scan!"</span>, e);
1240 <a class="jxr_linenumber" name="L1232" href="#L1232">1232</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(e.getMessage());
1241 <a class="jxr_linenumber" name="L1233" href="#L1233">1233</a> }
1242 <a class="jxr_linenumber" name="L1234" href="#L1234">1234</a> }
1243 <a class="jxr_linenumber" name="L1235" href="#L1235">1235</a>
1244 <a class="jxr_linenumber" name="L1236" href="#L1236">1236</a> <strong class="jxr_keyword">private</strong> Set<String> scanUrls(Set<URL> scanRoots)
1245 <a class="jxr_linenumber" name="L1237" href="#L1237">1237</a> <strong class="jxr_keyword">throws</strong>
1246 <a class="jxr_linenumber" name="L1238" href="#L1238">1238</a> MojoFailureException
1247 <a class="jxr_linenumber" name="L1239" href="#L1239">1239</a> {
1248 <a class="jxr_linenumber" name="L1240" href="#L1240">1240</a> <strong class="jxr_keyword">try</strong>
1249 <a class="jxr_linenumber" name="L1241" href="#L1241">1241</a> {
1250 <a class="jxr_linenumber" name="L1242" href="#L1242">1242</a> AnnotationDB db = <strong class="jxr_keyword">new</strong> AnnotationDB();
1251 <a class="jxr_linenumber" name="L1243" href="#L1243">1243</a> <strong class="jxr_keyword">for</strong> (URL root : scanRoots)
1252 <a class="jxr_linenumber" name="L1244" href="#L1244">1244</a> db.scanArchives(root);
1253 <a class="jxr_linenumber" name="L1245" href="#L1245">1245</a>
1254 <a class="jxr_linenumber" name="L1246" href="#L1246">1246</a> Set<String> classes = <strong class="jxr_keyword">new</strong> HashSet<String>();
1255 <a class="jxr_linenumber" name="L1247" href="#L1247">1247</a> <strong class="jxr_keyword">if</strong> (db.getAnnotationIndex().containsKey(Entity.<strong class="jxr_keyword">class</strong>.getName()))
1256 <a class="jxr_linenumber" name="L1248" href="#L1248">1248</a> classes.addAll(db.getAnnotationIndex().get(Entity.<strong class="jxr_keyword">class</strong>.getName()));
1257 <a class="jxr_linenumber" name="L1249" href="#L1249">1249</a> <strong class="jxr_keyword">if</strong> (db.getAnnotationIndex().containsKey(MappedSuperclass.<strong class="jxr_keyword">class</strong>.getName()))
1258 <a class="jxr_linenumber" name="L1250" href="#L1250">1250</a> classes.addAll(db.getAnnotationIndex().get(MappedSuperclass.<strong class="jxr_keyword">class</strong>.getName()));
1259 <a class="jxr_linenumber" name="L1251" href="#L1251">1251</a> <strong class="jxr_keyword">if</strong> (db.getAnnotationIndex().containsKey(Embeddable.<strong class="jxr_keyword">class</strong>.getName()))
1260 <a class="jxr_linenumber" name="L1252" href="#L1252">1252</a> classes.addAll(db.getAnnotationIndex().get(Embeddable.<strong class="jxr_keyword">class</strong>.getName()));
1261 <a class="jxr_linenumber" name="L1253" href="#L1253">1253</a>
1262 <a class="jxr_linenumber" name="L1254" href="#L1254">1254</a> <strong class="jxr_keyword">return</strong> classes;
1263 <a class="jxr_linenumber" name="L1255" href="#L1255">1255</a> }
1264 <a class="jxr_linenumber" name="L1256" href="#L1256">1256</a> <strong class="jxr_keyword">catch</strong> (Exception e)
1265 <a class="jxr_linenumber" name="L1257" href="#L1257">1257</a> {
1266 <a class="jxr_linenumber" name="L1258" href="#L1258">1258</a> getLog().error(<span class="jxr_string">"Error while scanning!"</span>, e);
1267 <a class="jxr_linenumber" name="L1259" href="#L1259">1259</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(e.getMessage());
1268 <a class="jxr_linenumber" name="L1260" href="#L1260">1260</a> }
1269 <a class="jxr_linenumber" name="L1261" href="#L1261">1261</a> }
1270 <a class="jxr_linenumber" name="L1262" href="#L1262">1262</a>
1271 <a class="jxr_linenumber" name="L1263" href="#L1263">1263</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> addAnnotated(
1272 <a class="jxr_linenumber" name="L1264" href="#L1264">1264</a> String name,
1273 <a class="jxr_linenumber" name="L1265" href="#L1265">1265</a> MetadataSources sources,
1274 <a class="jxr_linenumber" name="L1266" href="#L1266">1266</a> ClassLoaderService classLoaderService,
1275 <a class="jxr_linenumber" name="L1267" href="#L1267">1267</a> <a href="../../../../de/juplo/plugins/hibernate/ModificationTracker.html">ModificationTracker</a> tracker
1276 <a class="jxr_linenumber" name="L1268" href="#L1268">1268</a> )
1277 <a class="jxr_linenumber" name="L1269" href="#L1269">1269</a> <strong class="jxr_keyword">throws</strong>
1278 <a class="jxr_linenumber" name="L1270" href="#L1270">1270</a> MojoFailureException,
1279 <a class="jxr_linenumber" name="L1271" href="#L1271">1271</a> MojoExecutionException
1280 <a class="jxr_linenumber" name="L1272" href="#L1272">1272</a> {
1281 <a class="jxr_linenumber" name="L1273" href="#L1273">1273</a> <strong class="jxr_keyword">try</strong>
1282 <a class="jxr_linenumber" name="L1274" href="#L1274">1274</a> {
1283 <a class="jxr_linenumber" name="L1275" href="#L1275">1275</a> getLog().info(<span class="jxr_string">"Adding annotated resource: "</span> + name);
1284 <a class="jxr_linenumber" name="L1276" href="#L1276">1276</a> String packageName = <strong class="jxr_keyword">null</strong>;
1285 <a class="jxr_linenumber" name="L1277" href="#L1277">1277</a>
1286 <a class="jxr_linenumber" name="L1278" href="#L1278">1278</a> <strong class="jxr_keyword">boolean</strong> error = false;
1287 <a class="jxr_linenumber" name="L1279" href="#L1279">1279</a> <strong class="jxr_keyword">try</strong>
1288 <a class="jxr_linenumber" name="L1280" href="#L1280">1280</a> {
1289 <a class="jxr_linenumber" name="L1281" href="#L1281">1281</a> Class<?> annotatedClass = classLoaderService.classForName(name);
1290 <a class="jxr_linenumber" name="L1282" href="#L1282">1282</a> String resourceName = annotatedClass.getName();
1291 <a class="jxr_linenumber" name="L1283" href="#L1283">1283</a> resourceName =
1292 <a class="jxr_linenumber" name="L1284" href="#L1284">1284</a> resourceName.substring(
1293 <a class="jxr_linenumber" name="L1285" href="#L1285">1285</a> resourceName.lastIndexOf(<span class="jxr_string">"."</span>) + 1,
1294 <a class="jxr_linenumber" name="L1286" href="#L1286">1286</a> resourceName.length()
1295 <a class="jxr_linenumber" name="L1287" href="#L1287">1287</a> ) + <span class="jxr_string">".class"</span>;
1296 <a class="jxr_linenumber" name="L1288" href="#L1288">1288</a> InputStream is = annotatedClass.getResourceAsStream(resourceName);
1297 <a class="jxr_linenumber" name="L1289" href="#L1289">1289</a> <strong class="jxr_keyword">if</strong> (is != <strong class="jxr_keyword">null</strong>)
1298 <a class="jxr_linenumber" name="L1290" href="#L1290">1290</a> {
1299 <a class="jxr_linenumber" name="L1291" href="#L1291">1291</a> <strong class="jxr_keyword">if</strong> (tracker.track(name, is))
1300 <a class="jxr_linenumber" name="L1292" href="#L1292">1292</a> getLog().debug(<span class="jxr_string">"New or modified class: "</span> + name);
1301 <a class="jxr_linenumber" name="L1293" href="#L1293">1293</a> <strong class="jxr_keyword">else</strong>
1302 <a class="jxr_linenumber" name="L1294" href="#L1294">1294</a> getLog().debug(<span class="jxr_string">"Unchanged class: "</span> + name);
1303 <a class="jxr_linenumber" name="L1295" href="#L1295">1295</a> sources.addAnnotatedClass(annotatedClass);
1304 <a class="jxr_linenumber" name="L1296" href="#L1296">1296</a> packageName = annotatedClass.getPackage().getName();
1305 <a class="jxr_linenumber" name="L1297" href="#L1297">1297</a> }
1306 <a class="jxr_linenumber" name="L1298" href="#L1298">1298</a> <strong class="jxr_keyword">else</strong>
1307 <a class="jxr_linenumber" name="L1299" href="#L1299">1299</a> {
1308 <a class="jxr_linenumber" name="L1300" href="#L1300">1300</a> getLog().error(<span class="jxr_string">"cannot find ressource "</span> + resourceName + <span class="jxr_string">" for class "</span> + name);
1309 <a class="jxr_linenumber" name="L1301" href="#L1301">1301</a> error = <strong class="jxr_keyword">true</strong>;
1310 <a class="jxr_linenumber" name="L1302" href="#L1302">1302</a> }
1311 <a class="jxr_linenumber" name="L1303" href="#L1303">1303</a> }
1312 <a class="jxr_linenumber" name="L1304" href="#L1304">1304</a> <strong class="jxr_keyword">catch</strong>(ClassLoadingException e)
1313 <a class="jxr_linenumber" name="L1305" href="#L1305">1305</a> {
1314 <a class="jxr_linenumber" name="L1306" href="#L1306">1306</a> packageName = name;
1315 <a class="jxr_linenumber" name="L1307" href="#L1307">1307</a> }
1316 <a class="jxr_linenumber" name="L1308" href="#L1308">1308</a> <strong class="jxr_keyword">if</strong> (error)
1317 <a class="jxr_linenumber" name="L1309" href="#L1309">1309</a> {
1318 <a class="jxr_linenumber" name="L1310" href="#L1310">1310</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(<span class="jxr_string">"error while inspecting annotated class "</span> + name);
1319 <a class="jxr_linenumber" name="L1311" href="#L1311">1311</a> }
1320 <a class="jxr_linenumber" name="L1312" href="#L1312">1312</a>
1321 <a class="jxr_linenumber" name="L1313" href="#L1313">1313</a> <strong class="jxr_keyword">while</strong> (packageName != <strong class="jxr_keyword">null</strong>)
1322 <a class="jxr_linenumber" name="L1314" href="#L1314">1314</a> {
1323 <a class="jxr_linenumber" name="L1315" href="#L1315">1315</a> <strong class="jxr_keyword">if</strong> (packages.contains(packageName))
1324 <a class="jxr_linenumber" name="L1316" href="#L1316">1316</a> <strong class="jxr_keyword">return</strong>;
1325 <a class="jxr_linenumber" name="L1317" href="#L1317">1317</a> String resource = packageName.replace('.', '/') + <span class="jxr_string">"/package-info.class"</span>;
1326 <a class="jxr_linenumber" name="L1318" href="#L1318">1318</a> InputStream is = classLoaderService.locateResourceStream(resource);
1327 <a class="jxr_linenumber" name="L1319" href="#L1319">1319</a> <strong class="jxr_keyword">if</strong> (is == <strong class="jxr_keyword">null</strong>)
1328 <a class="jxr_linenumber" name="L1320" href="#L1320">1320</a> {
1329 <a class="jxr_linenumber" name="L1321" href="#L1321">1321</a> <em class="jxr_comment">// No compiled package-info available: no package-level annotations!</em>
1330 <a class="jxr_linenumber" name="L1322" href="#L1322">1322</a> getLog().debug(<span class="jxr_string">"Package "</span> + packageName + <span class="jxr_string">" is not annotated."</span>);
1331 <a class="jxr_linenumber" name="L1323" href="#L1323">1323</a> }
1332 <a class="jxr_linenumber" name="L1324" href="#L1324">1324</a> <strong class="jxr_keyword">else</strong>
1333 <a class="jxr_linenumber" name="L1325" href="#L1325">1325</a> {
1334 <a class="jxr_linenumber" name="L1326" href="#L1326">1326</a> <strong class="jxr_keyword">if</strong> (tracker.track(packageName, is))
1335 <a class="jxr_linenumber" name="L1327" href="#L1327">1327</a> getLog().debug(<span class="jxr_string">"New or modified package: "</span> + packageName);
1336 <a class="jxr_linenumber" name="L1328" href="#L1328">1328</a> <strong class="jxr_keyword">else</strong>
1337 <a class="jxr_linenumber" name="L1329" href="#L1329">1329</a> getLog().debug(<span class="jxr_string">"Unchanged package: "</span> + packageName);
1338 <a class="jxr_linenumber" name="L1330" href="#L1330">1330</a> getLog().info(<span class="jxr_string">"Adding annotations from package "</span> + packageName);
1339 <a class="jxr_linenumber" name="L1331" href="#L1331">1331</a> sources.addPackage(packageName);
1340 <a class="jxr_linenumber" name="L1332" href="#L1332">1332</a> }
1341 <a class="jxr_linenumber" name="L1333" href="#L1333">1333</a> packages.add(packageName);
1342 <a class="jxr_linenumber" name="L1334" href="#L1334">1334</a> <strong class="jxr_keyword">int</strong> i = packageName.lastIndexOf('.');
1343 <a class="jxr_linenumber" name="L1335" href="#L1335">1335</a> <strong class="jxr_keyword">if</strong> (i < 0)
1344 <a class="jxr_linenumber" name="L1336" href="#L1336">1336</a> packageName = <strong class="jxr_keyword">null</strong>;
1345 <a class="jxr_linenumber" name="L1337" href="#L1337">1337</a> <strong class="jxr_keyword">else</strong>
1346 <a class="jxr_linenumber" name="L1338" href="#L1338">1338</a> packageName = packageName.substring(0,i);
1347 <a class="jxr_linenumber" name="L1339" href="#L1339">1339</a> }
1348 <a class="jxr_linenumber" name="L1340" href="#L1340">1340</a> }
1349 <a class="jxr_linenumber" name="L1341" href="#L1341">1341</a> <strong class="jxr_keyword">catch</strong> (Exception e)
1350 <a class="jxr_linenumber" name="L1342" href="#L1342">1342</a> {
1351 <a class="jxr_linenumber" name="L1343" href="#L1343">1343</a> getLog().error(<span class="jxr_string">"Error while adding the annotated class "</span> + name, e);
1352 <a class="jxr_linenumber" name="L1344" href="#L1344">1344</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(e.getMessage());
1353 <a class="jxr_linenumber" name="L1345" href="#L1345">1345</a> }
1354 <a class="jxr_linenumber" name="L1346" href="#L1346">1346</a> }
1355 <a class="jxr_linenumber" name="L1347" href="#L1347">1347</a>
1356 <a class="jxr_linenumber" name="L1348" href="#L1348">1348</a> <strong class="jxr_keyword">private</strong> ParsedPersistenceXmlDescriptor loadPersistenceUnit(
1357 <a class="jxr_linenumber" name="L1349" href="#L1349">1349</a> ClassLoaderService classLoaderService,
1358 <a class="jxr_linenumber" name="L1350" href="#L1350">1350</a> Properties properties
1359 <a class="jxr_linenumber" name="L1351" href="#L1351">1351</a> )
1360 <a class="jxr_linenumber" name="L1352" href="#L1352">1352</a> <strong class="jxr_keyword">throws</strong>
1361 <a class="jxr_linenumber" name="L1353" href="#L1353">1353</a> MojoFailureException
1362 <a class="jxr_linenumber" name="L1354" href="#L1354">1354</a> {
1363 <a class="jxr_linenumber" name="L1355" href="#L1355">1355</a> PersistenceXmlParser parser =
1364 <a class="jxr_linenumber" name="L1356" href="#L1356">1356</a> <strong class="jxr_keyword">new</strong> PersistenceXmlParser(
1365 <a class="jxr_linenumber" name="L1357" href="#L1357">1357</a> classLoaderService,
1366 <a class="jxr_linenumber" name="L1358" href="#L1358">1358</a> PersistenceUnitTransactionType.RESOURCE_LOCAL
1367 <a class="jxr_linenumber" name="L1359" href="#L1359">1359</a> );
1368 <a class="jxr_linenumber" name="L1360" href="#L1360">1360</a>
1369 <a class="jxr_linenumber" name="L1361" href="#L1361">1361</a> Map<String, ParsedPersistenceXmlDescriptor> units =
1370 <a class="jxr_linenumber" name="L1362" href="#L1362">1362</a> parser.doResolve(properties);
1371 <a class="jxr_linenumber" name="L1363" href="#L1363">1363</a>
1372 <a class="jxr_linenumber" name="L1364" href="#L1364">1364</a> <strong class="jxr_keyword">if</strong> (persistenceUnit == <strong class="jxr_keyword">null</strong>)
1373 <a class="jxr_linenumber" name="L1365" href="#L1365">1365</a> {
1374 <a class="jxr_linenumber" name="L1366" href="#L1366">1366</a> Iterator<String> names = units.keySet().iterator();
1375 <a class="jxr_linenumber" name="L1367" href="#L1367">1367</a> <strong class="jxr_keyword">if</strong> (!names.hasNext())
1376 <a class="jxr_linenumber" name="L1368" href="#L1368">1368</a> {
1377 <a class="jxr_linenumber" name="L1369" href="#L1369">1369</a> getLog().info(<span class="jxr_string">"Found no META-INF/persistence.xml."</span>);
1378 <a class="jxr_linenumber" name="L1370" href="#L1370">1370</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
1379 <a class="jxr_linenumber" name="L1371" href="#L1371">1371</a> }
1380 <a class="jxr_linenumber" name="L1372" href="#L1372">1372</a>
1381 <a class="jxr_linenumber" name="L1373" href="#L1373">1373</a> String name = names.next();
1382 <a class="jxr_linenumber" name="L1374" href="#L1374">1374</a> <strong class="jxr_keyword">if</strong> (!names.hasNext())
1383 <a class="jxr_linenumber" name="L1375" href="#L1375">1375</a> {
1384 <a class="jxr_linenumber" name="L1376" href="#L1376">1376</a> getLog().info(<span class="jxr_string">"Using persistence-unit "</span> + name);
1385 <a class="jxr_linenumber" name="L1377" href="#L1377">1377</a> <strong class="jxr_keyword">return</strong> units.get(name);
1386 <a class="jxr_linenumber" name="L1378" href="#L1378">1378</a> }
1387 <a class="jxr_linenumber" name="L1379" href="#L1379">1379</a>
1388 <a class="jxr_linenumber" name="L1380" href="#L1380">1380</a> StringBuilder builder = <strong class="jxr_keyword">new</strong> StringBuilder();
1389 <a class="jxr_linenumber" name="L1381" href="#L1381">1381</a> builder.append(<span class="jxr_string">"No name provided and multiple persistence units found: "</span>);
1390 <a class="jxr_linenumber" name="L1382" href="#L1382">1382</a> builder.append(name);
1391 <a class="jxr_linenumber" name="L1383" href="#L1383">1383</a> <strong class="jxr_keyword">while</strong>(names.hasNext())
1392 <a class="jxr_linenumber" name="L1384" href="#L1384">1384</a> {
1393 <a class="jxr_linenumber" name="L1385" href="#L1385">1385</a> builder.append(<span class="jxr_string">", "</span>);
1394 <a class="jxr_linenumber" name="L1386" href="#L1386">1386</a> builder.append(names.next());
1395 <a class="jxr_linenumber" name="L1387" href="#L1387">1387</a> }
1396 <a class="jxr_linenumber" name="L1388" href="#L1388">1388</a> builder.append('.');
1397 <a class="jxr_linenumber" name="L1389" href="#L1389">1389</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(builder.toString());
1398 <a class="jxr_linenumber" name="L1390" href="#L1390">1390</a> }
1399 <a class="jxr_linenumber" name="L1391" href="#L1391">1391</a>
1400 <a class="jxr_linenumber" name="L1392" href="#L1392">1392</a> <strong class="jxr_keyword">if</strong> (units.containsKey(persistenceUnit))
1401 <a class="jxr_linenumber" name="L1393" href="#L1393">1393</a> {
1402 <a class="jxr_linenumber" name="L1394" href="#L1394">1394</a> getLog().info(<span class="jxr_string">"Using configured persistence-unit "</span> + persistenceUnit);
1403 <a class="jxr_linenumber" name="L1395" href="#L1395">1395</a> <strong class="jxr_keyword">return</strong> units.get(persistenceUnit);
1404 <a class="jxr_linenumber" name="L1396" href="#L1396">1396</a> }
1405 <a class="jxr_linenumber" name="L1397" href="#L1397">1397</a>
1406 <a class="jxr_linenumber" name="L1398" href="#L1398">1398</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"Could not find persistence-unit "</span> + persistenceUnit);
1407 <a class="jxr_linenumber" name="L1399" href="#L1399">1399</a> }
1408 <a class="jxr_linenumber" name="L1400" href="#L1400">1400</a>
1409 <a class="jxr_linenumber" name="L1401" href="#L1401">1401</a>
1410 <a class="jxr_linenumber" name="L1402" href="#L1402">1402</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> printStrackTrace(StringBuilder builder, Throwable t)
1411 <a class="jxr_linenumber" name="L1403" href="#L1403">1403</a> {
1412 <a class="jxr_linenumber" name="L1404" href="#L1404">1404</a> <strong class="jxr_keyword">while</strong> (t != <strong class="jxr_keyword">null</strong>)
1413 <a class="jxr_linenumber" name="L1405" href="#L1405">1405</a> {
1414 <a class="jxr_linenumber" name="L1406" href="#L1406">1406</a> builder.append(<span class="jxr_string">"\n\tCause: "</span>);
1415 <a class="jxr_linenumber" name="L1407" href="#L1407">1407</a> builder.append(t.getMessage() == <strong class="jxr_keyword">null</strong> ? <span class="jxr_string">""</span> : t.getMessage().replaceAll(<span class="jxr_string">"\\s+"</span>, <span class="jxr_string">" "</span>));
1416 <a class="jxr_linenumber" name="L1408" href="#L1408">1408</a> <strong class="jxr_keyword">for</strong> (StackTraceElement trace : t.getStackTrace())
1417 <a class="jxr_linenumber" name="L1409" href="#L1409">1409</a> {
1418 <a class="jxr_linenumber" name="L1410" href="#L1410">1410</a> builder.append(<span class="jxr_string">"\n\t"</span>);
1419 <a class="jxr_linenumber" name="L1411" href="#L1411">1411</a> builder.append(trace.getClassName());
1420 <a class="jxr_linenumber" name="L1412" href="#L1412">1412</a> builder.append(<span class="jxr_string">"."</span>);
1421 <a class="jxr_linenumber" name="L1413" href="#L1413">1413</a> builder.append(trace.getMethodName());
1422 <a class="jxr_linenumber" name="L1414" href="#L1414">1414</a> builder.append(<span class="jxr_string">"():"</span>);
1423 <a class="jxr_linenumber" name="L1415" href="#L1415">1415</a> builder.append(trace.getLineNumber());
1424 <a class="jxr_linenumber" name="L1416" href="#L1416">1416</a> }
1425 <a class="jxr_linenumber" name="L1417" href="#L1417">1417</a> t = t.getCause();
1426 <a class="jxr_linenumber" name="L1418" href="#L1418">1418</a> }
1427 <a class="jxr_linenumber" name="L1419" href="#L1419">1419</a> }
1428 <a class="jxr_linenumber" name="L1420" href="#L1420">1420</a> }
1431 <div id="footer">Copyright © 2017. All rights reserved.</div>