Fork me on GitHub

Home Forums JSweet Discussion How to include source from another Maven project?

This topic contains 2 replies, has 2 voices, and was last updated by Avatar Louis Grignon 1 year, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2117
    Avatar
    Anonymous

    I have two Java Maven projects, one with my core files that compiles to a jar, and a second new one with JSweet that I’d like to use to create a web app based on them. I’ve set up the pom of my second project by customizing the pom from the JSweet quickstart, but am having trouble figuring out how to get my second project to reference the source and/or jars from my first project. Both projects have their root in the same directory.

    My attempt to build with JSweet ends with the below error message. The file it is referring to is located in my core project:

    2018-07-14 01:26:50.050 ERROR output:55 - namespace 'com.kitfox.macaw' has no exported member 'data' at D:\dev\starling2\game\2018\Macaw2\MacawJsweet\src\main\java\com\kitfox\macaw\jsweet\NewMain.java(23)

    And this is the pom I’m using. It’s basically the quickstart pom with my project added in to the dependencies section:

    <?xml version="1.0" encoding="UTF-8"?>
    <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>com.kitfox.macaw</groupId>
        <artifactId>MacawJsweet</artifactId>
        <version>1.0-SNAPSHOT</version>
        <name>Macaw Web App</name>
        <developers>
            <developer>
                <id>kitfox</id>
                <name>Mark McKay</name>
            </developer>
        </developers>
        <licenses>
            <license>
                <name>The Apache Software License, Version 2.0</name>
                <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
                <distribution>repo</distribution>
            </license>
        </licenses>
        <pluginRepositories>
            <pluginRepository>
                <id>jsweet-plugins-release</id>
                <name>plugins-release</name>
                <url>http://repository.jsweet.org/artifactory/plugins-release-local</url>
            </pluginRepository>
            <pluginRepository>
                <snapshots />
                <id>jsweet-plugins-snapshots</id>
                <name>plugins-snapshot</name>
                <url>http://repository.jsweet.org/artifactory/plugins-snapshot-local</url>
            </pluginRepository>
        </pluginRepositories>
        <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>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.kitfox.macaw</groupId>
                    <artifactId>MacawCore</artifactId>
                    <version>1.0-SNAPSHOT</version>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <fork>true</fork>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jsweet</groupId>
                    <artifactId>jsweet-maven-plugin</artifactId>
                    <version>2.2.0-SNAPSHOT</version>
                    <configuration>
                        <verbose>true</verbose>
                        <tsOut>target/ts</tsOut>
                        <outDir>target/js</outDir>
                        <candiesJsOut>webapp</candiesJsOut>
                        <targetVersion>ES6</targetVersion>
                        <!-- bundle your JS automatically -->
                        <bundle>true</bundle>
                        <!-- end of bundle configuration -->
                    </configuration>
                    <executions>
                        <execution>
                            <id>generate-js</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>jsweet</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    
        <dependencies>
            <dependency>
                <groupId>org.jsweet</groupId>
                <artifactId>jsweet-core</artifactId>
                <version>6-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.jsweet.candies</groupId>
                <artifactId>jquery</artifactId>
                <version>1.10.0-20170726</version>
            </dependency>
            <dependency>
                <groupId>com.kitfox.macaw</groupId>
                <artifactId>MacawCore</artifactId>
                <version>1.0-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </project>
    #2118
    Avatar
    Anonymous

    Adding the extra directory to my build seems to have worked:

        <build>
            <sourceDirectory>src/main/java, ../MacawCore/src/main/java</sourceDirectory>
    #2119
    Avatar
    Louis Grignon
    Keymaster

    Nice! I didn’t know you can specify multiple sources directories, comma separated in Maven.
    I was about to recommend you to package your core lib as a candy:
    https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md#packaging-a-jsweet-jar-candy

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘JSweet Discussion’ is closed to new topics and replies.