Skip to content

Commit

Permalink
I'm quite sure the solution is good, but there is just one github tes…
Browse files Browse the repository at this point in the history
…t that doesn't work
  • Loading branch information
Riduidel committed Feb 27, 2024
1 parent 824511b commit 1ed5528
Show file tree
Hide file tree
Showing 84 changed files with 677 additions and 286 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package org.ndx.aadarchi.maven.plugin;

import com.structurizr.annotation.Component;
import org.apache.deltaspike.core.api.config.ConfigProperty;

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.ResolutionScope;
import org.ndx.aadarchi.cdi.deltaspike.ConfigProperty;
import org.ndx.aadarchi.maven.cdi.helper.wrappers.AbstractCDIStarterMojo;

import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
import jakarta.enterprise.inject.spi.Bean;
import jakarta.enterprise.inject.spi.BeanManager;
import jakarta.enterprise.inject.spi.InjectionPoint;
import jakarta.inject.Inject;
import java.util.Arrays;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -40,7 +41,7 @@ public static class ListAvailableProperties implements Runnable {
*/
Set<String> filteredPackages = new TreeSet<>(Arrays.asList(
"org.jboss.weld",
"javax.enterprise.inject",
"jakarta.enterprise.inject",
"org.apache.deltaspike"));

private boolean isInFilteredPackage(String packageName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.io.IOException;
import java.util.logging.Logger;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import org.ndx.aadarchi.base.ArchitectureDocumentationBuilder;

Expand Down
10 changes: 5 additions & 5 deletions aadarchi-test-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
Mainly contains tools allowing easy injection of Maven properties into tests</description>
<dependencies>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<groupId>${project.groupId}</groupId>
<artifactId>cdi-config-extension</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Directly referenced to make sure we can create the ConfigSource allowing us to provide maven properties as config properties -->
<dependency>
<groupId>org.apache.deltaspike.core</groupId>
<artifactId>deltaspike-core-impl</artifactId>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,65 @@
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.logging.Logger;

import javax.inject.Inject;
import org.ndx.aadarchi.cdi.deltaspike.ConfigSource;

import org.apache.deltaspike.core.api.config.Source;
import org.apache.deltaspike.core.api.projectstage.ProjectStage;
import org.apache.deltaspike.core.spi.config.ConfigSource;
import jakarta.enterprise.context.ApplicationScoped;

@Source
@ApplicationScoped
public class ExposeMavenPropertiesAsConfigProperties implements ConfigSource {
private static final Logger logger = Logger.getLogger(ExposeMavenPropertiesAsConfigProperties.class.getName());

private static final int DELTASPIKE_PRIORITY = 1000;

public static enum Keys {
BASE_DIR("project.basedir") {

@Override
public String getComputedValue() {
return computeBasedir();
}

},
BUILD_DIR("project.build.directory") {

@Override
public String getComputedValue() {
return computeBuildDirectory();
}

};

private final String propertyKey;

private Keys(String propertyKey) {
this.propertyKey = propertyKey;
}

static Optional<String> getEnumValueFor(String key) {
for(Keys k : values()) {
if(k.getPropertyKey().equals(key)) {
return Optional.ofNullable(k.getComputedValue());
}
}
return Optional.empty();
}

String getPropertyKey() {
return propertyKey;
}

public abstract String getComputedValue();

}

public ExposeMavenPropertiesAsConfigProperties() {
super();
}

@Inject ProjectStage projectStage;

@Override
public String getConfigName() {
return "maven-fake-properties";
Expand All @@ -36,25 +74,19 @@ public Map<String, String> getProperties() {

@Override
public String getPropertyValue(String key) {
switch(key) {
case "project.basedir":
return computeBasedir();
case "project.build.directory":
return computeBuildDirectory();
default:
return null;
}
return Keys.getEnumValueFor(key)
.orElse(null);
}

private String computeBuildDirectory() {
static String computeBuildDirectory() {
return computePathMatching(file -> new File(file, "target").exists() && new File(file, "target").isDirectory())+"/target";
}

private String computeBasedir() {
static String computeBasedir() {
return computePathMatching(file -> new File(file, ".git").exists());
}

private String computePathMatching(Predicate<File> predicate) {
static private String computePathMatching(Predicate<File> predicate) {
File current = new File(".");
try {
current = current.getCanonicalFile();
Expand All @@ -64,7 +96,7 @@ private String computePathMatching(Predicate<File> predicate) {
}
}

private String computeParentPathMatching(File current, Predicate<File> test) {
static private String computeParentPathMatching(File current, Predicate<File> test) {
if(test.test(current))
return current.getAbsolutePath();
else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.ndx.aadarchi.maven.cdi.faker.properties;

import org.apache.commons.lang3.StringUtils;
import org.ndx.aadarchi.cdi.deltaspike.ConfigFilter;

import jakarta.inject.Inject;

public class FilterMavenPropertiesInValues implements ConfigFilter {

@Inject ExposeMavenPropertiesAsConfigProperties configSource;

@Override
public String filterValue(String key, String value) {
String updatedValue = value;
for(ExposeMavenPropertiesAsConfigProperties.Keys k : ExposeMavenPropertiesAsConfigProperties.Keys.values()) {
String initial = String.format("${%s}", k.getPropertyKey());
String replaced = k.getComputedValue();
updatedValue = updatedValue.replace(initial, replaced);
}
return updatedValue;
}

@Override
public String filterValueForLog(String key, String value) {
String updatedValue = value;
for(ExposeMavenPropertiesAsConfigProperties.Keys k : ExposeMavenPropertiesAsConfigProperties.Keys.values()) {
String initial = String.format("${%s}", k.getPropertyKey());
String replaced = k.getComputedValue();
if(k.getPropertyKey().contains("password")) {
replaced = StringUtils.repeat('*', replaced.length());
}
updatedValue = updatedValue.replace(initial, replaced);
}
return updatedValue;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;

import org.apache.commons.vfs2.FileObject;
import org.apache.deltaspike.core.api.config.ConfigProperty;
import org.ndx.aadarchi.base.AgileArchitectureSection;
import org.ndx.aadarchi.base.Enhancer;
import org.ndx.aadarchi.base.OutputBuilder;
Expand All @@ -28,6 +27,7 @@
import org.ndx.aadarchi.base.enhancers.tickets.Ticket;
import org.ndx.aadarchi.base.enhancers.tickets.TicketStatus;
import org.ndx.aadarchi.base.enhancers.tickets.TicketsHandler;
import org.ndx.aadarchi.cdi.deltaspike.ConfigProperty;

import com.structurizr.annotation.Component;
import com.structurizr.model.Element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.ndx.aadarchi.base.OutputBuilder;
import org.ndx.aadarchi.base.enhancers.ModelElementAdapter;

import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.util.Comparator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.se.SeContainer;
import javax.enterprise.inject.se.SeContainerInitializer;
import javax.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Any;
import jakarta.enterprise.inject.Instance;
import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.se.SeContainerInitializer;
import jakarta.inject.Inject;

import org.jboss.weld.config.ConfigurationKey;
import org.ndx.aadarchi.base.providers.FromDsl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;

import org.apache.commons.lang3.stream.Streams;
import org.apache.commons.lang3.time.StopWatch;
import org.apache.commons.vfs2.FileObject;
import org.apache.deltaspike.core.api.config.ConfigProperty;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys.ConfigProperties.DisabledEnhancers;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys.ConfigProperties.EnhancementsDir;
import org.ndx.aadarchi.base.utils.SimpleOutputBuilder;
import org.ndx.aadarchi.cdi.deltaspike.ConfigProperty;

import com.structurizr.Workspace;
import com.structurizr.annotation.UsesComponent;
Expand Down
4 changes: 2 additions & 2 deletions base/src/main/java/org/ndx/aadarchi/base/enhancers/ToDsl.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;

import javax.inject.Inject;
import jakarta.inject.Inject;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.vfs2.FileObject;
import org.apache.deltaspike.core.api.config.ConfigProperty;
import org.ndx.aadarchi.base.AgileArchitectureException;
import org.ndx.aadarchi.base.ModelEnhancer;
import org.ndx.aadarchi.base.OutputBuilder;
import org.ndx.aadarchi.base.ViewEnhancer;
import org.ndx.aadarchi.cdi.deltaspike.ConfigProperty;

import com.structurizr.Workspace;
import com.structurizr.model.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.inject.Inject;
import jakarta.inject.Inject;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.vfs2.FileExtensionSelector;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.deltaspike.core.api.config.ConfigProperty;
import org.ndx.aadarchi.base.AgileArchitectureSection;
import org.ndx.aadarchi.base.ModelEnhancer;
import org.ndx.aadarchi.base.OutputBuilder;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys.ConfigProperties.EnhancementsDir;
import org.ndx.aadarchi.base.utils.CantToResolvePath;
import org.ndx.aadarchi.base.utils.StructurizrUtils;
import org.ndx.aadarchi.cdi.deltaspike.ConfigProperty;

import com.structurizr.Workspace;
import com.structurizr.model.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;

import javax.inject.Inject;
import jakarta.inject.Inject;

import org.apache.commons.text.similarity.LevenshteinDistance;
import org.ndx.aadarchi.base.OutputBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
import java.nio.charset.Charset;
import java.util.logging.Logger;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import org.apache.commons.io.IOUtils;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.deltaspike.core.api.config.ConfigProperty;
import org.ndx.aadarchi.base.OutputBuilder;
import org.ndx.aadarchi.base.ViewEnhancer;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys.ConfigProperties.DiagramsDir;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys.ConfigProperties.Force;
import org.ndx.aadarchi.base.utils.CantToResolvePath;
import org.ndx.aadarchi.cdi.deltaspike.ConfigProperty;

import com.structurizr.Workspace;
import com.structurizr.annotation.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.ndx.aadarchi.base.enhancers.ModelElementKeys;
import org.ndx.aadarchi.base.enhancers.ViewEnhancerAdapter;

import javax.inject.Inject;
import jakarta.inject.Inject;
import java.util.logging.Logger;

public class ViewUpdater extends ViewEnhancerAdapter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
import java.io.IOException;
import java.nio.file.Path;

import javax.inject.Inject;
import jakarta.inject.Inject;

import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.deltaspike.core.api.config.ConfigProperty;
import org.ndx.aadarchi.base.AgileArchitectureSection;
import org.ndx.aadarchi.base.OutputBuilder;
import org.ndx.aadarchi.base.enhancers.ModelElementAdapter;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys.ConfigProperties.AsciidocSourceDir;
import org.ndx.aadarchi.base.utils.CantAccessPath;
import org.ndx.aadarchi.base.utils.SimpleOutputBuilder;
import org.ndx.aadarchi.base.utils.StructurizrUtils;
import org.ndx.aadarchi.cdi.deltaspike.ConfigProperty;

import com.structurizr.annotation.Component;
import com.structurizr.model.Element;
Expand Down
Loading

0 comments on commit 1ed5528

Please sign in to comment.