Skip to content

Commit

Permalink
[maven] Fixing invalid source folder definitions.
Browse files Browse the repository at this point in the history
close #504

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Sep 29, 2016
1 parent af48213 commit 600ef4f
Show file tree
Hide file tree
Showing 16 changed files with 607 additions and 37 deletions.
78 changes: 78 additions & 0 deletions maven/sarl-maven-plugin/generate_pom.pl
@@ -0,0 +1,78 @@
#!/usr/bin/env perl

use strict;

my @BASE_MODULES = ("io.sarl.lang", "io.sarl.lang.core", "org.eclipse.osgi", "org.eclipse.xtend.core");

my %MODULE_MAP = (
"io.sarl.lang" => "io.sarl.lang:io.sarl.lang",
"io.sarl.lang.core" => "io.sarl.lang:io.sarl.lang.core",
"org.eclipse.osgi" => "org.eclipse:osgi",
"org.eclipse.xtend.core" => "org.eclipse.xtend:org.eclipse.xtend.core",
);

use File::Basename;
use File::Spec;

my $SCRIPT_DIR = File::Spec->rel2abs(dirname($0));
my $IN_FILENAME = File::Spec->catfile("$SCRIPT_DIR", "src-templates", "pom.template");
my $OUT_FILENAME = File::Spec->catfile("$SCRIPT_DIR", "pom.xml");

local *INFILE;

open(*INFILE, "< $IN_FILENAME") or die("$IN_FILENAME: $!\n");
my $content = '';
while (my $line = <INFILE>) {
$content .= "$line";
}
close(*INFILE);

my $dependencyList = '';
my $mavenDependencies = '';

my @deps = (@BASE_MODULES);

while (@deps) {
my $dep = shift @deps;
if (!exists $MODULE_MAP{$dep} || !$MODULE_MAP{$dep}) {
die("Undefined mapping from Eclipse plugin '$dep' to equivalent Maven artifact.");
}
if ($dependencyList) {
$dependencyList .= ", ";
}
my $groupId;
my $artifactId;
if ($MODULE_MAP{$dep} =~ /^([^:]+):([^:]+)$/) {
$groupId = "$1";
$artifactId = "$2";
} else {
die("Invalid format for '$MODULE_MAP{$dep}'.");
}
$dependencyList .= $MODULE_MAP{$dep};
$mavenDependencies .= "\t\t<dependency>\n";
$mavenDependencies .= "\t\t\t<groupId>$groupId</groupId>\n";
$mavenDependencies .= "\t\t\t<artifactId>$artifactId</artifactId>\n";
if ($dep =~ /^io\.sarl/) {
$mavenDependencies .= "\t\t\t<exclusions>\n";
$mavenDependencies .= "\t\t\t\t<exclusion>\n";
$mavenDependencies .= "\t\t\t\t\t<groupId>*</groupId>\n";
$mavenDependencies .= "\t\t\t\t\t<artifactId>*</artifactId>\n";
$mavenDependencies .= "\t\t\t\t</exclusion>\n";
$mavenDependencies .= "\t\t\t</exclusions>\n";
}
$mavenDependencies .= "\t\t</dependency>\n";
}

$content =~ s/%\%DEPENDENCY_LIST%%/$dependencyList/sg;
$content =~ s/%\%MAVEN_DEPENDENCIES%%/\n$mavenDependencies/sg;

local *OUTFILE;
open(*OUTFILE, "> $OUT_FILENAME") or die("$OUT_FILENAME: $!\n");
print OUTFILE "<!-- *******************************************************\n";
print OUTFILE " * This file is automatically generated. Do not change it. *\n";
print OUTFILE " ******************************************************* -->\n\n";
print OUTFILE ($content);
close(*OUTFILE);

exit(0);

46 changes: 27 additions & 19 deletions maven/sarl-maven-plugin/pom.xml
@@ -1,3 +1,7 @@
<!-- *******************************************************
* This file is automatically generated. Do not change it. *
******************************************************* -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
Expand All @@ -19,22 +23,8 @@
<dependency.xtext-compiler.groupId>org.eclipse.xtext</dependency.xtext-compiler.groupId>
<dependency.xtext-compiler.artifactId>xtext-maven-plugin</dependency.xtext-compiler.artifactId>
<dependency.xtext-compiler.mojo>generate</dependency.xtext-compiler.mojo>
<!-- The following dependencies are required by the Xtext compiler.
They must appear as Maven dependencies for ensuring the Jar files are available.
BUNDLE = MAVEN ARTIFACT
=======================================================================
javax.inject = javax.inject:javax.inject
com.google.inject = com.google.inject:guice
org.eclipse.osgi = org.eclipse:osgi
org.eclipse.xtext.xbase.lib = org.eclipse.xtext:org.eclipse.xtext.xbase.lib
org.eclipse.xtend.lib = org.eclipse.xtend:org.eclipse.xtend.lib
io.sarl.lang = io.sarl.lang:io.sarl.lang
io.sarl.lang.core = io.sarl.lang:io.sarl.lang.core
-->
<dependency.xtext-compiler.dependencies>
io.sarl.lang:io.sarl.lang; \
io.sarl.lang:io.sarl.lang.core; \
org.eclipse.xtend:org.eclipse.xtend.core
io.sarl.lang:io.sarl.lang, io.sarl.lang:io.sarl.lang.core, org.eclipse:osgi, org.eclipse.xtend:org.eclipse.xtend.core
</dependency.xtext-compiler.dependencies>
<dependency.java-compiler.groupId>org.apache.maven.plugins</dependency.java-compiler.groupId>
<dependency.java-compiler.artifactId>maven-compiler-plugin</dependency.java-compiler.artifactId>
Expand Down Expand Up @@ -62,10 +52,6 @@
<groupId>org.arakhne.afc.core</groupId>
<artifactId>vmutils</artifactId>
</dependency>
<dependency>
<groupId>io.sarl.lang</groupId>
<artifactId>io.sarl.lang</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -79,14 +65,36 @@
<groupId>org.eclipse.xtext</groupId>
<artifactId>xtext-maven-plugin</artifactId>
</dependency>

<dependency>
<groupId>io.sarl.lang</groupId>
<artifactId>io.sarl.lang</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.sarl.lang</groupId>
<artifactId>io.sarl.lang.core</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.xtend</groupId>
<artifactId>org.eclipse.xtend.core</artifactId>
</dependency>

<!-- The following dependencies are required for testing this maven plugin -->
<dependency>
<groupId>junit</groupId>
Expand Down
118 changes: 118 additions & 0 deletions maven/sarl-maven-plugin/src-templates/functional_pom.xml
@@ -0,0 +1,118 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupid</groupId>
<artifactId>artifactid</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<janus.version>2.0.5.0-SNAPSHOT</janus.version>
<sarl.version>0.5.0-SNAPSHOT</sarl.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/sarl/</source>
<source>target/xtext-temp/stubs/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.xtext</groupId>
<artifactId>xtext-maven-plugin</artifactId>
<version>2.10.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
<compilerSourceLevel>1.8</compilerSourceLevel>
<compilerTargetLevel>1.8</compilerTargetLevel>
<failOnValidationError>true</failOnValidationError>
<languages>
<language>
<setup>io.sarl.lang.SARLStandaloneSetup</setup>
<outputConfigurations>
<outputConfiguration>
<createOutputDirectory>true</createOutputDirectory>
<outputDirectory>target/xtext-temp/stubs/</outputDirectory>
</outputConfiguration>
</outputConfigurations>
</language>
</languages>
</configuration>
<dependencies>
<dependency>
<groupId>io.sarl.lang</groupId>
<artifactId>io.sarl.lang</artifactId>
<version>${sarl.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.sarl.lang</groupId>
<artifactId>io.sarl.lang.core</artifactId>
<version>${sarl.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
<version>3.10.0-v20140606-1445</version>
</dependency>
<dependency>
<groupId>org.eclipse.xtend</groupId>
<artifactId>org.eclipse.xtend.core</artifactId>
<version>2.10.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>io.sarl.maven</groupId>
<artifactId>io.sarl.maven.sdk</artifactId>
<version>${sarl.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.janusproject</groupId>-->
<!-- <artifactId>io.janusproject.kernel</artifactId>-->
<!-- <version>${janus.version}</version>-->
<!-- </dependency>-->
</dependencies>
</project>

0 comments on commit 600ef4f

Please sign in to comment.