cincheo / jsweet-eclipse-plugin

The official Eclipse plugin for the JSweet transpiler
http://www.jsweet.org
Apache License 2.0
20 stars 10 forks source link

Starting a blank project with Eclipse plugin #19

Open travelbasys opened 6 years ago

travelbasys commented 6 years ago

Hello. I am using Eclipse Neon with Java SDK 1.8.0_111 and added the latest Maven (m2e 1.8.1) and JSweet (0.9.5) plugins just a few days ago. With these, jsweet-quickstart from GitHub works allright, has proper code completion and builds automatically. Fine.

My POM ends up looking like this:

<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>jsweet-tutorial</groupId>
    <artifactId>jsweet-tutorial</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <!-- repositories -->
    <repositories>
        <repository>
            <id>jsweet-central</id>
            <name>libs-release</name>
            <url>http://repository.jsweet.org/artifactory/libs-release-local</url>
        </repository>
        <repository>
            <snapshots />
            <id>jsweet-snapshots</id>
            <name>libs-snapshot</name>
            <url>http://repository.jsweet.org/artifactory/libs-snapshot-local</url>
        </repository>
    </repositories>
    <!-- end repositories -->
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <!-- dependencies -->
    <dependencies>
        <!-- JSweet core API -->
        <dependency>
            <groupId>org.jsweet.candies</groupId>
            <artifactId>jsweet-core</artifactId>
            <version>5-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <!-- end dependencies -->
</project>

When I store it (and refresh the project) Eclipse does not add "Maven Dependencies" to the project.

I also created class helloworld.HelloWorld.java as the tutorial says. But naturally, code completion after entering "al" does not suggest alert and jsweet.dom.Globals is not found.

What could be wrong? I have the strong feeling that my POM cannot be right because jsweet-quickstart as loaded from GitHub works allright and that one has quite a different POM.

Thanks for advice.

travelbasys commented 6 years ago

Works now. But the instructions given are somewhat broken and do not agree with the current JSweet release.

The POM should look like this (the last dependency should be corrected):

<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>jsweet-tutorial</groupId>
    <artifactId>jsweet-tutorial</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <!-- repositories -->
    <repositories>
        <repository>
            <id>jsweet-central</id>
            <name>libs-release</name>
            <url>http://repository.jsweet.org/artifactory/libs-release-local</url>
        </repository>
        <repository>
            <snapshots />
            <id>jsweet-snapshots</id>
            <name>libs-snapshot</name>
            <url>http://repository.jsweet.org/artifactory/libs-snapshot-local</url>
        </repository>
    </repositories>
    <!-- end repositories -->
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <!-- dependencies -->
    <dependencies>
        <!-- JSweet core API -->
        <dependency>
            <groupId>org.jsweet</groupId>
            <artifactId>jsweet-core</artifactId>
            <version>5-20170726</version>
        </dependency>
    </dependencies>
    <!-- end dependencies -->
</project>

I have the impression, that after storing the POM one should clean and build the project for the Maven dependencies to show up.

And the Java code should not be as told in the instruction:

package helloworld;

import static jsweet.dom.Globals.*;
import jsweet.dom.HTMLElement;

public class Globals {
    public static void main(String[] args) {
        alert("This example writes 'Hello world' in the document!");
        HTMLElement e = document.getElementById("target");
        e.innerHTML = "Hello world!";
    }
}

But rather:

package helloworld;

import static def.dom.Globals.*;
import def.dom.HTMLElement;

public class HelloWorld {
    public static void main(String[] args) {
        alert("This example writes 'Hello world' in the document!");
        HTMLElement e = document.getElementById("target");
        e.innerHTML = "Hello world!";
    }
}

Note that jsweet.dom was changed in favour of def.dom.