Skip to content

Commit 6d7da83

Browse files
committed
added test for gradle 9
1 parent f8c3d5f commit 6d7da83

8 files changed

Lines changed: 224 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
buildscript {
2+
repositories {
3+
flatDir dirs: "../../jcp/target"
4+
}
5+
dependencies {
6+
classpath "com.igormaznitsa:jcp:$jcp_test_version"
7+
}
8+
}
9+
10+
apply plugin: 'java'
11+
apply plugin: 'application'
12+
apply plugin: 'com.igormaznitsa.jcp'
13+
14+
application {
15+
mainClass = 'hello.world'
16+
}
17+
18+
java {
19+
sourceCompatibility = JavaVersion.VERSION_1_8
20+
targetCompatibility = JavaVersion.VERSION_1_8
21+
}
22+
23+
repositories {
24+
mavenLocal()
25+
mavenCentral()
26+
}
27+
28+
dependencies {
29+
testImplementation 'junit:junit:4.12'
30+
}
31+
32+
jar {
33+
manifest {
34+
attributes(
35+
'Main-Class': 'com.igormaznitsa.jcp.it.gradle.MainTwo'
36+
)
37+
}
38+
}
39+
40+
41+
preprocess {
42+
sources = sourceSets.main.java.srcDirs
43+
allowWhitespaces = true
44+
eol = '\r\n'
45+
keepAttributes = true
46+
sourceEncoding = 'UTF-8'
47+
targetEncoding = 'UTF-8'
48+
ignoreMissingSources = false
49+
excludeExtensions = ['txt', 'xml']
50+
fileExtensions = ['java']
51+
unknownVarAsFalse = false
52+
dryRun = false
53+
verbose = true
54+
clearTarget = true
55+
careForLastEol = true
56+
keepComments = 'remove_jcp_only'
57+
excludeFolders = ['**/some1', '**/some2']
58+
configFiles = ['./configFile.txt']
59+
keepLines = true
60+
allowWhitespaces = true
61+
preserveIndents = true
62+
dontOverwriteSameContent = false
63+
actionPreprocessorExtension = "com.igormaznitsa.jcp.extension.LogPreprocessorExtension"
64+
vars = ['some.test.global': 'Some Test Global Value']
65+
}
66+
task(changeSourceFolder) {
67+
sourceSets.main.java.srcDirs = [preprocess.target]
68+
}.dependsOn preprocess
69+
70+
71+
compileJava.dependsOn preprocess
72+
73+
gradle.buildFinished {
74+
println("Incoming preprocess files: " + preprocess.incomingFiles.size())
75+
println("Resulted preprocess files: " + preprocess.outcomingFiles.size())
76+
}
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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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-9</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>${gradle9.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>-Pjcp_test_version=${jcp.test.version}</argument>
74+
<argument>
75+
-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
76+
</argument>
77+
</arguments>
78+
</configuration>
79+
<goals>
80+
<goal>exec</goal>
81+
</goals>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
</plugins>
86+
</build>
87+
88+
</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+
//#action "hello","world",$user2(1,2)
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
<gradle6.executable>gradle6</gradle6.executable>
1717
<gradle7.executable>gradle7</gradle7.executable>
1818
<gradle8.executable>gradle8</gradle8.executable>
19+
<gradle9.executable>gradle9</gradle9.executable>
1920
</properties>
2021

2122
<modules>
@@ -27,6 +28,7 @@
2728
<module>jcp-test-gradle-6</module>
2829
<module>jcp-test-gradle-7</module>
2930
<module>jcp-test-gradle-8</module>
31+
<module>jcp-test-gradle-9</module>
3032
<module>jcp-test-android</module>
3133
</modules>
3234

0 commit comments

Comments
 (0)