GH-1 - Initial port of Moduliths project.

Basically the state of commit c7cf939 of https://github.com/moduliths/moduliths for further development under the Spring umbrella.
This commit is contained in:
Oliver Drotbohm
2022-07-06 12:58:50 +02:00
commit 6c444769d7
236 changed files with 17771 additions and 0 deletions

28
moduliths-api/pom.xml Normal file
View File

@@ -0,0 +1,28 @@
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.moduliths</groupId>
<artifactId>moduliths</artifactId>
<version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>Moduliths - API</name>
<artifactId>moduliths-api</artifactId>
<properties>
<module.name>org.moduliths.api</module.name>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2018 the original author or authors.
*
* Licensed 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.moduliths;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation to customize information of a {@link Modulith} module.
*
* @author Oliver Gierke
*/
@Target({ ElementType.PACKAGE, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface Module {
String displayName() default "";
/**
* List the names of modules that the module is allowed to depend on. Shared modules defined in {@link Modulith} will
* be allowed, too.
*
* @return
*/
String[] allowedDependencies() default {};
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed 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.moduliths;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurationExcludeFilter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.TypeExcludeFilter;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.annotation.AliasFor;
/**
* Defines a Spring Boot application to follow the Modulith structuring conventions.
*
* @author Oliver Gierke
*/
@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Modulithic
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { //
@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface Modulith {
/**
* A logical system name for documentation purposes.
*
* @return
*/
@AliasFor(annotation = Modulithic.class)
String systemName() default "";
/**
* Whether to use fully qualified module names by default. If set to {@literal true}, hits will cause the module's
* default names to be their complete package name instead of just the modulith-local one. This might be useful in
* case {@link #additionalPackages()} pulls in packages that would cause module name conflicts, i.e. both root
* packages declare a local sub-package of the same name.
*
* @return
*/
@AliasFor(annotation = Modulithic.class)
boolean useFullyQualifiedModuleNames() default false;
/**
* The names of modules considered to be shared, i.e. which should always be included in the bootstrap no matter what.
* Useful for code to contain commons Spring configuration and components.
*
* @return
*/
@AliasFor(annotation = Modulithic.class)
String[] sharedModules() default {};
/**
* Defines which additional packages shall be considered as modulith base packages in addition to the one of the class
* carrying this annotation.
*
* @return
*/
@AliasFor(annotation = Modulithic.class)
String[] additionalPackages() default {};
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright 2019 the original author or authors.
*
* Licensed 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.moduliths;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Defines a Spring Boot application to follow the Modulith structuring conventions.
*
* @author Oliver Drotbohm
*/
@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Modulithic {
/**
* A logical system name for documentation purposes.
*
* @return
*/
String systemName() default "";
/**
* Whether to use fully qualified module names by default. If set to {@literal true}, hits will cause the module's
* default names to be their complete package name instead of just the modulith-local one. This might be useful in
* case {@link #additionalPackages()} pulls in packages that would cause module name conflicts, i.e. both root
* packages declare a local sub-package of the same name.
*
* @return
*/
boolean useFullyQualifiedModuleNames() default false;
/**
* The names of modules considered to be shared, i.e. which should always be included in the bootstrap no matter what.
* Useful for code to contain commons Spring configuration and components.
*
* @return
*/
String[] sharedModules() default {};
/**
* Defines which additional packages shall be considered as modulith base packages in addition to the one of the class
* carrying this annotation.
*
* @return
*/
String[] additionalPackages() default {};
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2018 the original author or authors.
*
* Licensed 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.moduliths;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation to mark a package as named interface of a {@link Module} (either implicit or explicitly annotated).
*
* @author Oliver Gierke
*/
@Documented
@Target({ ElementType.PACKAGE, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface NamedInterface {
/**
* The name of the interface.
*
* @return
*/
String[] value();
}