4

I'm able to build an executable jar of my Xtext project with Maven (I want to automate the process for CI)

But, I have an error during the execution. The execution succeed even if there is this error. I attached the pom.xml for the package goal.

error :

    1    [main] ERROR xt.validation.ResourceValidatorImpl  - The string resource '_UI_DiagnosticRoot_diagnostic' could not be located
java.util.MissingResourceException: The string resource '_UI_DiagnosticRoot_diagnostic' could not be located
        at org.eclipse.emf.common.util.DelegatingResourceLocator.delegatedGetString(DelegatingResourceLocator.java:541)
        at org.eclipse.emf.common.util.DelegatingResourceLocator.getString(DelegatingResourceLocator.java:445)
        at org.eclipse.emf.common.util.DelegatingResourceLocator.getString(DelegatingResourceLocator.java:560)
        at org.eclipse.emf.common.util.DelegatingResourceLocator.getString(DelegatingResourceLocator.java:552)
        at org.eclipse.emf.ecore.util.Diagnostician.createDefaultDiagnostic(Diagnostician.java:111)
        at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:140)
        at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:147)
        at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:125)
        at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:91)
        at langage.generator.Main.runGenerator(Main.java:66)
        at langage.generator.Main.main(Main.java:35)

pom.xml :

<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>comp_go</groupId>  
    <artifactId>go.prettyprinter</artifactId>  
    <version>1</version>  

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       <java.version>1.8</java.version>
       <maven.compiler.source>1.8</maven.compiler.source>
       <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <finalName>Main</finalName>
        <sourceDirectory>src/langage/generator</sourceDirectory>
        <outputDirectory>target/classes</outputDirectory>
         <!-- PLUGINS -->
        <plugins>
            <plugin>
            <groupId>org.eclipse.xtend</groupId>    
            <artifactId>xtend-maven-plugin</artifactId>
            <version>2.23.0</version>
            <dependencies>
                <dependency>
                    <groupId>org.eclipse.platform</groupId>
                    <artifactId>org.eclipse.equinox.common</artifactId>
                    <version>3.10.0</version>
                </dependency>
            </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>langage.generator.Main</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <!-- DEPENDENCES -->
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.eclipse.emf/ecore -->
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>org.eclipse.emf.ecore</artifactId>
            <version>2.6.0.v20100614-1136</version>
        </dependency>
        <dependency>
                <groupId>org.eclipse.emf</groupId>
                <artifactId>org.eclipse.emf.common</artifactId>
                <version>2.20.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.inject/guice -->
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>5.0.0-BETA-1</version>
        </dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.xtext/org.eclipse.xtext -->
<dependency>
    <groupId>org.eclipse.xtext</groupId>
    <artifactId>org.eclipse.xtext</artifactId>
    <version>2.23.0</version>
</dependency>
    </dependencies>
</project>

I guess the error comes from the dependency com.google.inject which isn't 100% compatible but it's a real problem, the pipeline fails because of this.

Valentin
  • 41
  • 4
  • here is what the new Xtext project wizard does: https://github.com/eclipse/xtext-core/blob/fecf0e7268b9396a76cf7487d7e261b0107f9818/org.eclipse.xtext.tests/testdata/wizard-expectations/lsMavenFatjar/lsMavenFatjar.parent/lsMavenFatjar.ide/pom.xml#L58 – Christian Dietrich Dec 07 '20 at 07:38

1 Answers1

1

Explanation:

emf.common needs a plugin.properties file that has a value for _UI_DiagnosticRoot_diagnostic.

Solution:

1- Create a new folder called resources at the root of your project.

2- Inside the folder, create 'plugin.properties' file

3- Inside the created folder, write the following command:

_UI_DiagnosticRoot_diagnostic=_UI_DiagnosticRoot_diagnostic

4- Clean your Project, then update it, and generate your jar file.

5- To check that the file has built correctly, go to Target -> classes, and you should find it (plugin.properties) beside your root folder and META-INF.

For everyone has the same issue, make sure that you've added the following dependencies

 <dependency>
        <groupId>org.eclipse.emf</groupId>
        <artifactId>org.eclipse.emf.ecore</artifactId>
        <version>2.6.0.v20100614-1136</version>
    </dependency>
    <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>org.eclipse.emf.common</artifactId>
            <version>2.20.0</version>
    </dependency>
Fadi
  • 585
  • 4
  • 22
  • 1
    if you use maven shade plugin: https://github.com/eclipse/xtext-core/blob/88f8155579d5562753f10f978277e993961c72db/org.eclipse.xtext.xtext.wizard/src/org/eclipse/xtext/xtext/wizard/IdeProjectDescriptor.xtend#L205 – Christian Dietrich Jul 01 '22 at 18:58