Skip to content

Commit

Permalink
Add test for auto libs directory
Browse files Browse the repository at this point in the history
  • Loading branch information
melix committed Nov 3, 2021
1 parent 684dc70 commit a012065
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,26 @@ class BasicFunctionalTest extends AbstractFunctionalTest {
errorOutputContains '''Included build '/xxx' does not exist'''
}

def "can automatically use local repository instead of checking out"() {
withSample 'basic'

file("gradle.properties") << """
auto.include.git.dirs=${new File("../samples/repo").absolutePath}
"""

when:
run 'dependencies', '--configuration', 'compileClasspath'

then:
tasks {
succeeded ':dependencies'
}

outputContains '''compileClasspath - Compile classpath for source set 'main'.
\\--- com.acme.somelib:somelib1:0.0 -> project :testlib0
+--- org.apache.commons:commons-math3:3.6.1 FAILED
\\--- dummy:for-test:1.0 FAILED
'''
}

}
19 changes: 19 additions & 0 deletions samples/repo/testlib0/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java-library'
}

group = 'com.acme.somelib'
version = '1.0'

repositories {
mavenCentral()
}

dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
api 'dummy:for-test:1.0'

implementation 'com.google.guava:guava:29.0-jre'

testImplementation 'junit:junit:4.13'
}
10 changes: 10 additions & 0 deletions samples/repo/testlib0/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/6.5/userguide/multi_project_builds.html
*/

rootProject.name = 'somelib1'
10 changes: 10 additions & 0 deletions samples/repo/testlib0/src/main/java/com/acme/somelib1/Library.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package com.acme.somelib1;

public class Library {
public boolean someLibraryMethod() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package com.acme.somelib1;

import org.junit.Test;
import static org.junit.Assert.*;

public class LibraryTest {
@Test public void testSomeLibraryMethod() {
Library classUnderTest = new Library();
assertTrue("someLibraryMethod should return 'true'", classUnderTest.someLibraryMethod());
}
}

0 comments on commit a012065

Please sign in to comment.