com.intershop.gradle.icm.tasks.crossproject.PrepareSitesFolder.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 2021 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.tasks.crossproject
import com.intershop.gradle.icm.CrossProjectDevelopmentPlugin.Companion.CROSSPRJ_FOLDERPATH
import com.intershop.gradle.icm.tasks.CreateSitesFolder
import com.intershop.gradle.icm.utils.PackageUtil
import org.gradle.api.file.CopySpec
import org.gradle.api.file.Directory
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.file.ProjectLayout
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import java.io.File
import javax.inject.Inject
open class PrepareSitesFolder
@Inject constructor(projectLayout: ProjectLayout,
objectFactory: ObjectFactory,
fsOps: FileSystemOperations): CreateSitesFolder(projectLayout, objectFactory, fsOps) {
init {
outputDir.set(File(project.projectDir, "${CROSSPRJ_FOLDERPATH}/storefront/sites"))
}
fun provideMainBaseDir(baseDir: Provider) = mainBaseDir.set(baseDir)
@get:InputDirectory
val mainBaseDir: DirectoryProperty = objectFactory.directoryProperty()
fun provideModuleDirectories(moduleDirMap: Provider>) = moduleDirectories.set(moduleDirMap)
@get:Input
val moduleDirectories: MapProperty = objectFactory.mapProperty(String::class.java, File::class.java)
override fun addPackages(cs: CopySpec) {
PackageUtil.addPackageToCS(
project = project,
dependency = baseProject.get().dependency.get(),
classifier = "sites",
copySpec = cs,
filePackage = baseProject.get().sitesPackage,
excludes = listOf(),
fileBase = mainBaseDir.get().asFile)
modules.get().forEach { prj ->
val dep = prj.dependency.get()
var key = ""
if(dep.isNotBlank()) {
val depList = dep.split(":")
key = if(depList.size > 1) { "${depList[0]}_${depList[1]}" } else { "" }
}
val dir = if(key.isNotBlank()) { moduleDirectories.get().get(key) } else { null }
PackageUtil.addPackageToCS(
project = project,
dependency = prj.dependency.get(),
classifier = "sites",
copySpec = cs,
filePackage = prj.sitesPackage,
excludes = listOf(),
fileBase = dir)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy