You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2017/02/01 14:46:53 UTC
[06/10] cayenne git commit: CAY-2215 rename "plugins" folder and
"cayenne-plugins-parent" module New names are "maven-plugins" and
"cayenne-maven-plugins-parent"
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterOldMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterOldMojo.java b/maven-plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterOldMojo.java
new file mode 100644
index 0000000..0bded58
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterOldMojo.java
@@ -0,0 +1,50 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Maven Mojo to import data model from DB into DataMap.
+ *
+ * @deprecated use "cayenne-maven-plugin"
+ * @since 4.0
+ */
+@Mojo(name = "cdbimport", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class DbImporterOldMojo extends DbImporterMojo {
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().warn("Plugin \"maven-cayenne-plugin\" has been deprecated.\n" +
+ "Please use \"cayenne-maven-plugin\":\n" +
+ "<plugin>\n" +
+ " <groupId>org.apache.cayenne.plugins</groupId>\n" +
+ " <artifactId>cayenne-maven-plugin</artifactId>\n" +
+ " <version>LATEST</version>\n" +
+ "</plugin>\n");
+
+ super.execute();
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/maven-plugins/maven-cayenne-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
new file mode 100644
index 0000000..e5de2d0
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
@@ -0,0 +1,32 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+-->
+<lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <goals>
+ <goal>cgen</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <execute>
+ <runOnIncremental>true</runOnIncremental>
+ <runOnConfiguration>true</runOnConfiguration>
+ </execute>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+</lifecycleMappingMetadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorOldMojoTest.java
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorOldMojoTest.java b/maven-plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorOldMojoTest.java
new file mode 100644
index 0000000..e91bc49
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorOldMojoTest.java
@@ -0,0 +1,77 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+package org.apache.cayenne.tools;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+
+import java.io.File;
+
+public class CayenneGeneratorOldMojoTest extends AbstractMojoTestCase {
+
+ public void testCgenExecution() throws Exception {
+
+ File pom = getTestFile("src/test/resources/cgen/project-to-test/pom.xml");
+ assertNotNull(pom);
+ assertTrue(pom.exists());
+
+ CayenneGeneratorMojo myMojo = (CayenneGeneratorMojo) lookupMojo("cgen", pom);
+ assertNotNull(myMojo);
+ myMojo.execute();
+
+ File superTestEntity = new File(
+ "target/cayenneGeneratedClasses/superPkg/_TestEntity.txt");
+ File testEntity = new File(
+ "target/cayenneGeneratedClasses/pack/TestEntity.txt");
+
+ File superEmbeddable = new File(
+ "target/cayenneGeneratedClasses/superPkg/_Embeddable.txt");
+ File embeddable = new File(
+ "target/cayenneGeneratedClasses/pack/Embeddable.txt");
+
+ File superNotIncludedEntity = new File(
+ "target/cayenneGeneratedClasses/pack/_NotIncludedEntity.txt");
+
+ File notIncludedEntity = new File(
+ "target/cayenneGeneratedClasses/pack/NotIncludedEntity.txt");
+
+ File superExcludedEntity = new File(
+ "target/cayenneGeneratedClasses/pack/_TestExcludedEntity.txt");
+ File excludedEntity = new File(
+ "target/cayenneGeneratedClasses/pack/TestExcludedEntity.txt");
+
+ assertTrue(superTestEntity.exists());
+ assertTrue(testEntity.exists());
+
+ assertTrue(superEmbeddable.exists());
+ assertTrue(embeddable.exists());
+
+ assertFalse(superNotIncludedEntity.exists());
+ assertFalse(notIncludedEntity.exists());
+
+ assertFalse(superExcludedEntity.exists());
+ assertFalse(excludedEntity.exists());
+
+ String content = FileUtils.readFileToString(superTestEntity);
+ assertTrue(content.contains("public static final Property<List<TestRelEntity>> ADDITIONAL_REL = Property.create(\"additionalRel\", List.class);"));
+ assertTrue(content.contains("public void addToAdditionalRel(TestRelEntity obj)"));
+ assertTrue(content.contains("public void removeFromAdditionalRel(TestRelEntity obj)"));
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterOldMojoConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterOldMojoConfigurationTest.java b/maven-plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterOldMojoConfigurationTest.java
new file mode 100644
index 0000000..a14a6b3
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterOldMojoConfigurationTest.java
@@ -0,0 +1,109 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeSet;
+import java.util.regex.Pattern;
+
+import org.apache.cayenne.dbsync.reverse.dbimport.Catalog;
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
+import org.apache.cayenne.dbsync.reverse.dbimport.Schema;
+import org.apache.cayenne.dbsync.reverse.filters.FiltersConfig;
+import org.apache.cayenne.dbsync.reverse.filters.IncludeTableFilter;
+import org.apache.cayenne.dbsync.reverse.filters.PatternFilter;
+import org.apache.cayenne.dbsync.reverse.filters.TableFilter;
+import org.apache.commons.logging.Log;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+
+import static org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineeringUtils.*;
+import static org.mockito.Mockito.mock;
+
+public class DbImporterOldMojoConfigurationTest extends AbstractMojoTestCase {
+
+ public void testLoadCatalog() throws Exception {
+ Map<String, Catalog> catalogs = new HashMap<>();
+ for (Catalog c : getCdbImport("pom-catalog.xml").getReverseEngineering().getCatalogs()) {
+ catalogs.put(c.getName(), c);
+ }
+
+ assertEquals(3, catalogs.size());
+ Catalog c3 = catalogs.get("catalog-name-03");
+ assertNotNull(c3);
+ assertCatalog(c3);
+ }
+
+ public void testLoadSchema() throws Exception {
+ Map<String, Schema> schemas = new HashMap<>();
+ for (Schema s : getCdbImport("pom-schema.xml").getReverseEngineering().getSchemas()) {
+ schemas.put(s.getName(), s);
+ }
+
+ assertEquals(3, schemas.size());
+ Schema s3 = schemas.get("schema-name-03");
+ assertNotNull(s3);
+ assertSchemaContent(s3);
+ }
+
+ public void testLoadSchema2() throws Exception {
+ FiltersConfig filters = getCdbImport("pom-schema-2.xml").createConfig(mock(Log.class))
+ .getDbLoaderConfig().getFiltersConfig();
+
+ TreeSet<IncludeTableFilter> includes = new TreeSet<>();
+ includes.add(new IncludeTableFilter(null, new PatternFilter().exclude("^ETL_.*")));
+
+ TreeSet<Pattern> excludes = new TreeSet<>(PatternFilter.PATTERN_COMPARATOR);
+ excludes.add(PatternFilter.pattern("^ETL_.*"));
+
+ assertEquals(filters.tableFilter(null, "NHL_STATS"),
+ new TableFilter(includes, excludes));
+ }
+
+ public void testLoadCatalogAndSchema() throws Exception {
+ assertCatalogAndSchema(getCdbImport("pom-catalog-and-schema.xml").getReverseEngineering());
+ }
+
+ public void testDefaultPackage() throws Exception {
+ DbImportConfiguration config = getCdbImport("pom-default-package.xml").createConfig(mock(Log.class));
+ assertEquals("com.example.test", config.getDefaultPackage());
+ }
+
+ public void testLoadFlat() throws Exception {
+ assertFlat(getCdbImport("pom-flat.xml").getReverseEngineering());
+ }
+
+ public void testSkipRelationshipsLoading() throws Exception {
+ assertSkipRelationshipsLoading(getCdbImport("pom-skip-relationships-loading.xml").getReverseEngineering());
+ }
+
+ public void testSkipPrimaryKeyLoading() throws Exception {
+ assertSkipPrimaryKeyLoading(getCdbImport("pom-skip-primary-key-loading.xml").getReverseEngineering());
+ }
+
+ public void testTableTypes() throws Exception {
+ assertTableTypes(getCdbImport("pom-table-types.xml").getReverseEngineering());
+ }
+
+ private DbImporterMojo getCdbImport(String pomFileName) throws Exception {
+ return (DbImporterMojo) lookupMojo("cdbimport",
+ getTestFile("src/test/resources/cdbimport/" + pomFileName));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-01.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-01.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-01.xml
new file mode 100644
index 0000000..a4a6955
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-01.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <name>DbImporterMojo Test1</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+ <dbimport>
+ <catalog>catalog-name-01</catalog>
+
+ <catalog>
+ <name>catalog-name-02</name>
+
+ <schema>schema-name-01</schema>
+
+ <schema>
+ <name>schema-name-02</name>
+
+ <includeTable>incTable-01</includeTable>
+ <excludeTable>excTable-01</excludeTable>
+
+ <includeTable>
+ <pattern>incTable-02</pattern>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ </includeTable>
+
+ <includeColumn>includeColumn-02</includeColumn>
+ <excludeColumn>excludeColumn-02</excludeColumn>
+ </schema>
+
+ <includeColumn>includeColumn-03</includeColumn>
+ <excludeColumn>excludeColumn-03</excludeColumn>
+ </catalog>
+
+ <schema>schema-name-03</schema>
+
+ <schema>
+ <name>schema-name-04</name>
+
+ <includeTable>incTable-04</includeTable>
+ <excludeTable>excTable-04</excludeTable>
+
+ <includeTable>
+ <pattern>incTable-05</pattern>
+
+ <includeColumn>includeColumn-04</includeColumn>
+ <excludeColumn>excludeColumn-04</excludeColumn>
+ </includeTable>
+
+ <includeColumn>includeColumn-04</includeColumn>
+ <excludeColumn>excludeColumn-04</excludeColumn>
+ </schema>
+
+ <includeTable>incTable-06</includeTable>
+ <excludeTable>excTable-06</excludeTable>
+
+ <includeTable>
+ <pattern>incTable-07</pattern>
+
+ <includeColumn>includeColumn-06</includeColumn>
+ <excludeColumn>excludeColumn-06</excludeColumn>
+ </includeTable>
+
+ <includeColumn>includeColumn-05</includeColumn>
+ <excludeColumn>excludeColumn-05</excludeColumn>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-catalog-and-schema.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-catalog-and-schema.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-catalog-and-schema.xml
new file mode 100644
index 0000000..d3828ce
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-catalog-and-schema.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+ <dbimport>
+ <catalog>
+ <name>catalog-name</name>
+ <schema>
+ <name>schema-name</name>
+ <includeTable>includeTable-01</includeTable>
+
+ <includeTable>
+ <pattern>includeTable-02</pattern>
+ </includeTable>
+
+ <includeTable>
+ <pattern>includeTable-03</pattern>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ </includeTable>
+
+ <excludeTable>excludeTable-01</excludeTable>
+ <excludeTable>
+ <pattern>excludeTable-02</pattern>
+ </excludeTable>
+ <excludeTable>excludeTable-03</excludeTable>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <includeColumn>
+ <pattern>includeColumn-02</pattern>
+ </includeColumn>
+ <includeColumn>includeColumn-03</includeColumn>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ <excludeColumn>
+ <pattern>excludeColumn-02</pattern>
+ </excludeColumn>
+ <excludeColumn>excludeColumn-03</excludeColumn>
+
+ <includeProcedure>includeProcedure-01</includeProcedure>
+ <includeProcedure>
+ <pattern>includeProcedure-02</pattern>
+ </includeProcedure>
+ <includeProcedure>includeProcedure-03</includeProcedure>
+ <excludeProcedure>excludeProcedure-01</excludeProcedure>
+ <excludeProcedure>
+ <pattern>excludeProcedure-02</pattern>
+ </excludeProcedure>
+ <excludeProcedure>excludeProcedure-03</excludeProcedure>
+ </schema>
+ </catalog>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-catalog.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-catalog.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-catalog.xml
new file mode 100644
index 0000000..9c919e8
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-catalog.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+ <dbimport>
+ <catalog>catalog-name-01</catalog>
+
+ <catalog>
+ <name>catalog-name-02</name>
+ </catalog>
+
+ <catalog>
+ <name>catalog-name-03</name>
+ <includeTable>includeTable-01</includeTable>
+
+ <includeTable>
+ <pattern>includeTable-02</pattern>
+ </includeTable>
+
+ <includeTable>
+ <pattern>includeTable-03</pattern>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ </includeTable>
+
+ <excludeTable>excludeTable-01</excludeTable>
+ <excludeTable>
+ <pattern>excludeTable-02</pattern>
+ </excludeTable>
+ <excludeTable>excludeTable-03</excludeTable>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <includeColumn>
+ <pattern>includeColumn-02</pattern>
+ </includeColumn>
+ <includeColumn>includeColumn-03</includeColumn>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ <excludeColumn>
+ <pattern>excludeColumn-02</pattern>
+ </excludeColumn>
+ <excludeColumn>excludeColumn-03</excludeColumn>
+
+ <includeProcedure>includeProcedure-01</includeProcedure>
+ <includeProcedure>
+ <pattern>includeProcedure-02</pattern>
+ </includeProcedure>
+ <includeProcedure>includeProcedure-03</includeProcedure>
+ <excludeProcedure>excludeProcedure-01</excludeProcedure>
+ <excludeProcedure>
+ <pattern>excludeProcedure-02</pattern>
+ </excludeProcedure>
+ <excludeProcedure>excludeProcedure-03</excludeProcedure>
+ </catalog>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-default-package.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-default-package.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-default-package.xml
new file mode 100644
index 0000000..7f09b88
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-default-package.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+ <dbimport>
+ <defaultPackage>com.example.test</defaultPackage>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-flat.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-flat.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-flat.xml
new file mode 100644
index 0000000..6987454
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-flat.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+ <dbimport>
+ <includeTable>includeTable-01</includeTable>
+
+ <includeTable>
+ <pattern>includeTable-02</pattern>
+ </includeTable>
+
+ <includeTable>
+ <pattern>includeTable-03</pattern>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ </includeTable>
+
+ <excludeTable>excludeTable-01</excludeTable>
+ <excludeTable>
+ <pattern>excludeTable-02</pattern>
+ </excludeTable>
+ <excludeTable>excludeTable-03</excludeTable>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <includeColumn>
+ <pattern>includeColumn-02</pattern>
+ </includeColumn>
+ <includeColumn>includeColumn-03</includeColumn>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ <excludeColumn>
+ <pattern>excludeColumn-02</pattern>
+ </excludeColumn>
+ <excludeColumn>excludeColumn-03</excludeColumn>
+
+ <includeProcedure>includeProcedure-01</includeProcedure>
+ <includeProcedure>
+ <pattern>includeProcedure-02</pattern>
+ </includeProcedure>
+ <includeProcedure>includeProcedure-03</includeProcedure>
+ <excludeProcedure>excludeProcedure-01</excludeProcedure>
+ <excludeProcedure>
+ <pattern>excludeProcedure-02</pattern>
+ </excludeProcedure>
+ <excludeProcedure>excludeProcedure-03</excludeProcedure>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-mapping.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-mapping.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-mapping.xml
new file mode 100644
index 0000000..10c99da
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-mapping.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+ <typeMapper >
+ <mapperClassName>class</mapperClassName>
+ <usePrimitives>false</usePrimitives>
+
+ <type>
+ <java>my.personal.type</java>
+ <jdbc>varchar</jdbc>
+ </type>
+ <type>
+ <java>java-01</java>
+ <jdbc>jdbc-01</jdbc>
+ </type>
+ <type>
+ <java>java-02</java>
+ <jdbc>jdbc-02</jdbc>
+ <length>21</length>
+ <notNull>true</notNull>
+ </type>
+ <type>
+ <java>java-03</java>
+ <jdbc>jdbc-03</jdbc>
+ <precision>5</precision>
+ <scale>2</scale>
+ </type>
+ <type>
+ <java>java-03</java>
+ <jdbc>jdbc-03</jdbc>
+ <precision>7</precision>
+ <notNull>true</notNull>
+ </type>
+ </typeMapper>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-schema-2.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-schema-2.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-schema-2.xml
new file mode 100644
index 0000000..05342fd
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-schema-2.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <dbimport>
+ <schema>
+ <name>NHL_STATS</name>
+ <excludeTable>^ETL_.*</excludeTable>
+ <excludeColumn>^ETL_.*</excludeColumn>
+ </schema>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-schema.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-schema.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-schema.xml
new file mode 100644
index 0000000..11804fc
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-schema.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+ <dbimport>
+ <schema>schema-name-01</schema>
+
+ <schema>
+ <name>schema-name-02</name>
+ </schema>
+
+ <schema>
+ <name>schema-name-03</name>
+ <includeTable>includeTable-01</includeTable>
+
+ <includeTable>
+ <pattern>includeTable-02</pattern>
+ </includeTable>
+
+ <includeTable>
+ <pattern>includeTable-03</pattern>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ </includeTable>
+
+ <excludeTable>excludeTable-01</excludeTable>
+ <excludeTable>
+ <pattern>excludeTable-02</pattern>
+ </excludeTable>
+ <excludeTable>excludeTable-03</excludeTable>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <includeColumn>
+ <pattern>includeColumn-02</pattern>
+ </includeColumn>
+ <includeColumn>includeColumn-03</includeColumn>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ <excludeColumn>
+ <pattern>excludeColumn-02</pattern>
+ </excludeColumn>
+ <excludeColumn>excludeColumn-03</excludeColumn>
+
+ <includeProcedure>includeProcedure-01</includeProcedure>
+ <includeProcedure>
+ <pattern>includeProcedure-02</pattern>
+ </includeProcedure>
+ <includeProcedure>includeProcedure-03</includeProcedure>
+ <excludeProcedure>excludeProcedure-01</excludeProcedure>
+ <excludeProcedure>
+ <pattern>excludeProcedure-02</pattern>
+ </excludeProcedure>
+ <excludeProcedure>excludeProcedure-03</excludeProcedure>
+ </schema>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-skip-primary-key-loading.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-skip-primary-key-loading.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-skip-primary-key-loading.xml
new file mode 100644
index 0000000..2c3e6c5
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-skip-primary-key-loading.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+ <dbimport>
+ <skipPrimaryKeyLoading>true</skipPrimaryKeyLoading>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-skip-relationships-loading.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-skip-relationships-loading.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-skip-relationships-loading.xml
new file mode 100644
index 0000000..9291871
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-skip-relationships-loading.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+ <dbimport>
+ <skipRelationshipsLoading>true</skipRelationshipsLoading>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-table-types.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-table-types.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-table-types.xml
new file mode 100644
index 0000000..b8d3ad3
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cdbimport/pom-table-types.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+ <dbimport>
+ <tableType>type1</tableType>
+ <tableType>type2</tableType>
+ <tableType>type3</tableType>
+ </dbimport>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/cayenne-testDomain.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/cayenne-testDomain.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/cayenne-testDomain.xml
new file mode 100644
index 0000000..3f63c14
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/cayenne-testDomain.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="6">
+ <map name="testDomainMap"/>
+ <map name="testAdditionalMap"/>
+</domain>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/pom.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/pom.xml
new file mode 100644
index 0000000..44db499
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/pom.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <name>Test CayenneGeneratorMojo</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-cayenne-plugin</artifactId>
+ <configuration>
+ <map>src/test/resources/cgen/testDomainMap.map.xml</map>
+ <destDir>target/cayenneGeneratedClasses</destDir>
+ <additionalMaps>src/test/resources/cgen/</additionalMaps>
+ <outputPattern>*.txt</outputPattern>
+ <makePairs>true</makePairs>
+ <usePkgPath>true</usePkgPath>
+ <superPkg>superPkg</superPkg>
+ <encoding>UTF-8</encoding>
+ <includeEntities>Test*</includeEntities>
+ <excludeEntities>TestExcludedEntity</excludeEntities>
+ <mode>all</mode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/testAdditionalMap.map.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/testAdditionalMap.map.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/testAdditionalMap.map.xml
new file mode 100644
index 0000000..f9a80fb
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/testAdditionalMap.map.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
+ project-version="6">
+ <property name="defaultPackage" value="pack"/>
+ <db-entity name="TestRelEntity">
+ <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+ <db-attribute name="NAME" type="VARCHAR" length="200"/>
+ </db-entity>
+ <obj-entity name="TestRelEntity" className="pack.TestRelEntity" dbEntityName="TestRelEntity">
+ <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+ </obj-entity>
+ <db-relationship name="additionalRel" source="TestRelEntity" target="TestEntity" toMany="false">
+ <db-attribute-pair source="ID" target="TestRelEntity_ID"/>
+ </db-relationship>
+ <obj-relationship name="additionalRel" source="TestRelEntity" target="TestEntity" deleteRule="Nullify" db-relationship-path="additionalRel"/>
+</data-map>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/testDomainMap.map.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/testDomainMap.map.xml b/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/testDomainMap.map.xml
new file mode 100644
index 0000000..d0ff3f5
--- /dev/null
+++ b/maven-plugins/maven-cayenne-plugin/src/test/resources/cgen/testDomainMap.map.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
+ project-version="6">
+ <property name="defaultPackage" value="pack"/>
+ <embeddable className="pack.Embeddable">
+ <embeddable-attribute name="embAttr" type="java.lang.String" db-attribute-name="EMB_ATTR"/>
+ </embeddable>
+ <db-entity name="NotIncludedEntity">
+ <db-attribute name="id" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
+ <db-attribute name="name" type="VARCHAR" length="255"/>
+ </db-entity>
+ <db-entity name="TestEntity">
+ <db-attribute name="id" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
+ <db-attribute name="testAttr" type="VARCHAR" length="255"/>
+ <db-attribute name="TestRelEntity_ID" type="INTEGER"/>
+ </db-entity>
+ <db-entity name="TestExcludedEntity">
+ <db-attribute name="id" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
+ <db-attribute name="name" type="VARCHAR" length="255"/>
+ </db-entity>
+ <obj-entity name="NotIncludedEntity" className="pack.NotIncludedEntity" dbEntityName="NotIncludedEntity">
+ <obj-attribute name="name" type="java.lang.String" db-attribute-path="name"/>
+ </obj-entity>
+ <obj-entity name="TestEntity" className="pack.TestEntity" dbEntityName="TestEntity">
+ <embedded-attribute name="embeddedAtr" type="pack.Embeddable"/>
+ <obj-attribute name="testAttr" type="java.lang.String" db-attribute-path="testAttr"/>
+ </obj-entity>
+ <obj-entity name="TestExcludedEntity" className="pack.TestExcludedEntity" dbEntityName="TestExcludedEntity">
+ <obj-attribute name="name" type="java.lang.String" db-attribute-path="name"/>
+ </obj-entity>
+ <db-relationship name="childrenRel" source="TestEntity" target="TestEntity" toMany="true">
+ <db-attribute-pair source="id" target="id"/>
+ </db-relationship>
+ <db-relationship name="parentRel" source="TestEntity" target="TestEntity" toMany="false">
+ <db-attribute-pair source="id" target="id"/>
+ </db-relationship>
+ <db-relationship name="additionalRel" source="TestEntity" target="TestRelEntity" toMany="true">
+ <db-attribute-pair source="TestRelEntity_ID" target="ID"/>
+ </db-relationship>
+ <obj-relationship name="childrenRel" source="TestEntity" target="TestEntity" deleteRule="Deny" db-relationship-path="childrenRel"/>
+ <obj-relationship name="parentRel" source="TestEntity" target="TestEntity" deleteRule="Nullify" db-relationship-path="parentRel"/>
+ <obj-relationship name="additionalRel" source="TestEntity" target="TestRelEntity" deleteRule="Deny" db-relationship-path="additionalRel"/>
+</data-map>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/maven-plugins/pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/pom.xml b/maven-plugins/pom.xml
new file mode 100644
index 0000000..813ef93
--- /dev/null
+++ b/maven-plugins/pom.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ you under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.cayenne</groupId>
+ <artifactId>cayenne-parent</artifactId>
+ <version>4.0.M5-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.cayenne.plugins</groupId>
+ <artifactId>cayenne-maven-plugins-parent</artifactId>
+ <name>cayenne-maven-plugins-parent: Maven Plugins parent</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>cayenne-maven-plugin</module>
+ <module>maven-cayenne-plugin</module>
+ <module>maven-cayenne-modeler-plugin</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>3.0-alpha-2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-api</artifactId>
+ <version>3.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-testing</groupId>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>3.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interpolation</artifactId>
+ <version>1.21</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <plugins>
+ <!-- This ensures LICENSE and NOTICE inclusion in all jars -->
+ <plugin>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <configuration>
+ <goalPrefix>signature</goalPrefix>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/plugins/cayenne-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/cayenne-maven-plugin/pom.xml b/plugins/cayenne-maven-plugin/pom.xml
deleted file mode 100644
index 9871994..0000000
--- a/plugins/cayenne-maven-plugin/pom.xml
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
- license agreements. See the NOTICE file distributed with this work for additional
- information regarding copyright ownership. The ASF licenses this file to
- you under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of
- the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
- by applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
- OF ANY KIND, either express or implied. See the License for the specific
- language governing permissions and limitations under the License. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <artifactId>cayenne-plugins-parent</artifactId>
- <groupId>org.apache.cayenne.plugins</groupId>
- <version>4.0.M5-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>cayenne-maven-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <name>cayenne-maven-plugin: Cayenne Maven Plugin</name>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-plugin-plugin</artifactId>
- <configuration>
- <goalPrefix>cayenne</goalPrefix>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-compat</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-interpolation</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cayenne</groupId>
- <artifactId>cayenne-cgen</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cayenne</groupId>
- <artifactId>cayenne-dbsync</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- Test deps -->
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.plugin-testing</groupId>
- <artifactId>maven-plugin-testing-harness</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cayenne</groupId>
- <artifactId>cayenne-dbsync</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cayenne.build-tools</groupId>
- <artifactId>cayenne-test-utilities</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
-
- <profiles>
- <profile>
- <id>code-quality</id>
-
- <activation>
- <property>
- <name>!fast-and-dirty</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <!--<configuration>
- <suppressionsLocation>${project.basedir}/cayenne-checkstyle-suppression.xml</suppressionsLocation>
- </configuration>-->
- </plugin>
- <plugin>
- <artifactId>maven-pmd-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
-
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java b/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
deleted file mode 100644
index 98e54e3..0000000
--- a/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
-import org.apache.cayenne.gen.ClassGenerationAction;
-import org.apache.cayenne.gen.ClientClassGenerationAction;
-import org.apache.cayenne.map.DataMap;
-import org.apache.commons.logging.Log;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-/**
- * Maven mojo to perform class generation from data map. This class is an Maven
- * adapter to DefaultClassGenerator class.
- *
- * @since 3.0
- */
-@Mojo(name = "cgen", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
-public class CayenneGeneratorMojo extends AbstractMojo {
-
- public static final File[] NO_FILES = new File[0];
-
- /**
- * Path to additional DataMap XML files to use for class generation.
- */
- @Parameter
- private File additionalMaps;
-
- /**
- * Whether we are generating classes for the client tier in a Remote Object
- * Persistence application. Default is <code>false</code>.
- */
- @Parameter(defaultValue = "false")
- private boolean client;
-
- /**
- * Destination directory for Java classes (ignoring their package names).
- */
- @Parameter(defaultValue = "${project.build.sourceDirectory}")
- private File destDir;
-
- /**
- * Specify generated file encoding if different from the default on current
- * platform. Target encoding must be supported by the JVM running Maven
- * build. Standard encodings supported by Java on all platforms are
- * US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, UTF-16. See Sun Java
- * Docs for java.nio.charset.Charset for more information.
- */
- @Parameter
- private String encoding;
-
- /**
- * Entities (expressed as a perl5 regex) to exclude from template
- * generation. (Default is to include all entities in the DataMap).
- */
- @Parameter
- private String excludeEntities;
-
- /**
- * Entities (expressed as a perl5 regex) to include in template generation.
- * (Default is to include all entities in the DataMap).
- */
- @Parameter
- private String includeEntities;
-
- /**
- * If set to <code>true</code>, will generate subclass/superclass pairs,
- * with all generated code included in superclass (default is
- * <code>true</code>).
- */
- @Parameter(defaultValue = "true")
- private boolean makePairs;
-
- /**
- * DataMap XML file to use as a base for class generation.
- */
- @Parameter(required = true)
- private File map;
-
- /**
- * Specifies generator iteration target. "entity" performs one
- * iteration for each selected entity. "datamap" performs one
- * iteration per datamap (This is always one iteration since cgen currently
- * supports specifying one-and-only-one datamap). (Default is "entity")
- */
- @Parameter(defaultValue = "entity")
- private String mode;
-
- /**
- * Name of file for generated output. (Default is "*.java")
- */
- @Parameter(defaultValue = "*.java")
- private String outputPattern;
-
- /**
- * If set to <code>true</code>, will overwrite older versions of generated
- * classes. Ignored unless makepairs is set to <code>false</code>.
- */
- @Parameter(defaultValue = "false")
- private boolean overwrite;
-
- /**
- * Java package name of generated superclasses. Ignored unless
- * <code>makepairs</code> set to <code>true</code>. If omitted, each
- * superclass will be assigned the same package as subclass. Note that
- * having superclass in a different package would only make sense when
- * <code>usepkgpath</code> is set to <code>true</code>. Otherwise classes
- * from different packages will end up in the same directory.
- */
- @Parameter
- private String superPkg;
-
- /**
- * Location of Velocity template file for Entity superclass generation.
- * Ignored unless <code>makepairs</code> set to <code>true</code>. If
- * omitted, default template is used.
- */
- @Parameter
- private String superTemplate;
-
- /**
- * Location of Velocity template file for Entity class generation. If
- * omitted, default template is used.
- */
- @Parameter
- private String template;
-
- /**
- * Location of Velocity template file for Embeddable superclass generation.
- * Ignored unless <code>makepairs</code> set to <code>true</code>. If
- * omitted, default template is used.
- */
- @Parameter
- private String embeddableSuperTemplate;
-
- /**
- * Location of Velocity template file for Embeddable class generation. If
- * omitted, default template is used.
- */
- @Parameter
- private String embeddableTemplate;
-
- /**
- * If set to <code>true</code> (default), a directory tree will be generated
- * in "destDir" corresponding to the class package structure, if set to
- * <code>false</code>, classes will be generated in "destDir"
- * ignoring their package.
- */
- @Parameter(defaultValue = "true")
- private boolean usePkgPath;
-
- /**
- * If set to <code>true</code>, will generate String Property names.
- * Default is <code>false</code>.
- */
- @Parameter(defaultValue = "false")
- private boolean createPropertyNames;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- // Create the destination directory if necessary.
- // TODO: (KJM 11/2/06) The destDir really should be added as a
- // compilation resource for maven.
- if (!destDir.exists()) {
- destDir.mkdirs();
- }
-
- Log logger = new MavenLogger(this);
- CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction();
- loaderAction.setMainDataMapFile(map);
-
- CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
- filterAction.setClient(client);
- filterAction.setNameFilter(NamePatternMatcher.build(logger, includeEntities, excludeEntities));
-
- try {
- loaderAction.setAdditionalDataMapFiles(convertAdditionalDataMaps());
-
- DataMap dataMap = loaderAction.getMainDataMap();
-
- ClassGenerationAction generator = createGenerator();
- generator.setLogger(logger);
- generator.setTimestamp(map.lastModified());
- generator.setDataMap(dataMap);
- generator.addEntities(filterAction.getFilteredEntities(dataMap));
- // ksenia khailenko 15.10.2010
- // TODO add the "includeEmbeddables" and "excludeEmbeddables"
- // attributes
- generator.addEmbeddables(dataMap.getEmbeddables());
- // TODO add the "includeQueries" and "excludeQueries" attributes
- generator.addQueries(dataMap.getQueryDescriptors());
- generator.execute();
- } catch (Exception e) {
- throw new MojoExecutionException("Error generating classes: ", e);
- }
- }
-
- /**
- * Loads and returns DataMap based on <code>map</code> attribute.
- */
- protected File[] convertAdditionalDataMaps() throws Exception {
-
- if (additionalMaps == null) {
- return NO_FILES;
- }
-
- if (!additionalMaps.isDirectory()) {
- throw new MojoFailureException(
- "'additionalMaps' must be a directory.");
- }
-
- FilenameFilter mapFilter = new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name != null &&
- name.toLowerCase().endsWith(".map.xml");
- }
- };
- return additionalMaps.listFiles(mapFilter);
- }
-
- /**
- * Factory method to create internal class generator. Called from
- * constructor.
- */
- protected ClassGenerationAction createGenerator() {
-
- ClassGenerationAction action;
- if (client) {
- action = new ClientClassGenerationAction();
- } else {
- action = new ClassGenerationAction();
- }
-
- action.setDestDir(destDir);
- action.setEncoding(encoding);
- action.setMakePairs(makePairs);
- action.setArtifactsGenerationMode(mode);
- action.setOutputPattern(outputPattern);
- action.setOverwrite(overwrite);
- action.setSuperPkg(superPkg);
- action.setSuperTemplate(superTemplate);
- action.setTemplate(template);
- action.setEmbeddableSuperTemplate(embeddableSuperTemplate);
- action.setEmbeddableTemplate(embeddableTemplate);
- action.setUsePkgPath(usePkgPath);
- action.setCreatePropertyNames(createPropertyNames);
-
- return action;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java b/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
deleted file mode 100644
index 0ef8a1c..0000000
--- a/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.access.DbGenerator;
-import org.apache.cayenne.datasource.DriverDataSource;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.dbsync.DbSyncModule;
-import org.apache.cayenne.di.AdhocObjectFactory;
-import org.apache.cayenne.di.DIBootstrap;
-import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.log.NoopJdbcEventLogger;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.MapLoader;
-import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
-import org.apache.cayenne.util.Util;
-import org.apache.commons.logging.Log;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.xml.sax.InputSource;
-
-import java.io.File;
-import java.sql.Driver;
-
-/**
- * Maven mojo to perform class generation from data map. This class is a Maven
- * adapter to DefaultClassGenerator class.
- *
- * @since 3.0
- */
-@Mojo(name = "cdbgen", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST)
-public class DbGeneratorMojo extends AbstractMojo {
-
- /**
- * DataMap XML file to use as a schema descriptor.
- */
- @Parameter(required = true)
- private File map;
-
- /**
- * Java class implementing org.apache.cayenne.dba.DbAdapter. While this
- * attribute is optional (a generic JdbcAdapter is used if not set), it is
- * highly recommended to specify correct target adapter.
- */
- @Parameter
- private String adapter;
-
- /**
- * A class of JDBC driver to use for the target database.
- */
- @Parameter(required = true)
- private String driver;
-
- /**
- * JDBC connection URL of a target database.
- */
- @Parameter(required = true)
- private String url;
-
- /**
- * Database user name.
- */
- @Parameter
- private String username;
-
- /**
- * Database user password.
- */
- @Parameter
- private String password;
-
- /**
- * Defines whether cdbgen should drop the tables before attempting to create
- * new ones. Default is <code>false</code>.
- */
- @Parameter(defaultValue = "false")
- private boolean dropTables;
-
- /**
- * Defines whether cdbgen should drop Cayenne primary key support objects.
- * Default is <code>false</code>.
- */
- @Parameter(defaultValue = "false")
- private boolean dropPK;
-
- /**
- * Defines whether cdbgen should create new tables. Default is
- * <code>true</code>.
- */
- @Parameter(defaultValue = "true")
- private boolean createTables;
-
- /**
- * Defines whether cdbgen should create Cayenne-specific auto PK objects.
- * Default is <code>true</code>.
- */
- @Parameter(defaultValue = "true")
- private boolean createPK;
-
- /**
- * Defines whether cdbgen should create foreign key copnstraints. Default is
- * <code>true</code>.
- */
- @Parameter(defaultValue = "true")
- private boolean createFK;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- Log logger = new MavenLogger(this);
- Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger));
- AdhocObjectFactory objectFactory = injector.getInstance(AdhocObjectFactory.class);
-
- logger.info(String.format("connection settings - [driver: %s, url: %s, username: %s]", driver, url, username));
-
- logger.info(String.format(
- "generator options - [dropTables: %s, dropPK: %s, createTables: %s, createPK: %s, createFK: %s]",
- dropTables, dropPK, createTables, createPK, createFK));
-
- try {
- final DbAdapter adapterInst = (adapter == null) ? (DbAdapter) objectFactory.newInstance(DbAdapter.class,
- JdbcAdapter.class.getName()) : (DbAdapter) objectFactory.newInstance(DbAdapter.class, adapter);
-
- // Load the data map and run the db generator.
- DataMap dataMap = loadDataMap();
- DbGenerator generator = new DbGenerator(adapterInst, dataMap, NoopJdbcEventLogger.getInstance());
- generator.setShouldCreateFKConstraints(createFK);
- generator.setShouldCreatePKSupport(createPK);
- generator.setShouldCreateTables(createTables);
- generator.setShouldDropPKSupport(dropPK);
- generator.setShouldDropTables(dropTables);
-
- // load driver taking custom CLASSPATH into account...
- DriverDataSource dataSource = new DriverDataSource((Driver) Class.forName(driver).newInstance(), url,
- username, password);
-
- generator.runGenerator(dataSource);
- } catch (Exception ex) {
- Throwable th = Util.unwindException(ex);
-
- String message = "Error generating database";
-
- if (th.getLocalizedMessage() != null) {
- message += ": " + th.getLocalizedMessage();
- }
-
- logger.error(message);
- throw new MojoExecutionException(message, th);
- }
- }
-
- /** Loads and returns DataMap based on <code>map</code> attribute. */
- protected DataMap loadDataMap() throws Exception {
- InputSource in = new InputSource(map.getCanonicalPath());
- return new MapLoader().loadDataMap(in);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/a0cd93d6/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbImportDataSourceConfig.java
----------------------------------------------------------------------
diff --git a/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbImportDataSourceConfig.java b/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbImportDataSourceConfig.java
deleted file mode 100644
index 8fa4b56..0000000
--- a/plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbImportDataSourceConfig.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-/**
- * @since 4.0
- */
-public class DbImportDataSourceConfig {
-
- /**
- * A class of JDBC driver to use for the target database.
- */
- private String driver;
-
- /**
- * JDBC connection URL of a target database.
- */
- private String url;
-
- /**
- * Database user name.
- */
- private String username;
-
- /**
- * Database user password.
- */
- private String password;
-
- public String getDriver() {
- return driver;
- }
-
- public String getUrl() {
- return url;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-}