Skip to content

Commit 8e6751c

Browse files
committed
added test for gradle 8
1 parent 56a7170 commit 8e6751c

8 files changed

Lines changed: 218 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
buildscript {
2+
repositories {
3+
flatDir dirs: "../../jcp/target"
4+
}
5+
dependencies {
6+
classpath "com.igormaznitsa:jcp:7.0.6-SNAPSHOT"
7+
}
8+
}
9+
10+
apply plugin: 'java'
11+
apply plugin: 'application'
12+
apply plugin: 'com.igormaznitsa.jcp'
13+
14+
mainClassName = 'hello.world'
15+
16+
sourceCompatibility = JavaVersion.VERSION_1_7
17+
targetCompatibility = JavaVersion.VERSION_1_7
18+
19+
repositories {
20+
mavenLocal()
21+
mavenCentral()
22+
}
23+
24+
dependencies {
25+
testImplementation 'junit:junit:4.12'
26+
}
27+
28+
jar {
29+
manifest {
30+
attributes(
31+
'Main-Class': 'com.igormaznitsa.jcp.it.gradle.MainTwo'
32+
)
33+
}
34+
}
35+
36+
37+
preprocess {
38+
sources = sourceSets.main.java.srcDirs
39+
allowWhitespaces = true
40+
eol = '\r\n'
41+
keepAttributes = true
42+
sourceEncoding = 'UTF-8'
43+
targetEncoding = 'UTF-8'
44+
ignoreMissingSources = false
45+
excludeExtensions = ['txt', 'xml']
46+
fileExtensions = ['java']
47+
unknownVarAsFalse = false
48+
dryRun = false
49+
verbose = true
50+
clearTarget = true
51+
careForLastEol = true
52+
keepComments = true
53+
excludeFolders = ['**/some1', '**/some2']
54+
configFiles = ['./configFile.txt']
55+
keepLines = true
56+
allowWhitespaces = true
57+
preserveIndents = true
58+
dontOverwriteSameContent = false
59+
vars = ['some.test.global': 'Some Test Global Value']
60+
}
61+
task(changeSourceFolder) {
62+
sourceSets.main.java.srcDirs = [preprocess.target]
63+
}.dependsOn preprocess
64+
65+
66+
compileJava.dependsOn preprocess
67+
68+
gradle.buildFinished {
69+
println("Incoming preprocess files: " + preprocess.incomingFiles.size())
70+
println("Resulted preprocess files: " + preprocess.outcomingFiles.size())
71+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# config file for build
2+
someGlobalVar="HUZZAA!"
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>com.igormaznitsa</groupId>
8+
<artifactId>jcp-tests</artifactId>
9+
<version>0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>jcp-test-gradle-8</artifactId>
13+
<packaging>pom</packaging>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>junit</groupId>
18+
<artifactId>junit</artifactId>
19+
<scope>provided</scope>
20+
</dependency>
21+
</dependencies>
22+
23+
<build>
24+
<plugins>
25+
<plugin>
26+
<artifactId>maven-clean-plugin</artifactId>
27+
<version>3.1.0</version>
28+
<configuration>
29+
<filesets>
30+
<fileset>
31+
<directory>${project.basedir}/gradle</directory>
32+
<followSymlinks>false</followSymlinks>
33+
</fileset>
34+
<fileset>
35+
<directory>${project.basedir}</directory>
36+
<includes>
37+
<include>gradlew</include>
38+
<include>gradlew.bat</include>
39+
</includes>
40+
<followSymlinks>false</followSymlinks>
41+
</fileset>
42+
<fileset>
43+
<directory>${project.basedir}/downloaded</directory>
44+
<followSymlinks>false</followSymlinks>
45+
</fileset>
46+
<fileset>
47+
<directory>${project.basedir}/build</directory>
48+
<followSymlinks>false</followSymlinks>
49+
</fileset>
50+
<fileset>
51+
<directory>${project.basedir}/out</directory>
52+
<followSymlinks>false</followSymlinks>
53+
</fileset>
54+
</filesets>
55+
</configuration>
56+
</plugin>
57+
<plugin>
58+
<groupId>org.codehaus.mojo</groupId>
59+
<artifactId>exec-maven-plugin</artifactId>
60+
<executions>
61+
<execution>
62+
<id>gradle</id>
63+
<phase>compile</phase>
64+
<configuration>
65+
<executable>${gradle8.executable}</executable>
66+
<arguments>
67+
<argument>clean</argument>
68+
<argument>test</argument>
69+
<argument>jar</argument>
70+
<argument>--rerun-tasks</argument>
71+
<argument>--scan</argument>
72+
<argument>--full-stacktrace</argument>
73+
<argument>
74+
-Pjcp_plugin_path=${project.basedir}${file.separator}..${file.separator}..${file.separator}jcp-gradle-plugin${file.separator}build${file.separator}libs${file.separator}jcp-gradle-plugin-${jcp.test.version}.jar
75+
</argument>
76+
</arguments>
77+
</configuration>
78+
<goals>
79+
<goal>exec</goal>
80+
</goals>
81+
</execution>
82+
</executions>
83+
</plugin>
84+
</plugins>
85+
</build>
86+
87+
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'jcp-test-gradle'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// #outname "MainTwo.java"
2+
package com.igormaznitsa.jcp.it.gradle;
3+
4+
//$public class MainTwo {
5+
//#//
6+
public class Main {
7+
8+
//$$public MainTwo(){
9+
//#//
10+
public Main(){
11+
if (!this.getClass().getName().endsWith("MainTwo")) {
12+
throw new Error("Must be MainTwo but detected"+this.getClass().getName());
13+
}
14+
15+
final String test = /*$"\""+some.test.global+someGlobalVar+"\";"$*/ /*-*/ "";
16+
17+
if ("Some Test Global ValueHUZZAA!".equals(test)){
18+
System.out.println("All ok, detected value '/*$some.test.global+someGlobalVar$*/'");
19+
} else {
20+
throw new Error("Unexpected value: "+test);
21+
}
22+
}
23+
24+
public String getValue(){
25+
return /*$"\""+some.test.global+someGlobalVar+"\";"$*/ /*-*/ "";
26+
}
27+
28+
public static void main(String [] args) {
29+
//$$new MainTwo();
30+
//#//
31+
new Main();
32+
}
33+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.igormaznitsa.jcp.it.gradle;
2+
3+
public class Some {
4+
5+
public String getText() {
6+
return "Some text";
7+
}
8+
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.igormaznitsa.jcp.it.gradle;
2+
3+
import org.junit.Test;
4+
import org.junit.Assert;
5+
6+
public class TestMain {
7+
8+
@Test
9+
public void testMain(){
10+
Assert.assertEquals("Some Test Global ValueHUZZAA!", new MainTwo().getValue());
11+
}
12+
13+
}

jcp-tests/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<gradle5.executable>gradle5</gradle5.executable>
1717
<gradle6.executable>gradle6</gradle6.executable>
1818
<gradle7.executable>gradle7</gradle7.executable>
19+
<gradle8.executable>gradle8</gradle8.executable>
1920
</properties>
2021

2122
<modules>
@@ -26,6 +27,7 @@
2627
<module>jcp-test-gradle-5</module>
2728
<module>jcp-test-gradle-6</module>
2829
<module>jcp-test-gradle-7</module>
30+
<module>jcp-test-gradle-8</module>
2931
<module>jcp-test-android</module>
3032
</modules>
3133

0 commit comments

Comments
 (0)