-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve discovering javaSource based on maven.compiler properties, de…
…fault as 8 We can recognize based on properties: - maven.compiler.release - maven.compiler.source - maven.compiler.target fix #194
- Loading branch information
1 parent
7518eb5
commit 25decf4
Showing
7 changed files
with
137 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...ugin/src/test/java/org/codehaus/modello/maven/AbstractModelloSourceGeneratorMojoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.codehaus.modello.maven; | ||
|
||
import java.util.Properties; | ||
|
||
import org.apache.maven.model.Model; | ||
import org.apache.maven.project.MavenProject; | ||
import org.codehaus.modello.ModelloParameterConstants; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class AbstractModelloSourceGeneratorMojoTest { | ||
|
||
private class ModelloSourceGeneratorMojoTest extends AbstractModelloSourceGeneratorMojo { | ||
|
||
private final Properties projectProperties; | ||
|
||
ModelloSourceGeneratorMojoTest(Properties projectProperties) { | ||
this.projectProperties = projectProperties; | ||
} | ||
|
||
@Override | ||
protected String getGeneratorType() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public MavenProject getProject() { | ||
Model model = new Model(); | ||
model.setProperties(projectProperties); | ||
MavenProject project = new MavenProject(); | ||
project.setModel(model); | ||
return project; | ||
} | ||
} | ||
|
||
private void executeJavaSourceTest(Properties projectProperties, String expexted) { | ||
ModelloSourceGeneratorMojoTest modelloSourceGeneratorMojoTest = | ||
new ModelloSourceGeneratorMojoTest(projectProperties); | ||
Properties properties = new Properties(); | ||
|
||
modelloSourceGeneratorMojoTest.customizeParameters(properties); | ||
|
||
assertEquals(properties.getProperty(ModelloParameterConstants.OUTPUT_JAVA_SOURCE), expexted); | ||
} | ||
|
||
@Test | ||
public void testJavaSourceDefault() { | ||
executeJavaSourceTest(new Properties(), ModelloParameterConstants.OUTPUT_JAVA_SOURCE_DEFAULT); | ||
} | ||
|
||
@Test | ||
public void testJavaSourceFromRelease() { | ||
Properties projectProperties = new Properties(); | ||
projectProperties.setProperty("maven.compiler.release", "11"); | ||
projectProperties.setProperty("maven.compiler.source", "xxx"); | ||
projectProperties.setProperty("maven.compiler.target", "xxx"); | ||
|
||
executeJavaSourceTest(projectProperties, "11"); | ||
} | ||
|
||
@Test | ||
public void testJavaSourceFromSource() { | ||
Properties projectProperties = new Properties(); | ||
projectProperties.setProperty("maven.compiler.source", "11"); | ||
projectProperties.setProperty("maven.compiler.target", "xxx"); | ||
|
||
executeJavaSourceTest(projectProperties, "11"); | ||
} | ||
|
||
@Test | ||
public void testJavaSourceFromTarget() { | ||
Properties projectProperties = new Properties(); | ||
projectProperties.setProperty("maven.compiler.target", "11"); | ||
|
||
executeJavaSourceTest(projectProperties, "11"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters