diff --git a/src/integrationTest/java/eu/xenit/gradle/alfrescosdk/Examples.java b/src/integrationTest/java/eu/xenit/gradle/alfrescosdk/Examples.java index c51df12..86c0d22 100644 --- a/src/integrationTest/java/eu/xenit/gradle/alfrescosdk/Examples.java +++ b/src/integrationTest/java/eu/xenit/gradle/alfrescosdk/Examples.java @@ -2,14 +2,20 @@ import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; import java.io.IOException; +import java.io.InputStream; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; +import java.nio.file.OpenOption; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.Properties; import java.util.function.Predicate; +import org.gradle.util.GUtil; import org.junit.Test; public class Examples extends AbstractIntegrationTest { @@ -116,6 +122,13 @@ public void testConfiguredAlfrescoProject() throws IOException { Path packagedJarFile = ampFs.getPath("lib/configured-alfresco-project-0.0.1.jar"); assertPath(Files::isRegularFile, packagedJarFile); assertArrayEquals("Jar inside amp is not identical to jar outside amp", Files.readAllBytes(jarFile), Files.readAllBytes(packagedJarFile)); + + Properties moduleProperties = GUtil.loadProperties(Files.newInputStream(ampFs.getPath("module.properties"))); + assertEquals("configured-alfresco-project", moduleProperties.get("module.id")); + assertEquals("configured-alfresco-project", moduleProperties.get("module.title")); + assertEquals("0.0.1", moduleProperties.get("module.version")); + assertEquals("Content type detection Webscript, very useful", moduleProperties.get("module.description")); + ampFs.close(); FileSystem jarFs = FileSystems.newFileSystem(jarFile, null); @@ -128,5 +141,28 @@ public void testConfiguredAlfrescoProject() throws IOException { @Test public void multiSourceAlfrescoProject() throws IOException { testProjectFolder(EXAMPLES.resolve("multi-source-alfresco-project"), ":assemble"); + + Path buildFolder = projectFolder.toPath().resolve("build"); + Path shareAmpFile = buildFolder.resolve("dist/multi-source-alfresco-project-0.0.1-share.amp"); + + assertPath(Files::isRegularFile, shareAmpFile); + FileSystem shareAmpFs = FileSystems.newFileSystem(shareAmpFile, null); + assertPath(Files::isRegularFile, shareAmpFs.getPath("module.properties")); + InputStream shareAmpPropertiesInputStream = Files.newInputStream(shareAmpFs.getPath("module.properties")); + Properties shareAmpProperties = GUtil.loadProperties(shareAmpPropertiesInputStream); + assertEquals("multi-source-alfresco-project-share", shareAmpProperties.getProperty("module.id")); + assertEquals("0.0.1", shareAmpProperties.getProperty("module.version")); + shareAmpFs.close(); + + Path ampFile = buildFolder.resolve("dist/multi-source-alfresco-project-0.0.1.amp"); + assertPath(Files::isRegularFile, ampFile); + FileSystem ampFs = FileSystems.newFileSystem(ampFile, null); + assertPath(Files::isRegularFile, ampFs.getPath("module.properties")); + InputStream ampPropertiesInputStream = Files.newInputStream(ampFs.getPath("module.properties")); + Properties ampProperties = GUtil.loadProperties(ampPropertiesInputStream); + assertEquals("multi-source-alfresco-project-repo", ampProperties.getProperty("module.id")); + assertEquals("0.0.1", ampProperties.getProperty("module.version")); + ampFs.close(); + } } diff --git a/src/integrationTest/resources/examples/multi-source-alfresco-project/build.gradle b/src/integrationTest/resources/examples/multi-source-alfresco-project/build.gradle index 7d59f8f..a731811 100644 --- a/src/integrationTest/resources/examples/multi-source-alfresco-project/build.gradle +++ b/src/integrationTest/resources/examples/multi-source-alfresco-project/build.gradle @@ -3,22 +3,27 @@ plugins { id 'eu.xenit.amp' } +version = "0.0.1" + sourceSets { main { - + amp { + module([ + "module.id": "${project.name}-repo", + "module.version": project.version + ]) + } } share { amp { module { - it.setProperty("module.id", project.name + "-share") + it.setProperty("module.id", "${project.name}-share") it.setProperty("module.version", project.version) } } } } -description = "HelloWorld Webscript, very useful" -version = "0.0.1" repositories { mavenCentral() diff --git a/src/main/java/eu/xenit/gradle/alfrescosdk/AmpBasePlugin.java b/src/main/java/eu/xenit/gradle/alfrescosdk/AmpBasePlugin.java index db6fc4d..c731911 100644 --- a/src/main/java/eu/xenit/gradle/alfrescosdk/AmpBasePlugin.java +++ b/src/main/java/eu/xenit/gradle/alfrescosdk/AmpBasePlugin.java @@ -56,9 +56,9 @@ public void apply(Project target) { } private static Map propertiesToMap(Properties properties) { - return properties.stringPropertyNames() + return properties.keySet() .stream() - .collect(Collectors.toMap(Function.identity(), properties::getProperty)); + .collect(Collectors.toMap(Object::toString, k -> properties.get(k).toString())); }