com.liferay.gradle.plugins.service.builder.BuildServiceTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.gradle.plugins.service.builder Show documentation
Show all versions of com.liferay.gradle.plugins.service.builder Show documentation
The Service Builder Gradle plugin lets you generate a Liferay service layer defined in a Service Builder service.xml file.
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.gradle.plugins.service.builder;
import com.liferay.gradle.util.FileUtil;
import com.liferay.gradle.util.GUtil;
import com.liferay.gradle.util.GradleUtil;
import com.liferay.gradle.util.Validator;
import com.liferay.portal.tools.service.builder.ServiceBuilderArgs;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.gradle.api.JavaVersion;
import org.gradle.api.Project;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.CacheableTask;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputDirectory;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.JavaExec;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.util.CollectionUtils;
/**
* @author Andrea Di Giorgi
*/
@CacheableTask
public class BuildServiceTask extends JavaExec {
public BuildServiceTask() {
Property mainClass = getMainClass();
mainClass.set(
"com.liferay.portal.tools.service.builder.ServiceBuilder");
modelHintsConfigs((Object[])ServiceBuilderArgs.MODEL_HINTS_CONFIGS);
readOnlyPrefixes((Object[])ServiceBuilderArgs.READ_ONLY_PREFIXES);
resourceActionsConfigs(
(Object[])ServiceBuilderArgs.RESOURCE_ACTION_CONFIGS);
springNamespaces("beans");
systemProperty("file.encoding", StandardCharsets.UTF_8.name());
}
@Override
public void exec() {
setArgs(getCompleteArgs());
super.exec();
}
@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
public File getApiDir() {
File file = GradleUtil.toFile(getProject(), _apiDir);
if (!file.exists()) {
file.mkdirs();
}
return file;
}
@Input
public String getBeanLocatorUtil() {
return GradleUtil.toString(_beanLocatorUtil);
}
@Input
public long getBuildNumber() {
return _buildNumber;
}
@Input
public int getDatabaseNameMaxLength() {
return _databaseNameMaxLength;
}
@InputFile
@Optional
@PathSensitive(PathSensitivity.RELATIVE)
public File getHbmFile() {
File file = GradleUtil.toFile(getProject(), _hbmFile);
if (!file.exists()) {
return null;
}
return file;
}
@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
public File getImplDir() {
File file = GradleUtil.toFile(getProject(), _implDir);
if (!file.exists()) {
file.mkdirs();
}
return file;
}
@Input
@Optional
public Set getIncubationFeatures() {
return _incubationFeatures;
}
@InputFile
@PathSensitive(PathSensitivity.RELATIVE)
public File getInputFile() {
return GradleUtil.toFile(getProject(), _inputFile);
}
@Override
public List getJvmArgs() {
List jvmArgs = new ArrayList<>();
JavaVersion javaVersion = getJavaVersion();
if (javaVersion.isJava9Compatible()) {
jvmArgs.add("--illegal-access=permit");
}
return jvmArgs;
}
@Input
public List getModelHintsConfigs() {
return GradleUtil.toStringList(_modelHintsConfigs);
}
@InputFile
@Optional
@PathSensitive(PathSensitivity.RELATIVE)
public File getModelHintsFile() {
File file = GradleUtil.toFile(getProject(), _modelHintsFile);
if (!file.exists()) {
return null;
}
return file;
}
@Input
public String getPluginName() {
return GradleUtil.toString(_pluginName);
}
@Input
public String getPropsUtil() {
return GradleUtil.toString(_propsUtil);
}
@Input
public List getReadOnlyPrefixes() {
return GradleUtil.toStringList(_readOnlyPrefixes);
}
@Input
public List getResourceActionsConfigs() {
return GradleUtil.toStringList(_resourceActionsConfigs);
}
@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
public File getResourcesDir() {
File file = GradleUtil.toFile(getProject(), _resourcesDir);
if (!file.exists()) {
file.mkdirs();
}
return file;
}
@InputFile
@Optional
@PathSensitive(PathSensitivity.RELATIVE)
public File getSpringFile() {
File file = GradleUtil.toFile(getProject(), _springFile);
if (!file.exists()) {
return null;
}
return file;
}
@Input
public List getSpringNamespaces() {
return GradleUtil.toStringList(_springNamespaces);
}
@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
public File getSqlDir() {
File file = GradleUtil.toFile(getProject(), _sqlDir);
if (!file.exists()) {
file.mkdirs();
}
return file;
}
@Input
public String getSqlFileName() {
return GradleUtil.toString(_sqlFileName);
}
@Input
public String getSqlIndexesFileName() {
return GradleUtil.toString(_sqlIndexesFileName);
}
@Input
public String getSqlSequencesFileName() {
return GradleUtil.toString(_sqlSequencesFileName);
}
@Input
@Optional
public String getTargetEntityName() {
return GradleUtil.toString(_targetEntityName);
}
@InputDirectory
@Optional
@PathSensitive(PathSensitivity.RELATIVE)
public File getTestDir() {
if (_testDir == null) {
return null;
}
File file = GradleUtil.toFile(getProject(), _testDir);
if (!file.exists()) {
file.mkdirs();
}
return file;
}
@InputDirectory
@Optional
@PathSensitive(PathSensitivity.RELATIVE)
public File getUADDir() {
if (_uadDir == null) {
return null;
}
File file = GradleUtil.toFile(getProject(), _uadDir);
if (!file.exists()) {
file.mkdirs();
}
return file;
}
@InputDirectory
@Optional
@PathSensitive(PathSensitivity.RELATIVE)
public File getUADTestIntegrationDir() {
if (_uadTestIntegrationDir == null) {
return null;
}
File file = GradleUtil.toFile(getProject(), _uadTestIntegrationDir);
if (!file.exists()) {
file.mkdirs();
}
return file;
}
public BuildServiceTask incubationFeatures(
Iterable incubationFeatures) {
GUtil.addToCollection(_incubationFeatures, incubationFeatures);
return this;
}
public BuildServiceTask incubationFeatures(String... incubationFeatures) {
return incubationFeatures(Arrays.asList(incubationFeatures));
}
@Input
public boolean isAutoImportDefaultReferences() {
return _autoImportDefaultReferences;
}
@Input
public boolean isAutoNamespaceTables() {
return _autoNamespaceTables;
}
@Input
public boolean isBuildNumberIncrement() {
return _buildNumberIncrement;
}
@Input
public boolean isOsgiModule() {
return _osgiModule;
}
public BuildServiceTask modelHintsConfigs(
Iterable
© 2015 - 2024 Weber Informatics LLC | Privacy Policy