Skip to content

Commit da4785f

Browse files
committed
#30 improved providing of maven project properties to support overriding
1 parent 8a57d38 commit da4785f

File tree

11 files changed

+188
-125
lines changed

11 files changed

+188
-125
lines changed

jcp-tests/jcp-test-gradle/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
flatDir dirs: "../../jcp/target"
44
}
55
dependencies {
6-
classpath "com.igormaznitsa:jcp:7.0.4"
6+
classpath "com.igormaznitsa:jcp:7.0.5-SNAPSHOT"
77
}
88
}
99

jcp-tests/jcp-test-maven/pom.xml

Lines changed: 98 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,105 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
3+
<modelVersion>4.0.0</modelVersion>
44

5-
<parent>
6-
<groupId>com.igormaznitsa</groupId>
7-
<artifactId>jcp-tests</artifactId>
8-
<version>0-SNAPSHOT</version>
9-
</parent>
5+
<parent>
6+
<groupId>com.igormaznitsa</groupId>
7+
<artifactId>jcp-tests</artifactId>
8+
<version>0-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>jcp-test-maven</artifactId>
12+
<packaging>jar</packaging>
1013

11-
<artifactId>jcp-test-maven</artifactId>
12-
<packaging>jar</packaging>
14+
<properties>
15+
<my.custom.property>some_custom_property</my.custom.property>
16+
</properties>
1317

14-
<build>
15-
<plugins>
16-
<plugin>
17-
<groupId>com.igormaznitsa</groupId>
18-
<artifactId>jcp</artifactId>
19-
<version>${jcp.test.version}</version>
20-
<configuration>
21-
<eol>\r\n</eol>
22-
</configuration>
23-
<executions>
24-
<execution>
25-
<id>preprocess-sources</id>
26-
<phase>generate-sources</phase>
27-
<goals>
28-
<goal>preprocess</goal>
29-
</goals>
30-
<configuration>
31-
<allowWhitespaces>true</allowWhitespaces>
32-
<eol>\r\n</eol>
33-
<excludeExtensions>
34-
<extension>xml</extension>
35-
<extension>txt</extension>
36-
</excludeExtensions>
37-
<extensions>
38-
<extension>java</extension>
39-
</extensions>
40-
<keepAttributes>true</keepAttributes>
41-
<keepComments>false</keepComments>
42-
<keepLines>true</keepLines>
43-
<vars>
44-
<some.test.global>Some Test Global Value</some.test.global>
45-
</vars>
46-
<sourceEncoding>UTF-8</sourceEncoding>
47-
<targetEncoding>UTF-8</targetEncoding>
48-
<ignoreMissingSources>false</ignoreMissingSources>
49-
<unknownVarAsFalse>true</unknownVarAsFalse>
50-
<dryRun>false</dryRun>
51-
<verbose>true</verbose>
52-
<clearTarget>true</clearTarget>
53-
<replaceSources>true</replaceSources>
54-
<careForLastEol>true</careForLastEol>
55-
<excludeFolders>
56-
<folder>./some1</folder>
57-
<folder>./**/some2</folder>
58-
</excludeFolders>
59-
<preserveIndents>true</preserveIndents>
60-
<dontOverwriteSameContent>false</dontOverwriteSameContent>
61-
<skip>false</skip>
62-
</configuration>
63-
</execution>
64-
<execution>
65-
<id>preprocess-test-sources</id>
66-
<phase>generate-test-sources</phase>
67-
<goals>
68-
<goal>preprocess</goal>
69-
</goals>
70-
<configuration>
71-
<useTestSources>true</useTestSources>
72-
<vars>
73-
<some.test.global.test>Some Test</some.test.global.test>
74-
</vars>
75-
</configuration>
76-
</execution>
77-
</executions>
78-
</plugin>
79-
</plugins>
80-
</build>
18+
<build>
19+
<plugins>
20+
<plugin>
21+
<groupId>com.igormaznitsa</groupId>
22+
<artifactId>jcp</artifactId>
23+
<version>${jcp.test.version}</version>
24+
<configuration>
25+
<eol>\r\n</eol>
26+
</configuration>
27+
<executions>
28+
<execution>
29+
<id>preprocess-sources</id>
30+
<phase>generate-sources</phase>
31+
<goals>
32+
<goal>preprocess</goal>
33+
</goals>
34+
<configuration>
35+
<allowWhitespaces>true</allowWhitespaces>
36+
<eol>\r\n</eol>
37+
<excludeExtensions>
38+
<extension>xml</extension>
39+
<extension>txt</extension>
40+
</excludeExtensions>
41+
<extensions>
42+
<extension>java</extension>
43+
</extensions>
44+
<keepAttributes>true</keepAttributes>
45+
<keepComments>false</keepComments>
46+
<keepLines>true</keepLines>
47+
<vars>
48+
<some.test.global>Some Test Global Value</some.test.global>
49+
</vars>
50+
<sourceEncoding>UTF-8</sourceEncoding>
51+
<targetEncoding>UTF-8</targetEncoding>
52+
<ignoreMissingSources>false</ignoreMissingSources>
53+
<unknownVarAsFalse>true</unknownVarAsFalse>
54+
<dryRun>false</dryRun>
55+
<verbose>true</verbose>
56+
<clearTarget>true</clearTarget>
57+
<replaceSources>true</replaceSources>
58+
<careForLastEol>true</careForLastEol>
59+
<excludeFolders>
60+
<folder>./some1</folder>
61+
<folder>./**/some2</folder>
62+
</excludeFolders>
63+
<preserveIndents>true</preserveIndents>
64+
<dontOverwriteSameContent>false</dontOverwriteSameContent>
65+
<skip>false</skip>
66+
</configuration>
67+
</execution>
68+
<execution>
69+
<id>preprocess-test-sources</id>
70+
<phase>generate-test-sources</phase>
71+
<goals>
72+
<goal>preprocess</goal>
73+
</goals>
74+
<configuration>
75+
<useTestSources>true</useTestSources>
76+
<vars>
77+
<some.test.global.test>Some Test</some.test.global.test>
78+
</vars>
79+
</configuration>
80+
</execution>
81+
</executions>
82+
</plugin>
83+
<plugin>
84+
<groupId>org.codehaus.mojo</groupId>
85+
<artifactId>build-helper-maven-plugin</artifactId>
86+
<version>3.0.0</version>
87+
<executions>
88+
<execution>
89+
<id>set-test-property</id>
90+
<goals>
91+
<goal>bsh-property</goal>
92+
</goals>
93+
<phase>process-classes</phase>
94+
<configuration>
95+
<source>
96+
session.getUserProperties().setProperty("my.custom.property","test_custom_property");
97+
</source>
98+
</configuration>
99+
</execution>
100+
</executions>
101+
</plugin>
102+
</plugins>
103+
</build>
81104

82105
</project>

jcp-tests/jcp-test-maven/src/main/java/com/igormaznitsa/jcp/it/maven/Main.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ public Main(){
2020
throw new Error("Unexpected value: "+test);
2121
}
2222
}
23+
24+
public String getProperty() {
25+
return "/*$mvn.project.property.my.custom.property$*/";
26+
}
2327
}

jcp-tests/jcp-test-maven/src/test/java/com/igormaznitsa/jcp/it/maven/TestMain.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ public class TestMain {
88

99
@Test
1010
public void testMain(){
11-
//$new MainTwo();
12-
//#//
13-
new Main();
11+
//$MainTwo obj = new MainTwo();
12+
//#-
13+
Main obj = new Main();
14+
//#+
15+
16+
assertEquals("some_custom_property", obj.getProperty());
17+
assertEquals("test_custom_property","/*$mvn.project.property.my.custom.property$*/");
18+
1419
String str = /*$"\""+some.test.global.test+"\";"$*/ /*-*/"";
1520
assertEquals("Some Test", str);
1621
System.out.println(str);

jcp-tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<properties>
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12-
<jcp.test.version>7.0.4</jcp.test.version>
12+
<jcp.test.version>7.0.5-SNAPSHOT</jcp.test.version>
1313
<junit.version>5.4.2</junit.version>
1414
<maven.compiler.source>1.8</maven.compiler.source>
1515
<maven.compiler.target>1.8</maven.compiler.target>

jcp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.igormaznitsa</groupId>
77
<artifactId>jcp-pom</artifactId>
8-
<version>7.0.4</version>
8+
<version>7.0.5-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>jcp</artifactId>

jcp/src/main/java/com/igormaznitsa/jcp/InfoHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ private InfoHelper() {
4545

4646

4747
public static String getVersion() {
48-
return "v7.0.4";
48+
return "v7.0.5";
4949
}
5050

5151

5252
public static String getCopyright() {
53-
return "Copyright (C) 2002-2020 Igor A. Maznitsa (https://www.igormaznitsa.com)";
53+
return "Copyright (C) 2002-2021 Igor A. Maznitsa (https://www.igormaznitsa.com)";
5454
}
5555

5656

0 commit comments

Comments
 (0)