Skip to content

Commit

Permalink
Remove gradle usage from build.
Browse files Browse the repository at this point in the history
  • Loading branch information
shuyangzhou committed Oct 4, 2023
1 parent b8a3fe1 commit dc27a53
Show file tree
Hide file tree
Showing 8 changed files with 517 additions and 239 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/private/*
.gradle
.m2-cache

build-ext.properties
11 changes: 1 addition & 10 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,8 @@ project.dir=portal

ignored.dirs=.git,.gradle,build,node_modules,portal-compat,sample,support-websphere,tmp,tools,.releng

display.gradle.process.output=false

jpda.settings=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y

group.stop.words=third-party,modules

include.generated.jsp.servlet=false

#Please provide comma separated path of excluded module relative to liferay-portal/modules
#Example: gradle.build.exclude.dirs=apps/collaboration/blogs,apps/foundation/portal-search
gradle.build.exclude.dirs=sdk/project-templates
gradle.build.exclude.dirs=

gradle.opts=-Xmx3g
include.generated.jsp.servlet=false
78 changes: 0 additions & 78 deletions dependency.gradle

This file was deleted.

6 changes: 3 additions & 3 deletions portal-module-dependency.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#Add modules as dependency to other modules
petra.modules=petra-concurrent,petra-executor,petra-function,petra-io,petra-lang,petra-memory,petra-nio,petra-process,petra-reflect,petra-sql-dsl-api,petra-sql-dsl-spi,petra-string,osgi-service-tracker-collections
portal-impl=portal-kernel,util-bridges,util-java,util-taglib,petra-content,petra-log4j,petra-encryptor,petra-mail,petra-xml,petra-portlet-url-builder,petra-url-pattern-mapper
portal-impl=portal-kernel,util-bridges,util-java,util-taglib
portal-kernel=osgi-service-tracker-collections
portal-test=portal-impl,portal-kernel,petra-log4j
portal-test=portal-impl,portal-kernel
support-tomcat=portal-kernel
util-bridges=portal-kernel
util-java=portal-kernel,portal-test
util-taglib=portal-kernel,util-java,petra-encryptor
util-taglib=portal-kernel,util-java
util-slf4j=portal-kernel
31 changes: 8 additions & 23 deletions src/com/liferay/netbeansproject/ProjectBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.liferay.netbeansproject.container.Module;
import com.liferay.netbeansproject.util.FileUtil;
import com.liferay.netbeansproject.util.GradleUtil;
import com.liferay.netbeansproject.util.MavenUtil;
import com.liferay.netbeansproject.util.ModuleUtil;
import com.liferay.netbeansproject.util.PropertiesUtil;
import com.liferay.netbeansproject.util.StringUtil;
Expand Down Expand Up @@ -56,26 +57,20 @@ public static void main(String[] args) throws Exception {
Path projectDirPath = Paths.get(
PropertiesUtil.getRequiredProperty(buildProperties, "project.dir"));

boolean displayGradleProcessOutput = Boolean.valueOf(
buildProperties.getProperty("display.gradle.process.output"));

String ignoredDirs = PropertiesUtil.getRequiredProperty(
buildProperties, "ignored.dirs");

boolean includeJsps = Boolean.valueOf(
PropertiesUtil.getRequiredProperty(
buildProperties, "include.generated.jsp.servlet"));

String gradleBuildExcludeDirs = buildProperties.getProperty(
"gradle.build.exclude.dirs");

String gradleOpts = buildProperties.getProperty("gradle.opts");

ProjectBuilder projectBuilder = new ProjectBuilder();

for (String portalDir : portalDirs) {
Path portalDirPath = Paths.get(portalDir);

MavenUtil.buildCache(portalDirPath, buildProperties);

Properties appServerProperties = new Properties();

Path trunkPath = null;
Expand All @@ -90,18 +85,15 @@ public static void main(String[] args) throws Exception {

projectBuilder.scanPortal(
projectDirPath.resolve(portalDirPath.getFileName()),
portalDirPath, displayGradleProcessOutput, ignoredDirs,
trunkPath,
portalDirPath, ignoredDirs, trunkPath,
appServerProperties.getProperty("app.server.tomcat.version"),
includeJsps, gradleBuildExcludeDirs, gradleOpts);
includeJsps);
}
}

public void scanPortal(
final Path projectPath, Path portalPath,
final boolean displayGradleProcessOutput, String ignoredDirs,
Path trunkPath, String tomcatVersion, boolean includeJsps,
String gradleBuildExcludeDirs, String gradleOpts)
final Path projectPath, Path portalPath, String ignoredDirs,
Path trunkPath, String tomcatVersion, boolean includeJsps)
throws Exception {

final Set<String> ignoredDirSet = new HashSet<>(
Expand Down Expand Up @@ -170,20 +162,13 @@ public FileVisitResult preVisitDirectory(

FileUtil.delete(projectPath);

Map<String, Set<Dependency>> jarDependenciesMap =
GradleUtil.getJarDependencies(
portalPath, portalPath.resolve("modules"),
moduleProjectPaths.keySet(), displayGradleProcessOutput, false,
gradleBuildExcludeDirs, gradleOpts);

Set<Dependency> portalLibJars = ModuleUtil.getPortalLibJars(portalPath);

for (Path modulePath : modulePaths) {
Module module = Module.createModule(
projectPath.resolve("modules"), modulePath,
moduleDependenciesMap.get(modulePath),
jarDependenciesMap.get(
String.valueOf(modulePath.getFileName())),
MavenUtil.getDependencies(modulePath.resolve("build.gradle")),
portalModuleDependencyProperties, trunkPath, includeJsps,
portalPath);

Expand Down
154 changes: 154 additions & 0 deletions src/com/liferay/netbeansproject/container/Coordinate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/**
* SPDX-FileCopyrightText: (c) 2023 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.netbeansproject.container;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

/**
* @author Shuyang Zhou
*/
public class Coordinate implements Comparable<Coordinate> {

public Coordinate(String line) {
String[] parts = line.split(":");

_groupId = parts[0];
_artifactId = parts[1];
_version = parts[2];
_test = false;

_filePath = _toFilePath(_groupId, _artifactId, _version);
}


public Coordinate(
String groupId, String artifactId, String version, boolean test) {

_groupId = groupId;
_artifactId = artifactId;
_version = version;
_test = test;

_filePath = _toFilePath(groupId, artifactId, version);
}

public Dependency toDependency(Path basePath) {
Path sourcePath = basePath.resolve(_filePath.replace(".jar", "-sources.jar"));

if (Files.notExists(sourcePath)) {
sourcePath = null;
}
else {
sourcePath = sourcePath.toAbsolutePath();
}

return new Dependency(basePath.resolve(_filePath).toAbsolutePath(), sourcePath, _test);
}

private static String _toFilePath(String groupId, String artifactId, String version) {
StringBuilder sb = new StringBuilder();

sb.append(groupId.replace('.', '/'));
sb.append('/');
sb.append(artifactId);
sb.append('/');
sb.append(version);
sb.append('/');
sb.append(artifactId);
sb.append('-');
sb.append(version);
sb.append(".jar");

return sb.toString();
}
public String getFilePath() {
return _filePath;
}

public String getGroupId() {
return _groupId;
}

public String getArtifactId() {
return _artifactId;
}

public String getVersion() {
return _version;
}

public boolean isTest() {
return _test;
}

public void setTest(boolean test) {
_test = test;
}

private final String _groupId;
private final String _artifactId;
private final String _version;
private boolean _test;
private final String _filePath;

@Override
public int hashCode() {
int hash = 7;
hash = 67 * hash + Objects.hashCode(this._groupId);
hash = 67 * hash + Objects.hashCode(this._artifactId);
hash = 67 * hash + Objects.hashCode(this._version);
hash = 67 * hash + (this._test ? 1 : 0);
return hash;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Coordinate other = (Coordinate)obj;
if (!Objects.equals(this._groupId, other._groupId)) {
return false;
}
if (!Objects.equals(this._artifactId, other._artifactId)) {
return false;
}
return Objects.equals(this._version, other._version);
}


@Override
public int compareTo(Coordinate coordinate) {
int result = _groupId.compareTo(coordinate._groupId);

if (result != 0) {
return result;
}

result = _artifactId.compareTo(coordinate._artifactId);

if (result != 0) {
return result;
}

return _version.compareTo(coordinate._version);
}

@Override
public String toString() {
return _groupId + ":" + _artifactId + ":" + _version;
}

}
Loading

0 comments on commit dc27a53

Please sign in to comment.