Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Init): Init Branch + toolchain plugin java version 17 #371

Merged
merged 16 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 11
java-version: 17
cache: 'maven'
- name: Build with Maven
run: mvn -B test --file pom.xml -Pcoverage -Daadarchi.github.token="$TOKEN_FOR_GITHUB" -Daadarchi.gitlab.token="$TOKEN_FOR_GITLAB"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/on_push_on_master_deploy_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 11
java-version: 17
cache: 'maven'
- name: Build with Maven
run: mvn -B install --file pom.xml -Daadarchi.github.token="$TOKEN_FOR_GITHUB" -Daadarchi.gitlab.token="$TOKEN_FOR_GITLAB"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
run: |
git config --global user.email "aadarchi-releaser-bot@users.noreply.github.com"
git config --global user.name "🤖 Aadarchi releaser bot"
- name: Set up JDK 11
uses: actions/setup-java@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
cache: maven
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
Expand Down
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
Loading
Loading