From 04fe3387070c98e508d7091625cfd332130d92e7 Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Sat, 15 Aug 2020 14:42:21 +0300 Subject: [PATCH] BAEL-4516: First structure --- gradle-5/settings.gradle | 3 +- gradle-5/source-sets/build.gradle | 35 +++++++++++++++++++ .../com/baeldung/itest/SourceSetsItest.java | 19 ++++++++++ .../com/baeldung/main/SourceSetsMain.java | 9 +++++ .../com/baeldung/test/SourceSetsTest.java | 19 ++++++++++ 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 gradle-5/source-sets/build.gradle create mode 100644 gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java create mode 100644 gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsMain.java create mode 100644 gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java diff --git a/gradle-5/settings.gradle b/gradle-5/settings.gradle index 1997e12ca5..5384d071e7 100644 --- a/gradle-5/settings.gradle +++ b/gradle-5/settings.gradle @@ -1,3 +1,4 @@ rootProject.name='gradle-5-articles' include 'java-exec' -include 'unused-dependencies' \ No newline at end of file +include 'unused-dependencies' +include 'source-sets' \ No newline at end of file diff --git a/gradle-5/source-sets/build.gradle b/gradle-5/source-sets/build.gradle new file mode 100644 index 0000000000..909b125aed --- /dev/null +++ b/gradle-5/source-sets/build.gradle @@ -0,0 +1,35 @@ + +apply plugin: "eclipse" + +description = "Source Sets example" + +task printConfigurations(){ + doLast{ + configurations.each { + println it.name + } + } +} + +sourceSets{ + itest { + java { + } + } +} + +dependencies { + implementation('org.apache.httpcomponents:httpclient:4.5.12') + testImplementation('junit:junit:4.12') + itestImplementation('com.google.guava:guava:29.0-jre') +} + +configurations { + itestImplementation.extendsFrom(testImplementation) +} + +eclipse { + classpath { + plusConfigurations+=[configurations.itestCompileClasspath] + } +} \ No newline at end of file diff --git a/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java b/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java new file mode 100644 index 0000000000..7f5d0699a2 --- /dev/null +++ b/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java @@ -0,0 +1,19 @@ +package com.baeldung.itest; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; + +import com.google.common.collect.ImmutableList; + +public class SourceSetsItest { + + @Test + public void whenRunThenFail() { + List someStrings = ImmutableList.of("Baeldung", "is", "cool"); + assertThat(false, is(true)); + } +} diff --git a/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsMain.java b/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsMain.java new file mode 100644 index 0000000000..319894d336 --- /dev/null +++ b/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsMain.java @@ -0,0 +1,9 @@ +package com.baeldung.main; + +public class SourceSetsMain { + + public static void main(String[] args) { + System.out.println("Hell..oh...world!"); + } + +} diff --git a/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java b/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java new file mode 100644 index 0000000000..829b6ee36b --- /dev/null +++ b/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java @@ -0,0 +1,19 @@ +package com.baeldung.test; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; + +import com.google.common.collect.ImmutableList; + +public class SourceSetsTest { + + @Test + public void whenRunThenSuccess() { + List someStrings = ImmutableList.of("Baeldung", "is", "cool"); + assertThat(true, is(true)); + } +}