From 18f492567d293c08cdd162ef6b69d415ac02e770 Mon Sep 17 00:00:00 2001 From: jensp Date: Sat, 17 Oct 2015 17:47:13 +0000 Subject: [PATCH] CCM NG: Maven Archetype for generating modules git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3694 8810af33-2d31-482b-a856-94f89814c4df --- ccm-archetype-module/pom.xml | 19 ++ .../META-INF/maven/archetype-metadata.xml | 38 +++ .../resources/archetype-resources/pom.xml | 316 ++++++++++++++++++ .../src/main/java/__moduleClassName__.java | 38 +++ .../services/org.libreccm.modules.CcmModule | 1 + .../test/java/__moduleClassName__Test.java | 104 ++++++ .../arquillian.xml | 36 ++ .../create___artifactName___schema.sql | 1 + .../test-persistence.xml | 40 +++ .../arquillian.xml | 36 ++ .../create___artifactName___schema.sql | 1 + .../test-persistence.xml | 41 +++ .../src/test/resources/scripts/h2-cleanup.sql | 1 + .../test/resources/scripts/pgsql-cleanup.sql | 1 + .../__groupId__.__artifactId__.properties | 4 + .../java/org/libreccm/modules/ModuleInfo.java | 2 +- ccm-shortcuts/pom.xml | 1 + pom.xml | 9 +- 18 files changed, 686 insertions(+), 3 deletions(-) create mode 100644 ccm-archetype-module/pom.xml create mode 100644 ccm-archetype-module/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/pom.xml create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/main/java/__moduleClassName__.java create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/test/java/__moduleClassName__Test.java create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/arquillian.xml create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/scripts/create___artifactName___schema.sql create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/test-persistence.xml create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/arquillian.xml create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/scripts/create___artifactName___schema.sql create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/test-persistence.xml create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources/scripts/h2-cleanup.sql create mode 100644 ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources/scripts/pgsql-cleanup.sql create mode 100644 ccm-archetype-module/src/main/resources/module-info/__groupId__.__artifactId__.properties diff --git a/ccm-archetype-module/pom.xml b/ccm-archetype-module/pom.xml new file mode 100644 index 000000000..b385ad119 --- /dev/null +++ b/ccm-archetype-module/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + + org.libreccm + libreccm-parent + 7.0.0-SNAPSHOT + + + org.libreccm + ccm-archetype-module + 7.0.0-SNAPSHOT + + LibreCCM Module archetype + http://www.libreccm.org/devel/modules + + diff --git a/ccm-archetype-module/src/main/resources/META-INF/maven/archetype-metadata.xml b/ccm-archetype-module/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 000000000..042522b74 --- /dev/null +++ b/ccm-archetype-module/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,38 @@ + + + + + ${artifactId} + + + + + + + + src/main/java + + + src/main/resources/db/migrations + + + src/main/resources/META-INF + + + src/main/resources/module-info + + + src/test/java + + + + diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/pom.xml b/ccm-archetype-module/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 000000000..d705b37d5 --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,316 @@ + + + 4.0.0 + + + UTF-8 + ${maven.build.timestamp} + yyyy-MM-dd'T'HH:mm:ss'Z'Z + + + ${groupId} + ${artifactId} + ${version} + + ${moduleName} + + + + javax + javaee-api + jar + provided + + + + org.libreccm + ccm-core + ${project.parent.version} + provided + + + + org.hibernate + hibernate-entitymanager + + + + org.hibernate + hibernate-validator + + + + junit + junit + test + + + + org.hamcrest + hamcrest-core + test + + + org.hamcrest + hamcrest-library + test + + + + org.libreccm + ccm-testutils + ${project.parent.version} + test + + + + nl.jqno.equalsverifier + equalsverifier + test + + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.arquillian.extension + arquillian-persistence-dbunit + test + + + org.jboss.arquillian.extension + arquillian-transaction-impl-base + test + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + test + + + + com.h2database + h2 + test + + + + + + ${artifactId} + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.7 + 1.7 + true + true + ${project.build.sourceEncoding} + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + org.libreccm.tests.categories.UnitTest + + + + + org.jacoco + jacoco-maven-plugin + 0.7.5.201505241946 + + + default-prepare-agent + + prepare-agent + + + + default-report + prepare-package + + report + + + + default-check + + check + + + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + 0.60 + + + + + + + + + + + de.jpdigital + hibernate4-ddl-maven-plugin + + + h2 + mysql5_innodb + oracle10g + postgresql9 + + + org.libreccm + + true + + + + + gen-ddl + + process-classes + + + + + + + + src/main/resources + true + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + true + true + + http://docs.oracle.com/javase/7/docs/api/ + http://docs.oracle.com/javaee/7/api/ + http://docs.jboss.org/hibernate/orm/4.3/javadocs/ + + private + true + UTF-8 + UTF-8 + UTF-8 + true + true + true + true + false + org.jboss.apiviz.APIviz + + org.jboss.apiviz + apiviz + 1.3.2.GA + + true + + -sourceclasspath ${project.build.outputDirectory} + + + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.5 + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.18.1 + + + org.jacoco + jacoco-maven-plugin + 0.7.5.201505241946 + + + org.codehaus.mojo + findbugs-maven-plugin + 3.0.1 + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.4 + + true + utf-8 + 1.7 + + /rulesets/java/basic.xml + /rulesets/java/braces.xml + /rulesets/java/clone.xml + /rulesets/java/codesize.xml + /rulesets/java/design.xml + /rulesets/java/empty.xml + /rulesets/java/finalizers.xml + /rulesets/java/imports.xml + /rulesets/java/javabeans.xml + /rulesets/java/junit.xml + /rulesets/java/naming.xml + /rulesets/java/optimizations.xml + /rulesets/java/strictexception.xml + /rulesets/java/strings.xml + /rulesets/java/sunsecure.xml + /rulesets/java/typeresolution.xml + /rulesets/java/unnecessary.xml + /rulesets/java/unusedcode.xml + + + + + org.codehaus.mojo + javancss-maven-plugin + 2.1 + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.8 + + + + dependencies + license + + + + + false + + + + + diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/main/java/__moduleClassName__.java b/ccm-archetype-module/src/main/resources/archetype-resources/src/main/java/__moduleClassName__.java new file mode 100644 index 000000000..9b18f229e --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/main/java/__moduleClassName__.java @@ -0,0 +1,38 @@ +/** + * Add your license here, for example LGPL + */ +package ${packageName} + +import org.libreccm.modules.CcmModule; +import org.libreccm.modules.InitEvent; +import org.libreccm.modules.InstallEvent; +import org.libreccm.modules.Module; +import org.libreccm.modules.ShutdownEvent; +import org.libreccm.modules.UnInstallEvent; + +@Module(moduleDataPackage=${packageName}, + requiredModules = {@RequiredModule = org.libreccm.core.CcmCore}) +public ${moduleClassName} implements CcmModule { + + @Override + public void install(final InstallEvent event) { + //ToDo Create initial data for the module if neccessary + } + + @Override + public void init(final InitEvent event) { + //ToDo Add initialisation logic necessary for your module + } + + @Override + public void shutdown(final ShutdownEvent event) { + //ToDo Add shutdown logic if necessary + } + + @Override + public void uninstall(final UnInstallEvent event) { + //ToDo Remove module data + } + + +} diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule b/ccm-archetype-module/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule new file mode 100644 index 000000000..fedd3f1fd --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule @@ -0,0 +1 @@ +${packageName}.${moduleClassName} diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/test/java/__moduleClassName__Test.java b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/java/__moduleClassName__Test.java new file mode 100644 index 000000000..09a4bd5dc --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/java/__moduleClassName__Test.java @@ -0,0 +1,104 @@ +/* + * ToDo: Add your license + */ +package ${packageName}; + +import static org.hamcrest.CoreMatchers.*; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.ShouldThrowException; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.junit.InSequence; +import org.jboss.arquillian.persistence.CreateSchema; +import org.jboss.arquillian.persistence.PersistenceTest; +import org.jboss.arquillian.persistence.ShouldMatchDataSet; +import org.jboss.arquillian.persistence.UsingDataSet; +import org.jboss.arquillian.transaction.api.annotation.TransactionMode; +import org.jboss.arquillian.transaction.api.annotation.Transactional; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.resolver.api.maven.Maven; +import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.libreccm.tests.categories.IntegrationTest; + +import java.io.File; +import java.util.List; + +import javax.inject.Inject; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +import static org.junit.Assert.*; + +@Category(IntegrationTest.class} +@RunWith(Arquillian.class) +@PersistenceTest +@Transactional(TransactionMode.COMMIT) +@CreateSchema({"create_${artifactId}_schema.sql"}) +public class ${moduleClassName}Test { + + @PersistenceContext(name = "LibreCCM") + private transient EntityManager entityManager; + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + @Deployment + public static WebArchive createDeployment() { + final PomEquippedResolveStage pom = Maven + .resolver() + .loadPomFromFile("pom.xml"); + final PomEquippedResolveStage dependencies = pom + .importCompileAndRuntimeDependencies(); + final File[] libs = dependencies.resolve().withTransitivity().asFile(); + + for (File lib : libs) { + System.err.printf("Adding file '%s' to test archive...%n", + lib.getName()); + } + + return ShrinkWrap + .create(WebArchive.class, + "LibreCCM-${packageName}.${moduleClassName}Test.war") + .addPackage(${moduleClassName}.class.getPackage()) + .addAsLibraries(libs) + .addAsResource("test-persistence.xml, + "META-INF/persistence.xml") + .addAsWebInfResource("test-web.xml", "WEB-INF/web.xml") + .addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml"); + + } + + @Test + @InSequence(1) + public void yourFirstTest() { + //ToDo: Add test logic + } + + + +} + + + diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/arquillian.xml b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/arquillian.xml new file mode 100644 index 000000000..9f191e452 --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/arquillian.xml @@ -0,0 +1,36 @@ + + + + + target/deployments + + + + + java:/comp/env/jdbc/org/libreccm/test-db/h2-mem + + + NONE + + true + target + + + + json + org.dbunit.ext.h2.H2DataTypeFactory + true + true + + + + scripts/h2-cleanup.sql + + + diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/scripts/create___artifactName___schema.sql b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/scripts/create___artifactName___schema.sql new file mode 100644 index 000000000..98eaaec36 --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/scripts/create___artifactName___schema.sql @@ -0,0 +1 @@ +-- ToDo diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/test-persistence.xml b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/test-persistence.xml new file mode 100644 index 000000000..d87713b4e --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-h2-mem/test-persistence.xml @@ -0,0 +1,40 @@ + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + java:/comp/env/jdbc/org/libreccm/test-db/h2-mem + + + + + + + + + + + + diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/arquillian.xml b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/arquillian.xml new file mode 100644 index 000000000..caecf27cc --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/arquillian.xml @@ -0,0 +1,36 @@ + + + + + target/deployments + + + + java:/comp/env/jdbc/org/libreccm/test-db/pgsql + + + NONE + + true + target + + + + json + true + true + + + + scripts/pgsql-cleanup.sql + + + + + diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/scripts/create___artifactName___schema.sql b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/scripts/create___artifactName___schema.sql new file mode 100644 index 000000000..98eaaec36 --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/scripts/create___artifactName___schema.sql @@ -0,0 +1 @@ +-- ToDo diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/test-persistence.xml b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/test-persistence.xml new file mode 100644 index 000000000..23161797a --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources-wildfly8-remote-pgsql/test-persistence.xml @@ -0,0 +1,41 @@ + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + java:/comp/env/jdbc/org/libreccm/test-db/pgsql + + + + + + + + + + + + + diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources/scripts/h2-cleanup.sql b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources/scripts/h2-cleanup.sql new file mode 100644 index 000000000..98eaaec36 --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources/scripts/h2-cleanup.sql @@ -0,0 +1 @@ +-- ToDo diff --git a/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources/scripts/pgsql-cleanup.sql b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources/scripts/pgsql-cleanup.sql new file mode 100644 index 000000000..98eaaec36 --- /dev/null +++ b/ccm-archetype-module/src/main/resources/archetype-resources/src/test/resources/scripts/pgsql-cleanup.sql @@ -0,0 +1 @@ +-- ToDo diff --git a/ccm-archetype-module/src/main/resources/module-info/__groupId__.__artifactId__.properties b/ccm-archetype-module/src/main/resources/module-info/__groupId__.__artifactId__.properties new file mode 100644 index 000000000..b9f3b36c8 --- /dev/null +++ b/ccm-archetype-module/src/main/resources/module-info/__groupId__.__artifactId__.properties @@ -0,0 +1,4 @@ +groupId=${project.groupId} +artifactId=${project.artifactId} +version=${project.version} +build.date=${timestamp} diff --git a/ccm-core/src/main/java/org/libreccm/modules/ModuleInfo.java b/ccm-core/src/main/java/org/libreccm/modules/ModuleInfo.java index c78a0b8be..1c3b1c136 100644 --- a/ccm-core/src/main/java/org/libreccm/modules/ModuleInfo.java +++ b/ccm-core/src/main/java/org/libreccm/modules/ModuleInfo.java @@ -283,7 +283,7 @@ public class ModuleInfo { getProperty(ARTIFACT_ID).replace("-", "_")); } else { - LOGGER.warn("The module data package was specified by the module " + LOGGER.warn("The module data package was not specified by the module " + "annotation nore was an group id found in the module info" + "file. Creating data package name from the name of the " + "module class."); diff --git a/ccm-shortcuts/pom.xml b/ccm-shortcuts/pom.xml index 7bd69adf4..a411416de 100644 --- a/ccm-shortcuts/pom.xml +++ b/ccm-shortcuts/pom.xml @@ -44,6 +44,7 @@ org.libreccm ccm-core ${project.parent.version} + provided diff --git a/pom.xml b/pom.xml index bb00d40de..3bb5592c1 100644 --- a/pom.xml +++ b/pom.xml @@ -39,8 +39,13 @@ ccm-shortcuts ccm-testutils ccm-docrepo + + ccm-test-bundle-wildfly8 - + + + ccm-archetype-module +