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

Remove Site API options #35

Merged
merged 7 commits into from
Nov 27, 2023
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
3 changes: 3 additions & 0 deletions changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<action type="update" dev="sseifert">
Update dependencies.
</action>
<action type="update" dev="sseifert">
Remove Site API options.
</action>
</release>

<release version="3.8.4" date="2023-09-08">
Expand Down
63 changes: 4 additions & 59 deletions src/main/resources/META-INF/archetype-post-generate.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import groovy.util.XmlSlurper

def rootDir = new File(request.getOutputDirectory() + "/" + request.getArtifactId())
def javaPackage = request.getProperties().get("package")
def javaPackagePath = javaPackage.replace('.','/')
def optionAemVersion = request.getProperties().get("optionAemVersion")
def optionAemServicePack = request.getProperties().get("optionAemServicePack")
def optionAemServicePackAPI = request.getProperties().get("optionAemServicePackAPI")
Expand All @@ -16,13 +15,10 @@ def optionEditableTemplates = request.getProperties().get("optionEditableTemplat
def optionMultiBundleLayout = request.getProperties().get("optionMultiBundleLayout")
def optionContextAwareConfig = request.getProperties().get("optionContextAwareConfig")
def optionWcmioHandler = request.getProperties().get("optionWcmioHandler")
def optionWcmioSiteApi = request.getProperties().get("optionWcmioSiteApi")
def optionWcmioSiteApiGenericEdit = request.getProperties().get("optionWcmioSiteApiGenericEdit")
def optionIntegrationTests = request.getProperties().get("optionIntegrationTests")

def coreBundle = new File(rootDir, "bundles/core")
def clientlibsBundle = new File(rootDir, "bundles/clientlibs")
def siteApiSpecBundle = new File(rootDir, "bundles/site-api-spec")
def completeContentPackage = new File(rootDir, "content-packages/complete")
def confContentPackage = new File(rootDir, "content-packages/conf-content")
def sampleContentPackage = new File(rootDir, "content-packages/sample-content")
Expand All @@ -32,7 +28,6 @@ def frontend = new File(rootDir, "frontend")
def rootPom = new File(rootDir, "pom.xml")
def parentPom = new File(rootDir, "parent/pom.xml")
def tests = new File(rootDir, "tests")
def integrationTests = new File(rootDir, "tests/integration")

// validate parameters - throw exceptions for invalid combinations
if ((optionAemServicePack=="y" || optionAemServicePackAPI=="y") && optionAemVersion == "cloud") {
Expand All @@ -50,15 +45,6 @@ if (optionWcmioHandler == "y" && optionContextAwareConfig == "n") {
if (optionEditableTemplates == "n" && optionWcmioHandler == "n") {
throw new RuntimeException("You have to specify either parameter optionEditableTemplates='y' or optionWcmioHandler='y'.")
}
if (optionWcmioSiteApi == "y" && optionWcmioHandler == "n") {
throw new RuntimeException("Parameter optionSiteApi='y' is only supported with optionWcmioHandler='y'.")
}
if (optionWcmioSiteApiGenericEdit == "y" && optionWcmioSiteApi == "n") {
throw new RuntimeException("Parameter optionWcmioSiteApiGenericEdit='y' is only supported with optionWcmioSiteApi='y'.")
}
if (optionWcmioSiteApiGenericEdit == "y" && optionFrontend == "y") {
throw new RuntimeException("Parameter optionWcmioSiteApiGenericEdit='y' is not allowed together with optionFrontend='y'.")
}
if (!(javaPackage ==~ /^[a-z0-9\.]+$/)) {
throw new RuntimeException("Java package name is invalid: " + javaPackage)
}
Expand Down Expand Up @@ -94,26 +80,18 @@ else {
// remove frontend module entry from root pom
removeModule(rootPom, "frontend")
}
if (optionWcmioSiteApiGenericEdit == "y") {
assert clientlibsBundle.deleteDir()
assert new File(uiAppsPackage, "jcr_root/apps/${projectName}/clientlibs").deleteDir()
// remove bundles/clientlibs module entry from root pom
removeModule(rootPom, "bundles/clientlibs")
}

// remove files only relevant for wcm.io Handler projects
if (optionWcmioHandler == "n") {
assert new File(coreBundle, "src/main/java/${javaPackagePath}/config").deleteDir()
assert new File(coreBundle, "src/main/java/" + javaPackage.replace('.','/') + "/config").deleteDir()

assert new File(coreBundle, "src/main/webapp/app-root/templates/admin/redirect").deleteDir()
assert new File(coreBundle, "src/main/webapp/app-root/templates/admin/redirect.json").delete()
assert new File(coreBundle, "src/main/webapp/app-root/components/admin/page/redirect.json").delete()
assert new File(coreBundle, "src/main/webapp/app-root/components/content/responsiveimage.json").delete()

if (optionWcmioSiteApiGenericEdit == "n") {
assert new File(clientlibsBundle, "src/main/webapp/clientlibs-root/${projectName}.app/css").deleteDir()
assert new File(uiAppsPackage, "jcr_root/apps/${projectName}/clientlibs/${projectName}.app/css").deleteDir()
}
assert new File(clientlibsBundle, "src/main/webapp/clientlibs-root/${projectName}.app/css").deleteDir()
assert new File(uiAppsPackage, "jcr_root/apps/${projectName}/clientlibs/${projectName}.app/css").deleteDir()

if (optionFrontend == "y") {
assert new File(frontend, "src/components/customcarousel/customcarousel.scss").delete()
Expand All @@ -132,24 +110,8 @@ else {
assert new File(uiAppsPackage, "jcr_root/apps/${projectName}/core/components/admin/page/structureElement/structureElement.html").delete()
}

// remove empty component HTL files
[
new File(coreBundle, "src/main/webapp/app-root/components"),
new File(uiAppsPackage, "jcr_root/apps/${projectName}/core/component")
].each { componentsFolder ->
if (componentsFolder.exists()) {
componentsFolder.eachFileRecurse(FileType.FILES) { file ->
if (file.name =~ /\.html$/) {
if (file.getText("UTF-8").empty) {
assert file.delete()
}
}
}
}
}

// refactor project layout when multi bundle layout is switched off
if (optionMultiBundleLayout == "n" && optionWcmioSiteApiGenericEdit == "n") {
if (optionMultiBundleLayout == "n") {
// move .gitignore for clientlibs-root
if (optionFrontend == "y") {
assert new File(clientlibsBundle, ".gitignore").renameTo(new File(coreBundle, ".gitignore"))
Expand Down Expand Up @@ -262,27 +224,10 @@ else {
assert new File(configDefinition, "src/main/environments/cloud.yaml").delete()
}

if (optionWcmioSiteApi == "n") {
assert new File(coreBundle, "src/main/java/${javaPackagePath}/reference").deleteDir()
assert new File(coreBundle, "src/test/java/${javaPackagePath}/reference").deleteDir()
removeModule(rootPom, "bundles/site-api-spec")
siteApiSpecBundle.deleteDir()
}

if (optionIntegrationTests == "n") {
removeModule(rootPom, "tests/integration")
tests.deleteDir()
}
else if (optionWcmioSiteApi == "y") {
// remove non-Site API integration test code
assert new File(integrationTests, "src/main/java/${javaPackagePath}/it/components").deleteDir()
assert new File(integrationTests, "src/main/java/${javaPackagePath}/it/rules").deleteDir()
assert new File(integrationTests, "src/main/java/${javaPackagePath}/it/tests").deleteDir()
}
else {
// remove Site API integration test code
assert new File(integrationTests, "src/main/java/${javaPackagePath}/it/siteapi").deleteDir()
}


// convert all line endings to unix-style
Expand Down
38 changes: 0 additions & 38 deletions src/main/resources/META-INF/maven/archetype-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,6 @@
<defaultValue>n</defaultValue>
<validationRegex>^(y|n)$</validationRegex>
</requiredProperty>
<!-- Setup AEM headless project based on wcm.io Site API. Requires optionWcmioHandler='y'. -->
<requiredProperty key="optionWcmioSiteApi">
<defaultValue>n</defaultValue>
<validationRegex>^(y|n)$</validationRegex>
</requiredProperty>
<!-- Setup AEM headless project based on wcm.io Site API Generic Edit. Requires optionWcmioHandler='y' and optionWcmioSiteApi='y'. -->
<requiredProperty key="optionWcmioSiteApiGenericEdit">
<defaultValue>n</defaultValue>
<validationRegex>^(y|n)$</validationRegex>
</requiredProperty>
<!-- Use latest Sling Models versions (ignored for AEMaaCS) -->
<requiredProperty key="optionSlingModelsLatest">
<defaultValue>n</defaultValue>
Expand Down Expand Up @@ -272,33 +262,6 @@
</fileSets>
</module>

<module id="${rootArtifactId}.site-api-spec" dir="bundles/site-api-spec" name="${rootArtifactId}.site-api-spec">
<fileSets>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/spec</directory>
<includes>
<include>**/*.yaml</include>
</includes>
</fileSet>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/test/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet encoding="UTF-8">
<directory></directory>
<includes>
<include>index.html</include>
<include>package.json</include>
<include>README.md</include>
<include>webpack.config.js</include>
<include>src/index.js</include>
</includes>
</fileSet>
</fileSets>
</module>

<module id="${rootArtifactId}.ui.apps" dir="content-packages/ui.apps" name="${rootArtifactId}.ui.apps">
<fileSets>
<fileSet filtered="true" encoding="UTF-8">
Expand Down Expand Up @@ -443,7 +406,6 @@
<directory></directory>
<includes>
<include>README.md</include>
<include>run-integration-tests-locally.sh</include>
</includes>
</fileSet>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ optionContextAwareConfig=${optionContextAwareConfig}
optionFrontend=${optionFrontend}
optionNodeJsPlugin=${optionNodeJsPlugin}
optionWcmioHandler=${optionWcmioHandler}
optionWcmioSiteApi=${optionWcmioSiteApi}
optionAcsCommons=${optionAcsCommons}
optionIntegrationTests=${optionIntegrationTests}
50 changes: 0 additions & 50 deletions src/main/resources/archetype-resources/bundles/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,6 @@
<artifactId>io.wcm.wcm.ui.clientlibs</artifactId>
<scope>compile</scope>
</dependency>
#if ( $optionWcmioSiteApi == "y" )
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.site-api.processor</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.site-api.handler</artifactId>
<scope>compile</scope>
</dependency>
#end
#if ( $optionWcmioSiteApiGenericEdit == "y" )
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.site-api.generic-edit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.site-api.generic-edit.handler</artifactId>
<scope>compile</scope>
</dependency>
#end

#end
<dependency>
Expand Down Expand Up @@ -204,37 +180,11 @@
<artifactId>io.wcm.testing.wcm-io-mock.wcm</artifactId>
<scope>test</scope>
</dependency>
#if ( $optionWcmioSiteApi == "y" )
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.site-api.processor</artifactId>
<scope>test</scope>
</dependency>
#end
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.handler</artifactId>
<scope>test</scope>
</dependency>
#if ( $optionWcmioSiteApi == "y" )
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.site-api.handler</artifactId>
<scope>test</scope>
</dependency>
#end
#if ( $optionWcmioSiteApiGenericEdit == "y" )
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.site-api.generic-edit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.site-api.generic-edit.handler</artifactId>
<scope>test</scope>
</dependency>
#end
#end

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,12 @@

import com.day.cq.wcm.api.Page;

#if ( $optionWcmioSiteApi == "y" )
import io.wcm.handler.link.markup.SimpleLinkMarkupBuilder;
#end
import io.wcm.handler.link.spi.LinkHandlerConfig;
#if ( $optionWcmioSiteApi == "y" )
import io.wcm.handler.link.spi.LinkMarkupBuilder;
import io.wcm.handler.link.spi.LinkProcessor;
#end
import io.wcm.handler.link.spi.LinkType;
import io.wcm.handler.link.type.ExternalLinkType;
import io.wcm.handler.link.type.InternalCrossContextLinkType;
import io.wcm.handler.link.type.InternalLinkType;
import io.wcm.handler.link.type.MediaLinkType;
#if ( $optionWcmioSiteApi == "y" )
import io.wcm.siteapi.handler.link.SiteApiLinkMarkupBuilder;
import io.wcm.siteapi.handler.link.SiteApiLinkPreProcessor;
#end
import io.wcm.wcm.commons.util.Template;

import ${package}.config.AppTemplate;
Expand All @@ -45,35 +34,12 @@ public class LinkHandlerConfigImpl extends LinkHandlerConfig {
ExternalLinkType.class,
MediaLinkType.class);

#if ( $optionWcmioSiteApi == "y" )
private static final List<Class<? extends LinkProcessor>> PRE_PROCESSORS = List.of(
SiteApiLinkPreProcessor.class);

private static final List<Class<? extends LinkMarkupBuilder>> LINK_MARKUP_BUILDERS = List.of(
SiteApiLinkMarkupBuilder.class,
SimpleLinkMarkupBuilder.class);

#end
@Override
@SuppressWarnings("squid:S2384") // returned list is immutable
public @NotNull List<Class<? extends LinkType>> getLinkTypes() {
return LINK_TYPES;
}

#if ( $optionWcmioSiteApi == "y" )
@Override
@SuppressWarnings("squid:S2384") // returned list is immutable
public @NotNull List<Class<? extends LinkProcessor>> getPreProcessors() {
return PRE_PROCESSORS;
}

@Override
@SuppressWarnings("squid:S2384") // returned list is immutable
public @NotNull List<Class<? extends LinkMarkupBuilder>> getMarkupBuilders() {
return LINK_MARKUP_BUILDERS;
}

#end
@Override
public boolean isValidLinkTarget(@NotNull Page page) {
return !Template.is(page, AppTemplate.ADMIN_STRUCTURE_ELEMENT);
Expand Down

This file was deleted.

Loading