You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2019/07/04 11:16:20 UTC
[isis] branch v2 updated: ISIS-2141 dropping module
'isis-maven-plugin'
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/v2 by this push:
new 6bbf7d0 ISIS-2141 dropping module 'isis-maven-plugin'
6bbf7d0 is described below
commit 6bbf7d08e8de0d878d17ec123c8a70439f8c076d
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Jul 4 13:16:13 2019 +0200
ISIS-2141 dropping module 'isis-maven-plugin'
---
.../apache/isis/mavenplugin/IsisMojoAbstract.java | 128 +++++++
.../apache/isis/mavenplugin/IsisMojoSwagger.java | 117 +++++++
.../apache/isis/mavenplugin/IsisMojoValidate.java | 65 ++++
.../org/apache/isis/mavenplugin/IsisMojoXsd.java | 144 ++++++++
.../isis/mavenplugin/MetaModelProcessor.java} | 40 +--
.../IsisMavenPlugin_SpringContextConfig.java | 0
.../IsisMavenPlugin_SpringContextLauncher.java | 55 +--
.../org/apache/isis/mavenplugin/util/Log4j.java | 0
core/legacy/maven-plugin/pom.xml | 383 ---------------------
.../appended-resources/supplemental-models.xml | 106 ------
.../apache/isis/mavenplugin/IsisMojoAbstract.java | 148 --------
.../apache/isis/mavenplugin/IsisMojoSwagger.java | 135 --------
.../apache/isis/mavenplugin/IsisMojoValidate.java | 76 ----
.../org/apache/isis/mavenplugin/IsisMojoXsd.java | 164 ---------
.../isis/mavenplugin/MetaModelProcessor.java | 48 ---
.../org/apache/isis/mavenplugin/util/Xpp3Doms.java | 32 --
16 files changed, 502 insertions(+), 1139 deletions(-)
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoAbstract.java b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoAbstract.java
new file mode 100644
index 0000000..ce89554
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoAbstract.java
@@ -0,0 +1,128 @@
+/*
+ * 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.isis.mavenplugin;
+
+public abstract class IsisMojoAbstract /*extends AbstractMojo*/ {
+
+ protected static final String CURRENT_PLUGIN_KEY = "org.apache.isis.tool:isis-maven-plugin";
+
+// @Component
+// private MavenProject mavenProject;
+//
+// @Parameter(required = true, readonly = false, property = "appManifest")
+// private String appManifest;
+//
+// protected IsisMojoAbstract() {
+// }
+//
+// @Override
+// public void execute() throws MojoExecutionException, MojoFailureException {
+//
+// new IsisLoggingConfigurer(Level.INFO).configureLogging(".", new String[]{});
+// IsisSystemEnvironment.setUnitTesting(true);
+//
+// final ContextForMojo mjContext = new ContextForMojo(mavenProject, getLog());
+//
+// final Plugin plugin = MavenProjects.lookupPlugin(mavenProject, CURRENT_PLUGIN_KEY);
+// _Blackhole.consume(plugin);
+//
+// final ConfigurableApplicationContext springContext =
+// IsisMavenPlugin_SpringContextLauncher.getContext(mavenProject, getLog());
+//
+// Objects.requireNonNull(springContext, "Failed to bring up Spring's context.");
+//
+// try {
+//
+// doExecute(mjContext);
+//
+// } catch (IOException e) {
+// // ignore
+// } finally {
+//
+// if(springContext!=null) {
+// springContext.close();
+// }
+//
+// }
+//
+// }
+//
+// protected abstract void doExecute(
+// final ContextForMojo mojoContext)
+// throws MojoFailureException, IOException;
+//
+// // -- Context
+// static class ContextForMojo implements MetaModelProcessor.Context {
+//
+// private final MavenProject mavenProject;
+// private final Log log;
+//
+// public ContextForMojo(final MavenProject mavenProject, final Log log) {
+// this.mavenProject = mavenProject;
+// this.log = log;
+// }
+//
+// @Override
+// public MavenProject getMavenProject() {
+// return mavenProject;
+// }
+//
+// @Override
+// public Log getLog() {
+// return log;
+// }
+//
+// @Override
+// public void throwFailureException(String errorMessage, Set<String> logMessages) throws MojoFailureException {
+// logErrors(logMessages);
+// throw new MojoFailureException(errorMessage);
+// }
+//
+// @Override
+// public void throwFailureException(String errorMessage, String... logMessages) throws MojoFailureException {
+// logErrors(logMessages);
+// throw new MojoFailureException(errorMessage);
+// }
+//
+// @Override
+// public void throwExecutionException(String errorMessage, Exception e) throws MojoExecutionException {
+// logErrors(errorMessage);
+// throw new MojoExecutionException(errorMessage, e);
+// }
+//
+// private void logErrors(Set<String> logMessages) {
+// logErrors(logMessages.toArray(new String[] {}));
+// }
+//
+// @Override
+// public void logErrors(String... logMessages) {
+// log.error("");
+// log.error("");
+// log.error("");
+// for (String logMessage : logMessages) {
+// log.error(logMessage);
+// }
+// log.error("");
+// log.error("");
+// log.error("");
+// }
+// }
+
+
+}
\ No newline at end of file
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoSwagger.java b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoSwagger.java
new file mode 100644
index 0000000..e609331
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoSwagger.java
@@ -0,0 +1,117 @@
+/*
+ * 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.isis.mavenplugin;
+
+//@Mojo(
+// name = "swagger",
+// defaultPhase = LifecyclePhase.PACKAGE,
+// requiresProject = true,
+// requiresDependencyResolution = ResolutionScope.COMPILE,
+// requiresDependencyCollection = ResolutionScope.COMPILE
+// )
+public class IsisMojoSwagger extends IsisMojoAbstract {
+
+ protected IsisMojoSwagger() {
+ super();
+ }
+
+// /**
+// * Filename prefix; is appended by the visibility parameter.
+// */
+// @Parameter(required = false, readonly = false, property = "fileNamePrefix", defaultValue = "swagger")
+// private String fileNamePrefix;
+//
+// /**
+// * List of visibilities required. Defaults to both `PUBLIC` and `PRIVATE`
+// */
+// @Parameter(required = false, readonly = false, property = "visibilities")
+// private List<SwaggerService.Visibility> visibilities;
+//
+// /**
+// * Preferred format. Defaults to <code>JSON</code>.
+// */
+// @Parameter(required = false, readonly = false, property = "format", defaultValue = "JSON")
+// private SwaggerService.Format format;
+//
+// /**
+// * Directory to generate Swagger spec file; defaults to <code>target/generated-resources/isis-swagger</code>
+// */
+// @Parameter(required = false, readonly = false, property = "output", defaultValue = "generated-resources/isis-swagger")
+// private String output;
+//
+// @Override
+// protected void doExecute(
+// final ContextForMojo context)
+// throws MojoFailureException, IOException {
+//
+// final SwaggerService swaggerService =
+// IsisContext.getServiceRegistry().lookupServiceElseFail(SwaggerService.class);
+//
+// final MavenProject mavenProject = context.getMavenProject();
+// final File outputDir = determineOutputDir(mavenProject, output);
+//
+// final List<SwaggerService.Visibility> visibilityList = determineVisibility(visibilities);
+// for (SwaggerService.Visibility visibility : visibilityList) {
+// final File swaggerSpecFile = buildSwaggerSpecFile(visibility, format, outputDir, fileNamePrefix);
+// writeSwaggerSpec(swaggerService, visibility, format, swaggerSpecFile);
+// }
+// }
+//
+// private static File determineOutputDir(final MavenProject mavenProject, final String output) {
+// final String targetDir = mavenProject.getBuild().getDirectory();
+// final String outputDirStr = targetDir + File.separator + output;
+// return new File(outputDirStr);
+// }
+//
+// private static List<SwaggerService.Visibility> determineVisibility(final List<SwaggerService.Visibility> visibilities) {
+// if (visibilities == null || visibilities.isEmpty()) {
+// return Arrays.asList(SwaggerService.Visibility.PUBLIC, SwaggerService.Visibility.PRIVATE);
+// }
+// return visibilities;
+// }
+//
+// private File buildSwaggerSpecFile(
+// final SwaggerService.Visibility visibility,
+// final SwaggerService.Format format,
+// final File outputDir,
+// final String fileNamePrefix) {
+// final String swaggerSpecName = fileNamePrefix + "-" + visibility + "." + format.name().toLowerCase();
+// return new File(outputDir, swaggerSpecName);
+// }
+//
+// private void writeSwaggerSpec(
+// final SwaggerService swaggerService,
+// final SwaggerService.Visibility visibility,
+// final SwaggerService.Format format,
+// final File swaggerSpecFile) throws MojoFailureException {
+// final String swaggerSpec = swaggerService.generateSwaggerSpec(visibility, format);
+//
+// try {
+// Files.createParentDirs(swaggerSpecFile);
+// } catch (IOException e) {
+// throw new MojoFailureException( String.format("Failed to create dir: '%s'", swaggerSpecFile.getParent()));
+// }
+// try {
+// Files.write(swaggerSpec, swaggerSpecFile, Charsets.UTF_8);
+// } catch (IOException e) {
+// throw new MojoFailureException("Failed to write out " + swaggerSpecFile);
+// }
+// }
+
+}
\ No newline at end of file
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoValidate.java b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoValidate.java
new file mode 100644
index 0000000..fb7fa38
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoValidate.java
@@ -0,0 +1,65 @@
+/*
+ * 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.isis.mavenplugin;
+
+//@Mojo(
+// name = "validate",
+// defaultPhase = LifecyclePhase.TEST,
+// requiresProject = true,
+// requiresDependencyResolution = ResolutionScope.COMPILE,
+// requiresDependencyCollection = ResolutionScope.COMPILE
+// )
+public class IsisMojoValidate extends IsisMojoAbstract {
+
+// private final MetaModelProcessor metaModelProcessor;
+//
+// protected IsisMojoValidate() {
+// this.metaModelProcessor = new ValidateMetaModelProcessor();
+// }
+//
+// @Override
+// protected void doExecute(
+// final ContextForMojo context)
+// throws MojoFailureException {
+//
+// metaModelProcessor.process(context, IsisContext.getSpecificationLoader());
+// }
+//
+// static class ValidateMetaModelProcessor implements MetaModelProcessor {
+//
+//
+// @Override
+// public void process(
+// final Context context,
+// final SpecificationLoader specificationLoader)
+// throws MojoFailureException {
+//
+// final ValidationFailures validationFailures = specificationLoader.validate();
+//
+// final Collection<ObjectSpecification> objectSpecifications = specificationLoader.currentSpecifications();
+// for (ObjectSpecification objectSpecification : objectSpecifications) {
+// context.getLog().debug("loaded: " + objectSpecification.getFullIdentifier());
+// }
+// if (validationFailures.occurred()) {
+// context.throwFailureException(validationFailures.getNumberOfMessages() + " problems found.", validationFailures.getMessages());
+// }
+// }
+// }
+
+}
\ No newline at end of file
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoXsd.java b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoXsd.java
new file mode 100644
index 0000000..11f30b5
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/IsisMojoXsd.java
@@ -0,0 +1,144 @@
+/*
+ * 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.isis.mavenplugin;
+
+//@Mojo(
+// name = "xsd",
+// defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
+// requiresProject = true,
+// requiresDependencyResolution = ResolutionScope.COMPILE,
+// requiresDependencyCollection = ResolutionScope.COMPILE
+// )
+public class IsisMojoXsd extends IsisMojoAbstract {
+
+ protected IsisMojoXsd() {
+ super();
+ }
+
+// /**
+// * List of JAXB-annotated classes to generate schema for.
+// */
+// @Parameter(required = true, readonly = false, property = "jaxbClasses")
+// private List<String> jaxbClasses;
+//
+// /**
+// * Directory to generate XSD schemas; defaults to <code>target/generated-resources/isis-xsd</code>
+// */
+// @Parameter(required = false, readonly = false, property = "output", defaultValue = "generated-resources/isis-xsd")
+// private String output;
+//
+// /**
+// * Whether a separate directory is created for each JAXB-class, or whether to generate all together (so that they
+// * are created as a single bundle).
+// */
+// @Parameter(required = false, readonly = false, property = "separate", defaultValue = "false")
+// private boolean separate;
+//
+// /**
+// * Whether to also generate the isis common schema(s).
+// */
+// @Parameter(required = false, readonly = false, property = "commonSchemas", defaultValue = "false")
+// private boolean commonSchemas;
+//
+// @Override
+// protected void doExecute(
+// final ContextForMojo context)
+// throws MojoFailureException, IOException {
+//
+// final JaxbService jaxbService =
+// IsisContext.getServiceRegistry().lookupServiceElseFail(JaxbService.class);
+//
+// final MavenProject mavenProject = context.getMavenProject();
+// final File outputDir = determineOutputDir(mavenProject);
+//
+// for (String jaxbClass : jaxbClasses) {
+// writeSchemas(jaxbService, jaxbClass, outputDir);
+// }
+// }
+//
+// private File determineOutputDir(final MavenProject mavenProject) {
+// final String targetDir = mavenProject.getBuild().getDirectory();
+// final String outputDirStr = targetDir + File.separator + output;
+// return new File(outputDirStr);
+// }
+//
+// /**
+// * to ensure that any schemas with no namespace are given unique file names when written out
+// */
+// private int unnamed;
+// private void writeSchemas(
+// final JaxbService jaxbService,
+// final String dtoClassName,
+// final File outputDir) throws MojoFailureException {
+//
+// final Object instance = InstanceUtil.createInstance(dtoClassName);
+// final Map<String, String> schemaByNamespace =
+// jaxbService.toXsd(
+// instance,
+// commonSchemas ? JaxbService.IsisSchemas.INCLUDE: JaxbService.IsisSchemas.IGNORE);
+//
+// final File schemaDir = separate? new File(outputDir, dtoClassName): outputDir;
+//
+// unnamed = 0;
+// for (Map.Entry<String, String> entry : schemaByNamespace.entrySet()) {
+// final String namespaceUri = entry.getKey();
+// final String schemaText = entry.getValue();
+//
+// final String xsdName = xsdDirNameFor(namespaceUri);
+// final File schemaFile = new File(schemaDir, xsdName);
+// try {
+// Files.createParentDirs(schemaFile);
+// } catch (IOException e) {
+// throw new MojoFailureException( String.format("Failed to create dir: '%s'", schemaFile.getParent()));
+// }
+// try {
+// Files.write(schemaText, schemaFile, Charsets.UTF_8);
+// } catch (IOException e) {
+// throw new MojoFailureException("Failed to write out " + schemaFile);
+// }
+// if(!xsdName.endsWith(".xsd")) {
+// final File schemaFileWithXsdSuffix = new File(schemaDir, xsdName + ".xsd");
+// try {
+// Files.copy(schemaFile, schemaFileWithXsdSuffix);
+// } catch (IOException e) {
+// throw new MojoFailureException("Failed to copy to " + schemaFileWithXsdSuffix);
+// }
+// }
+// }
+// }
+//
+// String xsdDirNameFor(final String namespaceUri) {
+// final String sanitized = sanitize(namespaceUri);
+// final String sanitizedElseUnnamed = _Strings.isNullOrEmpty(sanitized) ? ("unnamed-" + (unnamed++)) : sanitized;
+// return sanitizedElseUnnamed;
+// }
+//
+// private static String sanitize(final String namespaceUri) {
+// String sanitized = namespaceUri;
+// sanitized = removePrefix(sanitized, "http://");
+// sanitized = removePrefix(sanitized, "https://");
+// sanitized = sanitized.replaceAll(":", "_");
+// return sanitized.replaceAll("[\\\\\\/]", File.separator + File.separator);
+// }
+//
+// private static String removePrefix(final String str, final String prefix) {
+// return str.startsWith(prefix)? str.substring(prefix.length()): str;
+// }
+
+}
\ No newline at end of file
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/util/MavenProjects.java b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/MetaModelProcessor.java
similarity index 53%
rename from core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/util/MavenProjects.java
rename to core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/MetaModelProcessor.java
index b907c9c..44bf469 100644
--- a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/util/MavenProjects.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/MetaModelProcessor.java
@@ -16,27 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.mavenplugin.util;
-
-import java.util.List;
-
-import org.apache.maven.model.Plugin;
-import org.apache.maven.project.MavenProject;
-
-public final class MavenProjects {
-
- private MavenProjects(){}
-
- public static Plugin lookupPlugin(MavenProject mavenProject, String key) {
-
- List<Plugin> plugins = mavenProject.getBuildPlugins();
-
- for (Plugin plugin : plugins) {
- if (key.equalsIgnoreCase(plugin.getKey())) {
- return plugin;
- }
- }
- return null;
+package org.apache.isis.mavenplugin;
+
+interface MetaModelProcessor {
+
+ public interface Context {
+
+// MavenProject getMavenProject();
+//
+// Log getLog();
+//
+// void logErrors(final String... logMessages);
+//
+// void throwFailureException(final String errorMessage, final Set<String> logMessages) throws MojoFailureException;
+//
+// void throwFailureException(final String errorMessage, final String... logMessages) throws MojoFailureException;
+//
+// void throwExecutionException(final String errorMessage, final Exception e) throws MojoExecutionException;
}
+// void process(final Context context, final SpecificationLoader specificationLoader) throws MojoFailureException;
+
}
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextConfig.java b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextConfig.java
similarity index 100%
rename from core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextConfig.java
rename to core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextConfig.java
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextLauncher.java b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextLauncher.java
similarity index 76%
rename from core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextLauncher.java
rename to core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextLauncher.java
index d94d5df..16babb8 100644
--- a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextLauncher.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/spring/IsisMavenPlugin_SpringContextLauncher.java
@@ -33,12 +33,13 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
+import org.apache.isis.commons.internal.collections._Arrays;
+import org.apache.isis.commons.internal.collections._Lists;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.apache.isis.commons.internal.collections._Arrays;
+import lombok.extern.java.Log;
+import lombok.extern.log4j.Log4j2;
/**
* Creates a Spring Context from scratch, adding the
@@ -48,13 +49,14 @@ import org.apache.isis.commons.internal.collections._Arrays;
* @since 2.0
*
*/
+@Log4j2
public class IsisMavenPlugin_SpringContextLauncher {
private final static String exclude_from_scan = "org.apache.isis.core";
- public static ConfigurableApplicationContext getContext(MavenProject project, Log log) {
+ public static ConfigurableApplicationContext getContext(/*MavenProject project, Log log*/) {
- Set<String> packages = scanForPackages(project);
+ Set<String> packages = scanForPackages(/*project*/);
log.info("packages from package-scan: " + packages);
@@ -73,36 +75,37 @@ public class IsisMavenPlugin_SpringContextLauncher {
// -- COLLECT PACKAGE NAMES
- private static Set<String> scanForPackages(MavenProject topProject) {
+ private static Set<String> scanForPackages(/*MavenProject topProject*/) {
Set<String> packageNames = new HashSet<String>();
- Stream.concat(Stream.of(topProject), topProject.getCollectedProjects().stream())
- .forEach(project->{
-
- for(String className : scanForClassNames(project)) {
- if(className.contains(".")) {
- int endIndex = className.lastIndexOf('.');
- String packageName = className.substring(0, endIndex);
- if(
- !packageName.equals(exclude_from_scan) &&
- !packageName.startsWith(exclude_from_scan + ".") ) {
-
- packageNames.add(packageName);
- }
-
- }
- }
-
- });
+// Stream.concat(Stream.of(topProject), topProject.getCollectedProjects().stream())
+// .forEach(project->{
+//
+// for(String className : scanForClassNames(project)) {
+// if(className.contains(".")) {
+// int endIndex = className.lastIndexOf('.');
+// String packageName = className.substring(0, endIndex);
+// if(
+// !packageName.equals(exclude_from_scan) &&
+// !packageName.startsWith(exclude_from_scan + ".") ) {
+//
+// packageNames.add(packageName);
+// }
+//
+// }
+// }
+//
+// });
return packageNames;
}
// -- COLLECT ALL CLASSNAMES
- private static Set<String> scanForClassNames(MavenProject project) {
+ private static Set<String> scanForClassNames(/*MavenProject project*/) {
Set<String> classNames = new HashSet<String>();
- List<String> roots = (List<String>)(project.getCompileSourceRoots());
+ List<String> roots = _Lists.newArrayList();
+ //(List<String>)(project.getCompileSourceRoots());
for (String root : roots) {
toPath(root).ifPresent(rootPath->{
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/util/Log4j.java b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/util/Log4j.java
similarity index 100%
rename from core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/util/Log4j.java
rename to core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/util/Log4j.java
diff --git a/core/legacy/maven-plugin/pom.xml b/core/legacy/maven-plugin/pom.xml
deleted file mode 100644
index 7b156e9..0000000
--- a/core/legacy/maven-plugin/pom.xml
+++ /dev/null
@@ -1,383 +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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.isis.core</groupId>
- <artifactId>isis</artifactId>
- <version>${revision}</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <groupId>org.apache.isis.tool</groupId>
- <artifactId>isis-maven-plugin</artifactId>
-
- <packaging>maven-plugin</packaging>
-
- <name>Apache Isis Maven Plugin (isis-maven-plugin)</name>
- <description>
- Maven plugin for Apache Isis, allowing the metamodel to be validated as part of the build process.
- </description>
-
- <prerequisites>
- <maven>3.5.3</maven>
- </prerequisites>
-
- <properties>
- <jar-plugin.automaticModuleName>org.apache.isis.tool.mavenplugin</jar-plugin.automaticModuleName>
- <git-plugin.propertiesDir>org/apache/isis/tool/mavenplugin</git-plugin.propertiesDir>
-
- <maven-core.version>3.5.3</maven-core.version>
- <maven-project.version>3.0-alpha-2</maven-project.version>
- <maven-plugin-annotations.version>3.5.1</maven-plugin-annotations.version>
- <plexus-container-default.version>1.7.1</plexus-container-default.version>
- <plexus-utils.version>3.1.0</plexus-utils.version>
-
- </properties>
-
- <build>
-
- <pluginManagement>
- <plugins>
- <!-- Apache Release Audit Tool -->
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <version>0.10</version>
- <configuration>
- <excludes>
- <!-- overriding inherited excludes from oia.core:isis with a more
- specific set for this component -->
- <exclude>**/target/**</exclude>
- <exclude>**/target-ide/**</exclude>
-
- <exclude>**/*.project</exclude>
- <exclude>**/.classpath</exclude>
- <exclude>**/.settings/**</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <configuration>
- <goalPrefix>configurator</goalPrefix>
- </configuration>
- <executions>
- <execution>
- <id>default-descriptor</id>
- <goals>
- <goal>descriptor</goal>
- </goals>
- <phase>process-classes</phase>
- </execution>
- <execution>
- <id>help-descriptor</id>
- <goals>
- <goal>helpmojo</goal>
- </goals>
- <phase>process-classes</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.isis.core</groupId>
- <artifactId>isis-runtime-services</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.isis.core</groupId>
- <artifactId>isis-runtime-extensions</artifactId>
- </dependency>
-
- <!-- the plethora of exclusions in the following dependencies are to ensure
- dependency convergence. In some cases, what would have been a transitive
- dependency is added as a direct dependency in order that its divergent dependency
- can be excluded. It's all a bit of a pig's ear... -->
-
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>${plexus-utils.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven-core.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- <version>${maven-plugin-annotations.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${maven-core.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-sec-dispatcher</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- <version>${maven-core.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model-builder</artifactId>
- <version>${maven-core.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-settings</artifactId>
- <version>${maven-core.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>${maven-core.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>${maven-project.version}</version>
- <exclusions>
- <!-- for dependency convergence -->
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-compat</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-interpolation</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-compat</artifactId>
- <version>${maven-core.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>${plexus-container-default.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-classworlds</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.google.collections</groupId>
- <artifactId>google-collections</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-toolchain</artifactId>
- <version>${maven-project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-compat</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- SPRING -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>${spring-boot.version}</version>
- <type>pom</type>
- <scope>import</scope>
-
- <exclusions>
- <exclusion>
- <groupId>org.ow2.asm</groupId>
- <artifactId>asm</artifactId>
- </exclusion>
- <exclusion>
- <!-- when spring-boot release lags behind spring-core release explicitly
- spring-test added below -->
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- </exclusion>
- <exclusion>
- <!-- when spring-boot release lags behind spring-core release explicitly
- spring-test added below -->
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- Logging -->
-
- <dependency>
- <groupId>org.apache.isis.core</groupId>
- <artifactId>isis-log4j</artifactId>
- </dependency>
-
- </dependencies>
-
- <profiles>
- <profile>
- <id>flatten</id>
- <activation>
- <property>
- <name>!skip.flatten</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>flatten-maven-plugin</artifactId>
- <version>1.0.0</version>
- <executions>
- <execution>
- <id>flatten</id>
- <phase>process-resources</phase>
- <goals>
- <goal>flatten</goal>
- </goals>
- <configuration>
- <flattenMode>defaults</flattenMode>
- <updatePomFile>true</updatePomFile>
- <pomElements>
- <name>resolve</name>
- <description>resolve</description>
- <dependencies>resolve</dependencies>
- </pomElements>
- </configuration>
- </execution>
- <execution>
- <id>flatten.clean</id>
- <phase>clean</phase>
- <goals>
- <goal>clean</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
diff --git a/core/legacy/maven-plugin/src/main/appended-resources/supplemental-models.xml b/core/legacy/maven-plugin/src/main/appended-resources/supplemental-models.xml
deleted file mode 100644
index ecd3906..0000000
--- a/core/legacy/maven-plugin/src/main/appended-resources/supplemental-models.xml
+++ /dev/null
@@ -1,106 +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. -->
-<supplementalDataModels xmlns="http://maven.apache.org/supplemental-model/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/supplemental-model/1.0.0 http://maven.apache.org/xsd/supplemental-model-1.0.0.xsd">
-
- <supplement>
- <project>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- <version>1.0</version>
- <licenses>
- <license>
- <name>Public Domain</name>
- </license>
- </licenses>
- </project>
- </supplement>
-
- <supplement>
- <!-- not quite sure why licenses:download-license flags this, since license info seems to be in its POM -->
- <project>
- <groupId>org.datanucleus</groupId>
- <artifactId>datanucleus-jodatime</artifactId>
- <version>3.1.1</version>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
-
- <supplement>
- <project>
- <groupId>org.scannotation</groupId>
- <artifactId>scannotation</artifactId>
- <version>1.0.3</version>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- </project>
- </supplement>
-
- <supplement>
- <project>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- <licenses>
- <license>
- <name>BSD License</name>
- <url>http://dom4j.sourceforge.net/dom4j-1.6.1/license.html</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- </project>
- </supplement>
-
- <supplement>
- <project>
- <groupId>net.jcip</groupId>
- <artifactId>jcip-annotations</artifactId>
- <version>1.0</version>
- <licenses>
- <license>
- <name>Creative Commons Attribution 2.5 License</name>
- <url>http://creativecommons.org/licenses/by/2.5/</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- </project>
- </supplement>
-
-
- <supplement>
- <project>
- <groupId>xalan</groupId>
- <artifactId>xalan</artifactId>
- <version>2.7.0</version>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- </project>
- </supplement>
-
-
-</supplementalDataModels>
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoAbstract.java b/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoAbstract.java
deleted file mode 100644
index dce8378..0000000
--- a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoAbstract.java
+++ /dev/null
@@ -1,148 +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.isis.mavenplugin;
-
-import java.io.IOException;
-import java.util.Objects;
-import java.util.Set;
-
-import org.apache.isis.commons.internal.base._Blackhole;
-import org.apache.isis.commons.internal.plugins.environment.IsisSystemEnvironment;
-import org.apache.isis.logging.IsisLoggingConfigurer;
-import org.apache.isis.mavenplugin.spring.IsisMavenPlugin_SpringContextLauncher;
-import org.apache.isis.mavenplugin.util.MavenProjects;
-import org.apache.logging.log4j.Level;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.springframework.context.ConfigurableApplicationContext;
-
-public abstract class IsisMojoAbstract extends AbstractMojo {
-
- protected static final String CURRENT_PLUGIN_KEY = "org.apache.isis.tool:isis-maven-plugin";
-
- @Component
- private MavenProject mavenProject;
-
- @Parameter(required = true, readonly = false, property = "appManifest")
- private String appManifest;
-
- protected IsisMojoAbstract() {
- }
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- new IsisLoggingConfigurer(Level.INFO).configureLogging(".", new String[]{});
- IsisSystemEnvironment.setUnitTesting(true);
-
- final ContextForMojo mjContext = new ContextForMojo(mavenProject, getLog());
-
- final Plugin plugin = MavenProjects.lookupPlugin(mavenProject, CURRENT_PLUGIN_KEY);
- _Blackhole.consume(plugin);
-
- final ConfigurableApplicationContext springContext =
- IsisMavenPlugin_SpringContextLauncher.getContext(mavenProject, getLog());
-
- Objects.requireNonNull(springContext, "Failed to bring up Spring's context.");
-
- try {
-
- doExecute(mjContext);
-
- } catch (IOException e) {
- // ignore
- } finally {
-
- if(springContext!=null) {
- springContext.close();
- }
-
- }
-
- }
-
- protected abstract void doExecute(
- final ContextForMojo mojoContext)
- throws MojoFailureException, IOException;
-
- // -- Context
- static class ContextForMojo implements MetaModelProcessor.Context {
-
- private final MavenProject mavenProject;
- private final Log log;
-
- public ContextForMojo(final MavenProject mavenProject, final Log log) {
- this.mavenProject = mavenProject;
- this.log = log;
- }
-
- @Override
- public MavenProject getMavenProject() {
- return mavenProject;
- }
-
- @Override
- public Log getLog() {
- return log;
- }
-
- @Override
- public void throwFailureException(String errorMessage, Set<String> logMessages) throws MojoFailureException {
- logErrors(logMessages);
- throw new MojoFailureException(errorMessage);
- }
-
- @Override
- public void throwFailureException(String errorMessage, String... logMessages) throws MojoFailureException {
- logErrors(logMessages);
- throw new MojoFailureException(errorMessage);
- }
-
- @Override
- public void throwExecutionException(String errorMessage, Exception e) throws MojoExecutionException {
- logErrors(errorMessage);
- throw new MojoExecutionException(errorMessage, e);
- }
-
- private void logErrors(Set<String> logMessages) {
- logErrors(logMessages.toArray(new String[] {}));
- }
-
- @Override
- public void logErrors(String... logMessages) {
- log.error("");
- log.error("");
- log.error("");
- for (String logMessage : logMessages) {
- log.error(logMessage);
- }
- log.error("");
- log.error("");
- log.error("");
- }
- }
-
-
-}
\ No newline at end of file
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoSwagger.java b/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoSwagger.java
deleted file mode 100644
index b990188..0000000
--- a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoSwagger.java
+++ /dev/null
@@ -1,135 +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.isis.mavenplugin;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-
-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.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-
-import org.apache.isis.applib.services.swagger.SwaggerService;
-import org.apache.isis.runtime.system.context.IsisContext;
-
-@Mojo(
- name = "swagger",
- defaultPhase = LifecyclePhase.PACKAGE,
- requiresProject = true,
- requiresDependencyResolution = ResolutionScope.COMPILE,
- requiresDependencyCollection = ResolutionScope.COMPILE
- )
-public class IsisMojoSwagger extends IsisMojoAbstract {
-
- protected IsisMojoSwagger() {
- super();
- }
-
- /**
- * Filename prefix; is appended by the visibility parameter.
- */
- @Parameter(required = false, readonly = false, property = "fileNamePrefix", defaultValue = "swagger")
- private String fileNamePrefix;
-
- /**
- * List of visibilities required. Defaults to both `PUBLIC` and `PRIVATE`
- */
- @Parameter(required = false, readonly = false, property = "visibilities")
- private List<SwaggerService.Visibility> visibilities;
-
- /**
- * Preferred format. Defaults to <code>JSON</code>.
- */
- @Parameter(required = false, readonly = false, property = "format", defaultValue = "JSON")
- private SwaggerService.Format format;
-
- /**
- * Directory to generate Swagger spec file; defaults to <code>target/generated-resources/isis-swagger</code>
- */
- @Parameter(required = false, readonly = false, property = "output", defaultValue = "generated-resources/isis-swagger")
- private String output;
-
- @Override
- protected void doExecute(
- final ContextForMojo context)
- throws MojoFailureException, IOException {
-
- final SwaggerService swaggerService =
- IsisContext.getServiceRegistry().lookupServiceElseFail(SwaggerService.class);
-
- final MavenProject mavenProject = context.getMavenProject();
- final File outputDir = determineOutputDir(mavenProject, output);
-
- final List<SwaggerService.Visibility> visibilityList = determineVisibility(visibilities);
- for (SwaggerService.Visibility visibility : visibilityList) {
- final File swaggerSpecFile = buildSwaggerSpecFile(visibility, format, outputDir, fileNamePrefix);
- writeSwaggerSpec(swaggerService, visibility, format, swaggerSpecFile);
- }
- }
-
- private static File determineOutputDir(final MavenProject mavenProject, final String output) {
- final String targetDir = mavenProject.getBuild().getDirectory();
- final String outputDirStr = targetDir + File.separator + output;
- return new File(outputDirStr);
- }
-
- private static List<SwaggerService.Visibility> determineVisibility(final List<SwaggerService.Visibility> visibilities) {
- if (visibilities == null || visibilities.isEmpty()) {
- return Arrays.asList(SwaggerService.Visibility.PUBLIC, SwaggerService.Visibility.PRIVATE);
- }
- return visibilities;
- }
-
- private File buildSwaggerSpecFile(
- final SwaggerService.Visibility visibility,
- final SwaggerService.Format format,
- final File outputDir,
- final String fileNamePrefix) {
- final String swaggerSpecName = fileNamePrefix + "-" + visibility + "." + format.name().toLowerCase();
- return new File(outputDir, swaggerSpecName);
- }
-
- private void writeSwaggerSpec(
- final SwaggerService swaggerService,
- final SwaggerService.Visibility visibility,
- final SwaggerService.Format format,
- final File swaggerSpecFile) throws MojoFailureException {
- final String swaggerSpec = swaggerService.generateSwaggerSpec(visibility, format);
-
- try {
- Files.createParentDirs(swaggerSpecFile);
- } catch (IOException e) {
- throw new MojoFailureException( String.format("Failed to create dir: '%s'", swaggerSpecFile.getParent()));
- }
- try {
- Files.write(swaggerSpec, swaggerSpecFile, Charsets.UTF_8);
- } catch (IOException e) {
- throw new MojoFailureException("Failed to write out " + swaggerSpecFile);
- }
- }
-
-}
\ No newline at end of file
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoValidate.java b/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoValidate.java
deleted file mode 100644
index e9601cc..0000000
--- a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoValidate.java
+++ /dev/null
@@ -1,76 +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.isis.mavenplugin;
-
-import java.util.Collection;
-
-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.ResolutionScope;
-import org.apache.isis.metamodel.spec.ObjectSpecification;
-import org.apache.isis.metamodel.specloader.SpecificationLoader;
-import org.apache.isis.metamodel.specloader.validator.ValidationFailures;
-import org.apache.isis.runtime.system.context.IsisContext;
-
-@Mojo(
- name = "validate",
- defaultPhase = LifecyclePhase.TEST,
- requiresProject = true,
- requiresDependencyResolution = ResolutionScope.COMPILE,
- requiresDependencyCollection = ResolutionScope.COMPILE
- )
-public class IsisMojoValidate extends IsisMojoAbstract {
-
- private final MetaModelProcessor metaModelProcessor;
-
- protected IsisMojoValidate() {
- this.metaModelProcessor = new ValidateMetaModelProcessor();
- }
-
- @Override
- protected void doExecute(
- final ContextForMojo context)
- throws MojoFailureException {
-
- metaModelProcessor.process(context, IsisContext.getSpecificationLoader());
- }
-
- static class ValidateMetaModelProcessor implements MetaModelProcessor {
-
-
- @Override
- public void process(
- final Context context,
- final SpecificationLoader specificationLoader)
- throws MojoFailureException {
-
- final ValidationFailures validationFailures = specificationLoader.validate();
-
- final Collection<ObjectSpecification> objectSpecifications = specificationLoader.currentSpecifications();
- for (ObjectSpecification objectSpecification : objectSpecifications) {
- context.getLog().debug("loaded: " + objectSpecification.getFullIdentifier());
- }
- if (validationFailures.occurred()) {
- context.throwFailureException(validationFailures.getNumberOfMessages() + " problems found.", validationFailures.getMessages());
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoXsd.java b/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoXsd.java
deleted file mode 100644
index 28ac15c..0000000
--- a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/IsisMojoXsd.java
+++ /dev/null
@@ -1,164 +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.isis.mavenplugin;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-
-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.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-
-import org.apache.isis.applib.services.jaxb.JaxbService;
-import org.apache.isis.commons.internal.base._Strings;
-import org.apache.isis.commons.internal.factory.InstanceUtil;
-import org.apache.isis.runtime.system.context.IsisContext;
-
-@Mojo(
- name = "xsd",
- defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
- requiresProject = true,
- requiresDependencyResolution = ResolutionScope.COMPILE,
- requiresDependencyCollection = ResolutionScope.COMPILE
- )
-public class IsisMojoXsd extends IsisMojoAbstract {
-
- protected IsisMojoXsd() {
- super();
- }
-
- /**
- * List of JAXB-annotated classes to generate schema for.
- */
- @Parameter(required = true, readonly = false, property = "jaxbClasses")
- private List<String> jaxbClasses;
-
- /**
- * Directory to generate XSD schemas; defaults to <code>target/generated-resources/isis-xsd</code>
- */
- @Parameter(required = false, readonly = false, property = "output", defaultValue = "generated-resources/isis-xsd")
- private String output;
-
- /**
- * Whether a separate directory is created for each JAXB-class, or whether to generate all together (so that they
- * are created as a single bundle).
- */
- @Parameter(required = false, readonly = false, property = "separate", defaultValue = "false")
- private boolean separate;
-
- /**
- * Whether to also generate the isis common schema(s).
- */
- @Parameter(required = false, readonly = false, property = "commonSchemas", defaultValue = "false")
- private boolean commonSchemas;
-
- @Override
- protected void doExecute(
- final ContextForMojo context)
- throws MojoFailureException, IOException {
-
- final JaxbService jaxbService =
- IsisContext.getServiceRegistry().lookupServiceElseFail(JaxbService.class);
-
- final MavenProject mavenProject = context.getMavenProject();
- final File outputDir = determineOutputDir(mavenProject);
-
- for (String jaxbClass : jaxbClasses) {
- writeSchemas(jaxbService, jaxbClass, outputDir);
- }
- }
-
- private File determineOutputDir(final MavenProject mavenProject) {
- final String targetDir = mavenProject.getBuild().getDirectory();
- final String outputDirStr = targetDir + File.separator + output;
- return new File(outputDirStr);
- }
-
- /**
- * to ensure that any schemas with no namespace are given unique file names when written out
- */
- private int unnamed;
- private void writeSchemas(
- final JaxbService jaxbService,
- final String dtoClassName,
- final File outputDir) throws MojoFailureException {
-
- final Object instance = InstanceUtil.createInstance(dtoClassName);
- final Map<String, String> schemaByNamespace =
- jaxbService.toXsd(
- instance,
- commonSchemas ? JaxbService.IsisSchemas.INCLUDE: JaxbService.IsisSchemas.IGNORE);
-
- final File schemaDir = separate? new File(outputDir, dtoClassName): outputDir;
-
- unnamed = 0;
- for (Map.Entry<String, String> entry : schemaByNamespace.entrySet()) {
- final String namespaceUri = entry.getKey();
- final String schemaText = entry.getValue();
-
- final String xsdName = xsdDirNameFor(namespaceUri);
- final File schemaFile = new File(schemaDir, xsdName);
- try {
- Files.createParentDirs(schemaFile);
- } catch (IOException e) {
- throw new MojoFailureException( String.format("Failed to create dir: '%s'", schemaFile.getParent()));
- }
- try {
- Files.write(schemaText, schemaFile, Charsets.UTF_8);
- } catch (IOException e) {
- throw new MojoFailureException("Failed to write out " + schemaFile);
- }
- if(!xsdName.endsWith(".xsd")) {
- final File schemaFileWithXsdSuffix = new File(schemaDir, xsdName + ".xsd");
- try {
- Files.copy(schemaFile, schemaFileWithXsdSuffix);
- } catch (IOException e) {
- throw new MojoFailureException("Failed to copy to " + schemaFileWithXsdSuffix);
- }
- }
- }
- }
-
- String xsdDirNameFor(final String namespaceUri) {
- final String sanitized = sanitize(namespaceUri);
- final String sanitizedElseUnnamed = _Strings.isNullOrEmpty(sanitized) ? ("unnamed-" + (unnamed++)) : sanitized;
- return sanitizedElseUnnamed;
- }
-
- private static String sanitize(final String namespaceUri) {
- String sanitized = namespaceUri;
- sanitized = removePrefix(sanitized, "http://");
- sanitized = removePrefix(sanitized, "https://");
- sanitized = sanitized.replaceAll(":", "_");
- return sanitized.replaceAll("[\\\\\\/]", File.separator + File.separator);
- }
-
- private static String removePrefix(final String str, final String prefix) {
- return str.startsWith(prefix)? str.substring(prefix.length()): str;
- }
-
-}
\ No newline at end of file
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/MetaModelProcessor.java b/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/MetaModelProcessor.java
deleted file mode 100644
index 807e3db..0000000
--- a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/MetaModelProcessor.java
+++ /dev/null
@@ -1,48 +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.isis.mavenplugin;
-
-import java.util.Set;
-
-import org.apache.isis.metamodel.specloader.SpecificationLoader;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-
-interface MetaModelProcessor {
-
- public interface Context {
-
- MavenProject getMavenProject();
-
- Log getLog();
-
- void logErrors(final String... logMessages);
-
- void throwFailureException(final String errorMessage, final Set<String> logMessages) throws MojoFailureException;
-
- void throwFailureException(final String errorMessage, final String... logMessages) throws MojoFailureException;
-
- void throwExecutionException(final String errorMessage, final Exception e) throws MojoExecutionException;
- }
-
- void process(final Context context, final SpecificationLoader specificationLoader) throws MojoFailureException;
-
-}
diff --git a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/util/Xpp3Doms.java b/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/util/Xpp3Doms.java
deleted file mode 100644
index 7d84a17..0000000
--- a/core/legacy/maven-plugin/src/main/java/org/apache/isis/mavenplugin/util/Xpp3Doms.java
+++ /dev/null
@@ -1,32 +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.isis.mavenplugin.util;
-
-import java.util.function.Function;
-
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-
-public final class Xpp3Doms {
-
- private Xpp3Doms(){}
-
- public static Function<Xpp3Dom, String> GET_VALUE = Xpp3Dom::getValue;
-
-
-}