-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from ia3andy/refactor
Refactor
- Loading branch information
Showing
42 changed files
with
399 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 0 additions & 88 deletions
88
...-deployment/src/main/java/io/quarkiverse/roq/deployment/config/RoqProjectDirectories.java
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
...deployment/src/main/java/io/quarkiverse/roq/generator/deployment/RoqProjectProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package io.quarkiverse.roq.generator.deployment; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import io.quarkiverse.roq.generator.deployment.config.RoqBuildConfig; | ||
import io.quarkiverse.roq.generator.deployment.items.RoqProjectBuildItem; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem; | ||
|
||
public class RoqProjectProcessor { | ||
|
||
private static final Logger LOG = Logger.getLogger(RoqProjectProcessor.class); | ||
|
||
@BuildStep | ||
RoqProjectBuildItem findProject(RoqBuildConfig config, OutputTargetBuildItem outputTarget) { | ||
return new RoqProjectBuildItem(resolveProjectDirs(config, outputTarget)); | ||
} | ||
|
||
/** | ||
* Resolves the project directories based on the provided configuration and output target. | ||
* | ||
* @param config the build configuration | ||
* @param outputTarget the output target build item | ||
* @return a {@link RoqProjectBuildItem.RoqProject} object containing the resolved project root, site root, and data root | ||
* directories, or {@code null} if the site root directory is not found | ||
* @throws IllegalStateException if the project root is not found and the site directory is not absolute | ||
*/ | ||
private static RoqProjectBuildItem.RoqProject resolveProjectDirs(RoqBuildConfig config, | ||
OutputTargetBuildItem outputTarget) { | ||
Path projectRoot = findProjectRoot(outputTarget.getOutputDirectory()); | ||
Path configuredSiteDirPath = Paths.get(config.siteDir().trim()); | ||
|
||
if (projectRoot == null || !Files.isDirectory(projectRoot)) { | ||
if (configuredSiteDirPath.isAbsolute() && Files.isDirectory(configuredSiteDirPath)) { | ||
configuredSiteDirPath = configuredSiteDirPath.normalize(); | ||
} else { | ||
throw new IllegalStateException( | ||
"If not absolute, the Site directory is resolved relative to the project root, but Roq was not able to find the project root."); | ||
} | ||
} | ||
|
||
final Path siteRoot = projectRoot.resolve(configuredSiteDirPath).normalize(); | ||
|
||
if (!Files.isDirectory(siteRoot)) { | ||
LOG.warnf( | ||
"Roq directory not found 'quarkus.roq.site-dir=%s' resolved to '%s'. It is recommended to remove the quarkus-roq extension if not used.", | ||
config.siteDir(), siteRoot.toAbsolutePath()); | ||
return null; | ||
} | ||
|
||
return new RoqProjectBuildItem.RoqProject(projectRoot, siteRoot); | ||
} | ||
|
||
private static Path findProjectRoot(Path outputDirectory) { | ||
Path currentPath = outputDirectory; | ||
do { | ||
if (Files.exists(currentPath.resolve(Paths.get("src", "main"))) | ||
|| Files.exists(currentPath.resolve(Paths.get("config", "application.properties"))) | ||
|| Files.exists(currentPath.resolve(Paths.get("config", "application.yaml"))) | ||
|| Files.exists(currentPath.resolve(Paths.get("config", "application.yml")))) { | ||
return currentPath.normalize(); | ||
} | ||
if (currentPath.getParent() != null && Files.exists(currentPath.getParent())) { | ||
currentPath = currentPath.getParent(); | ||
} else { | ||
return null; | ||
} | ||
} while (true); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ment/src/main/java/io/quarkiverse/roq/generator/deployment/items/RoqProjectBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.quarkiverse.roq.generator.deployment.items; | ||
|
||
import java.nio.file.Path; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
|
||
public final class RoqProjectBuildItem extends SimpleBuildItem { | ||
private final RoqProject project; | ||
|
||
public RoqProjectBuildItem(RoqProject project) { | ||
this.project = project; | ||
} | ||
|
||
public RoqProject dirs() { | ||
return project; | ||
} | ||
|
||
// TODO: in the future we might want to include a Scanner like in web-bundler to see if dependencies contains roq stuff | ||
|
||
/** | ||
* Container to store resolved directory locations. | ||
*/ | ||
public record RoqProject( | ||
/** | ||
* The root directory of the project | ||
*/ | ||
Path rootDir, | ||
/** | ||
* The site directory of the project defaults to /src/main/site | ||
*/ | ||
Path siteDir) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.quarkiverse.roq</groupId> | ||
<artifactId>quarkus-roq-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>quarkus-roq-common</artifactId> | ||
<name>Quarkus Roq - Common</name> | ||
</project> |
2 changes: 1 addition & 1 deletion
2
...arkiverse/roq/runtime/util/PathUtils.java → ...va/io/quarkiverse/roq/util/PathUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package io.quarkiverse.roq.runtime.util; | ||
package io.quarkiverse.roq.util; | ||
|
||
public final class PathUtils { | ||
|
||
|
107 changes: 0 additions & 107 deletions
107
deployment/src/main/java/io/quarkiverse/roq/deployment/RoqProcessor.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
deployment/src/test/java/io/quarkiverse/roq/test/RoqDevModeTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.