com.intershop.gradle.icm.extension.ProjectConfiguration.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of icm-gradle-plugin Show documentation
Show all versions of icm-gradle-plugin Show documentation
Intershop Commerce Management Plugins
/*
* Copyright 2019 Intershop Communications AG.
*
* 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 com.intershop.gradle.icm.extension
import com.intershop.gradle.icm.project.TargetConf
import groovy.lang.Closure
import org.gradle.api.Action
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.file.ProjectLayout
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.util.ConfigureUtil
import java.io.File
import javax.inject.Inject
/**
* Extension of an Intershop ICM project.
*
* @constructor creates the extension of a project configuration.
*/
open class ProjectConfiguration @Inject constructor(objectFactory: ObjectFactory, projectLayout: ProjectLayout) {
val containerConfig: File = TargetConf.PRODUCTION.config(projectLayout).get().asFile
val testcontainerConfig: File = TargetConf.TEST.config(projectLayout).get().asFile
val containerSites: File = TargetConf.PRODUCTION.sites(projectLayout).get().asFile
val testcontainerSites: File = TargetConf.TEST.sites(projectLayout).get().asFile
val config: File = TargetConf.DEVELOPMENT.config(projectLayout).get().asFile
val sites: File = TargetConf.DEVELOPMENT.sites(projectLayout).get().asFile
val newBaseProject: Property = objectFactory.property(Boolean::class.java)
/**
* Base project configuration for final project.
*
* @property base
*/
val base: CartridgeProject = objectFactory.newInstance(CartridgeProject::class.java)
/**
* Configures a binary base project (This is also connected to
* a Docker image.).
*
* @param action Action to configure Cartridge project (ICM)
*/
fun base(action: Action) {
action.execute(base)
}
/**
* Configures a binary base project (This is also connected to
* a Docker image.).
*
* @param c Closure to configure Cartridge project (ICM)
*/
fun base(c: Closure) {
ConfigureUtil.configure(c, base)
}
val modules: NamedDomainObjectContainer =
objectFactory.domainObjectContainer(NamedCartridgeProject::class.java)
val cartridgeListDependency: Property = objectFactory.property(String::class.java)
val libFilterFileDependency: Property = objectFactory.property(String::class.java)
/**
* Cartridges of this project.
*
* @property cartridges
*/
val cartridges: SetProperty = objectFactory.setProperty(String::class.java)
/**
* Add a single cartridge to the list.
*
* @param cartridge name of an ICM cartridge
*/
fun cartridge(cartridge: String) {
cartridges.add(cartridge)
}
/**
* Cartridges of this project.
*
* @property dbprepareCartridges
*/
var dbprepareCartridges: SetProperty = objectFactory.setProperty(String::class.java)
/**
* Add a single cartridge to the list of dbprepare cartridges.
*
* @param cartridge name of an ICM cartridge
*/
fun dbprepareCartridge(cartridge: String) {
dbprepareCartridges.add(cartridge)
}
val serverDirConfig: ProjectServerDirs = objectFactory.newInstance(ProjectServerDirs::class.java)
/**
* Configures the directory configuration of the project.
*
* @param action Action to configure project server dirs
*/
fun serverDirConfig(action: Action) {
action.execute(serverDirConfig)
}
/**
* Configures the directory configuration of the project.
*
* @param c Closure to configure project server dirs
*/
fun serverDirConfig(c: Closure) {
ConfigureUtil.configure(c, serverDirConfig)
}
init {
newBaseProject.set(false)
serverDirConfig.base.config.dirs.register("main") {
it.dir.convention( projectLayout.projectDirectory.dir("config/base") )
}
serverDirConfig.base.sites.dirs.register("main") {
it.dir.convention(projectLayout.projectDirectory.dir("sites/base"))
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy