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

[BUILD] Separate transitive dependencies in core #1124

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ subprojects {
configurations {
create("testing") // used to reference the testJar
create("testConfig") // contains test dependencies that are used by all java subprojects
create("releaseDep") { // contains all dependencies which has to be included into the release jar/zip
create("bundle") { // contains all which are used by core
isTransitive = false // avoid that the whole dependency tree is released
}
create("bundleApi") { // contains all dependencies which are used by all java subprojects
isTransitive = false // avoid that the whole dependency tree is released
}
}
Expand Down Expand Up @@ -109,7 +112,8 @@ subprojects {
*/
register("generateLib", Copy::class) {
into("${project.projectDir}/lib")
from(projectToConf.configurations.getByName("releaseDep"))
from(projectToConf.configurations.getByName("bundle"))
from(projectToConf.configurations.getByName("bundleApi"))
}

val aggregateTestResults: String? by project
Expand Down Expand Up @@ -139,6 +143,9 @@ subprojects {
// Bridge that routes log4j calls to log4j2
val log4j2Bridge = "org.apache.logging.log4j:log4j-1.2-api:$log4j2VersionNr"

projectToConf.extra["commons-lang3"] = "org.apache.commons:commons-lang3:3.8.1"
projectToConf.extra["commons-io2"] = "commons-io:commons-io:2.0.1"

projectToConf.extra["junitVersion"] = junitVersion
projectToConf.extra["log4j2ApiVersion"] = log4j2Api
projectToConf.extra["log4j2CoreVersion"] = log4j2Core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class SarosEclipseExtension {
private boolean addDependencies = false;
private boolean addPdeNature = false;
private boolean createBundleJar = false;
private List<String> configs = new ArrayList<>();

public File getManifest() {
return manifest;
Expand Down Expand Up @@ -106,4 +107,23 @@ public boolean isCreateBundleJar() {
public void setCreateBundleJar(boolean createBundleJar) {
this.createBundleJar = createBundleJar;
}

public void setConfigs(List<String> configs) {
this.configs = configs;
}

public List<String> getConfigs() {
return configs;
}

/**
* Get the list of (gradle) configurations or a given default if the list of configurations is
* empty.
*
* @param defaultConfigs The list of (gradle) configurations to be returned when an empty
* configurations-list is given.
*/
public List<String> getConfigs(List<String> defaultConfigs) {
return configs.isEmpty() ? defaultConfigs : configs;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package saros.gradle.eclipse;

import java.util.Arrays;
import java.util.List;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
Expand All @@ -16,6 +18,7 @@
public class SarosEclipsePlugin implements Plugin<Project> {
private static final String EXTENSION_NAME = "sarosEclipse";
private static final String PLUGIN_VERSION_CHANGE_TASK_NAME = "changeEclipsePluginVersion";
private static final List<String> DEFAULT_CONFIG_NAMES = Arrays.asList("bundle", "bundleApi");

/**
* Method which is called when the plugin is integrated in a gradle build (e.g. with {@code apply
Expand Down Expand Up @@ -70,7 +73,8 @@ private void configureEclipseAfterEvaluate(Project p, SarosEclipseExtension e) {

if (e.isCreateBundleJar()) {
methodRequiresManifest("create bundle jar", e);
new JarConfigurator(p).createBundleJar(e.getManifest());
List<String> jarConfigs = e.getConfigs(DEFAULT_CONFIG_NAMES);
new JarConfigurator(p, jarConfigs).createBundleJar(e.getManifest());
}

if (e.isAddDependencies()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package saros.gradle.eclipse.configurator;

import java.io.File;
import java.util.List;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.file.CopySpec;
Expand All @@ -14,13 +15,14 @@ public class JarConfigurator {
private static final String JAVA_PLUGIN_ID = "java";
private static final String JAR_TASK_NAME = "jar";

private static final String RELEASE_CONFIG_NAME = "releaseDep";
private static final String JAR_LIB_DESTINATION = "lib";

private Project project;
private final List<String> configs;

public JarConfigurator(Project project) {
public JarConfigurator(Project project, List<String> configs) {
this.project = project;
this.configs = configs;
project.getPluginManager().apply(JAVA_PLUGIN_ID);
}

Expand All @@ -33,8 +35,10 @@ public void createBundleJar(File manifestFile) {
jarTask.manifest((Manifest mf) -> mf.from(manifestFile));
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
jarTask.from(sourceSets.getByName(JAVA_MAIN_SOURCE_SET_NAME).getOutput());
jarTask.into(
JAR_LIB_DESTINATION,
(CopySpec cs) -> cs.from(project.getConfigurations().getByName(RELEASE_CONFIG_NAME)));
for (String jarConfig : this.configs) {
jarTask.into(
JAR_LIB_DESTINATION,
(CopySpec cs) -> cs.from(project.getConfigurations().getByName(jarConfig)));
}
}
}
38 changes: 1 addition & 37 deletions core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,7 @@ Bundle-Name: Saros Core
Bundle-SymbolicName: saros.core
Bundle-Version: 0.2.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.thoughtworks.xstream,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you remove the exports ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The xstream-Package is only used by the core and no other bundle. So the core don't need to export this package. If any other bundle is using this package and we missed to find it, please tell us that.

com.thoughtworks.xstream.annotations,
com.thoughtworks.xstream.converters,
com.thoughtworks.xstream.converters.basic,
com.thoughtworks.xstream.converters.collections,
com.thoughtworks.xstream.converters.enums,
com.thoughtworks.xstream.converters.extended,
com.thoughtworks.xstream.converters.javabean,
com.thoughtworks.xstream.converters.reflection,
com.thoughtworks.xstream.core,
com.thoughtworks.xstream.core.util,
com.thoughtworks.xstream.io,
com.thoughtworks.xstream.io.binary,
com.thoughtworks.xstream.io.copy,
com.thoughtworks.xstream.io.json,
com.thoughtworks.xstream.io.naming,
com.thoughtworks.xstream.io.path,
com.thoughtworks.xstream.io.xml,
com.thoughtworks.xstream.io.xml.xppdom,
com.thoughtworks.xstream.mapper,
com.thoughtworks.xstream.persistence,
saros,
Export-Package: saros,
saros.account,
saros.activities,
saros.annotations,
Expand Down Expand Up @@ -80,21 +59,6 @@ Export-Package: com.thoughtworks.xstream,
saros.ui.util,
saros.util,
saros.versioning,
org.apache.commons.codec,
org.apache.commons.codec.binary,
org.apache.commons.codec.digest,
org.apache.commons.codec.language,
org.apache.commons.codec.net,
org.apache.commons.io,
org.apache.commons.io.comparator,
org.apache.commons.io.filefilter,
org.apache.commons.io.input,
org.apache.commons.io.monitor,
org.apache.commons.io.output,
org.apache.commons.lang3,
org.apache.commons.lang3.exception,
org.apache.commons.lang3.time,
org.apache.commons.lang3.tuple,
org.apache.log4j,
org.apache.log4j.config,
org.apache.log4j.helpers,
Expand Down
45 changes: 26 additions & 19 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
plugins {
id("saros.gradle.eclipse.plugin")
`java-library`
}

val versionQualifier = ext.get("versionQualifier") as String
val commonsLang = ext.get("commons-lang3") as String
val commonsIo = ext.get("commons-io2") as String

val log4j2ApiVersion = ext.get("log4j2ApiVersion") as String
val log4j2CoreVersion = ext.get("log4j2CoreVersion") as String
val log4j2BridgeVersion = ext.get("log4j2BridgeVersion") as String

configurations {
val bundle by getting {}
val bundleApi by getting {}
val api by getting {
extendsFrom(bundleApi)
}
val implementation by getting {
extendsFrom(bundle)
}
// Defined in root build.gradle
val testConfig by getting {}
val releaseDep by getting {}

// Default configuration
val compile by getting {
extendsFrom(releaseDep)
}
val testCompile by getting {
extendsFrom(testConfig)
}
val plain by creating {
extendsFrom(compile)
extendsFrom(implementation, api)
}
}

Expand All @@ -33,26 +40,26 @@ sarosEclipse {
}

dependencies {
releaseDep("commons-codec:commons-codec:1.3")
releaseDep("commons-io:commons-io:2.0.1")
releaseDep("org.apache.commons:commons-lang3:3.8.1")
bundle("commons-codec:commons-codec:1.3")
bundle(commonsIo)
bundle(commonsLang)

releaseDep("javax.jmdns:jmdns:3.4.1")
releaseDep("xpp3:xpp3:1.1.4c")
releaseDep("com.thoughtworks.xstream:xstream:1.4.10")
releaseDep("org.gnu.inet:libidn:1.15")
bundle("javax.jmdns:jmdns:3.4.1")
bundle("xpp3:xpp3:1.1.4c")
bundle("com.thoughtworks.xstream:xstream:1.4.10")
bundle("org.gnu.inet:libidn:1.15")

releaseDep(log4j2ApiVersion)
releaseDep(log4j2CoreVersion)
releaseDep(log4j2BridgeVersion)
bundleApi(log4j2ApiVersion)
bundleApi(log4j2CoreVersion)
bundleApi(log4j2BridgeVersion)

// TODO: use real release. This version is a customized SNAPSHOT
releaseDep(files("libs/weupnp.jar"))
bundleApi(files("libs/weupnp.jar"))
// Workaround until we updated to a newer smack version
releaseDep(files("libs/smack-3.4.1.jar"))
releaseDep(files("libs/smackx-3.4.1.jar"))
bundleApi(files("libs/smack-3.4.1.jar"))
bundleApi(files("libs/smackx-3.4.1.jar"))
// Workaround until we can publish and use (without a user token) the repackaged jar in GitHub Packages
releaseDep(rootProject.files("libs/picocontainer-2.11.2-patched_relocated.jar"))
bundleApi(rootProject.files("libs/picocontainer-2.11.2-patched_relocated.jar"))
}

sourceSets {
Expand Down
5 changes: 5 additions & 0 deletions eclipse/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import com.diffplug.gradle.pde.EclipseRelease
val versionQualifier = ext.get("versionQualifier") as String
val eclipseVersionNr = ext.get("eclipseVersion") as String

val commonsIo = ext.get("commons-io2") as String
val commonsLang = ext.get("commons-lang3") as String

configurations {
val testConfig by getting {}
getByName("testImplementation") {
Expand Down Expand Up @@ -40,6 +43,8 @@ sourceSets {

dependencies {
implementation(project(":saros.core"))
implementation(commonsIo)
implementation(commonsLang)
// This is a workaround for https://github.com/saros-project/saros/issues/1086
implementation("org.eclipse.platform:org.eclipse.urischeme:1.1.0")
// This is a workaround for https://github.com/saros-project/saros/issues/1114
Expand Down
5 changes: 5 additions & 0 deletions intellij/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ val versionQualifier: String? = ext.get("versionQualifier") as String?
val intellijHome: String? = ext.get("intellijHome") as String?
val intellijSandboxDir: String? = ext.get("intellijSandboxDir") as String?

val commonsIo = ext.get("commons-io2") as String
val commonsLang = ext.get("commons-lang3") as String

configurations {
val testConfig by getting {}
val testCompile by getting {
Expand All @@ -15,6 +18,8 @@ configurations {

dependencies {
compile(project(path = ":saros.core", configuration = "plain"))
implementation(commonsIo)
implementation(commonsLang)

compile("org.easytesting:fest-assert:1.2")
compile("org.easytesting:fest-reflect:1.2")
Expand Down
3 changes: 3 additions & 0 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
val versionQualifier = ext.get("versionQualifier")

val commonsIo = ext.get("commons-io2") as String

configurations {
val testConfig by getting {}
val testCompile by getting {
Expand All @@ -10,6 +12,7 @@ configurations {
dependencies {
compile(project(":saros.core"))
compile("org.apache.commons:commons-collections4:4.2")
implementation(commonsIo)
}

sourceSets {
Expand Down
3 changes: 3 additions & 0 deletions stf.test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ plugins {

val eclipseVersionNr = ext.get("eclipseVersion") as String

val commonsLang = ext.get("commons-lang3") as String

sarosEclipse {
manifest = file("META-INF/MANIFEST.MF")
excludeManifestDependencies = listOf("org.junit", "saros.eclipse", "saros.core")
Expand All @@ -25,6 +27,7 @@ configurations {
}

dependencies {
implementation(commonsLang)
val stfTestCompile by configurations
stfTestCompile(project(":saros.stf"))
stfTestCompile(project(path = ":saros.stf", configuration = "testing"))
Expand Down
6 changes: 3 additions & 3 deletions stf/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ sarosEclipse {
}

configurations {
val releaseDep by getting {}
val bundleApi by getting {}
val compile by getting {
extendsFrom(releaseDep)
extendsFrom(bundleApi)
}
}

Expand All @@ -35,7 +35,7 @@ dependencies {
implementation("org.eclipse.platform:org.eclipse.ui.workbench:3.120.0")
compile(project(path = ":saros.eclipse", configuration = "testing"))

releaseDep(fileTree("libs"))
bundleApi(fileTree("libs"))
}

sourceSets {
Expand Down