konsoletyper / teavm

Compiles Java bytecode to JavaScript, WebAssembly and C
https://teavm.org
Apache License 2.0
2.61k stars 263 forks source link

maven plugin: `sourceFilesCopied` setting doesn't work #408

Open Namek opened 5 years ago

Namek commented 5 years ago

version: 0.6.0-dev-816

Issue:

Mapping files exist but they point to non-existing URLs like: http://localhost:8080/teavm/src/org/teavm/libgdx/emu/Matrix4Emulator.java In fact, maven plugin does not copy the source files.

Expected:

Directory demos/superjumper/webapp/target/teavm-libgdx-superjumper-webapp-0.1.0-SNAPSHOT containing index.html should also contain subfolder teavm/src.

Reproduction:

  1. Get code from branch https://github.com/Namek/teavm-libgdx/tree/master---repro_issues
  2. Run mvn package
  3. Observe following file list in subdirectory demos/superjumper/webapp:
|   pom.xml
|   teavm-libgdx-superjumper-webapp.iml
|   
+---src
|   \---main
|       +---java
|       |   \---org
|       |       \---teavm
|       |           \---libgdx
|       |               \---superjumper
|       |                       TeaVMLauncher.java
|       |                       
|       \---webapp
|           |   index.html
|           |   
|           +---assets
|           |   \---data
|           |           background.png
|           |           click.wav
|           |           coin.wav
|           |           font.fnt
|           |           font.png
|           |           help.png
|           |           help1.png
|           |           help2.png
|           |           help3.png
|           |           help4.png
|           |           help5.png
|           |           highjump.wav
|           |           hit.wav
|           |           items.png
|           |           items.ugh
|           |           jump.wav
|           |           music.mp3
|           |           
|           \---WEB-INF
|                   web.xml
|                   
\---target
    |   teavm-libgdx-superjumper-webapp-0.1.0-SNAPSHOT.war
    |   
    +---classes
    |   \---org
    |       \---teavm
    |           \---libgdx
    |               \---superjumper
    |                       TeaVMLauncher.class
    |                       
    +---generated
    |   |   filesystem.json
    |   |   
    |   +---assets
    |   |   \---com
    |   |       \---badlogic
    |   |           \---gdx
    |   |               +---graphics
    |   |               |   \---g3d
    |   |               |       +---particles
    |   |               |       |       particles.fragment.glsl
    |   |               |       |       particles.vertex.glsl
    |   |               |       |       
    |   |               |       \---shaders
    |   |               |               default.fragment.glsl
    |   |               |               default.vertex.glsl
    |   |               |               depth.fragment.glsl
    |   |               |               depth.vertex.glsl
    |   |               |               
    |   |               \---utils
    |   |                       arial-15.fnt
    |   |                       arial-15.png
    |   |                       
    |   \---teavm
    |           classes.js
    |           classes.js.map
    |           classes.js.teavmdbg
    |           
    +---generated-sources
    |   \---annotations
    +---maven-archiver
    |       pom.properties
    |       
    +---maven-status
    |   \---maven-compiler-plugin
    |       \---compile
    |           \---default-compile
    |                   createdFiles.lst
    |                   inputFiles.lst
    |                   
    \---teavm-libgdx-superjumper-webapp-0.1.0-SNAPSHOT
        |   filesystem.json
        |   index.html
        |   
        +---assets
        |   +---com
        |   |   \---badlogic
        |   |       \---gdx
        |   |           +---graphics
        |   |           |   \---g3d
        |   |           |       +---particles
        |   |           |       |       particles.fragment.glsl
        |   |           |       |       particles.vertex.glsl
        |   |           |       |       
        |   |           |       \---shaders
        |   |           |               default.fragment.glsl
        |   |           |               default.vertex.glsl
        |   |           |               depth.fragment.glsl
        |   |           |               depth.vertex.glsl
        |   |           |               
        |   |           \---utils
        |   |                   arial-15.fnt
        |   |                   arial-15.png
        |   |                   
        |   \---data
        |           background.png
        |           click.wav
        |           coin.wav
        |           font.fnt
        |           font.png
        |           help.png
        |           help1.png
        |           help2.png
        |           help3.png
        |           help4.png
        |           help5.png
        |           highjump.wav
        |           hit.wav
        |           items.png
        |           items.ugh
        |           jump.wav
        |           music.mp3
        |           
        +---META-INF
        +---teavm
        |       classes.js
        |       classes.js.map
        |       classes.js.teavmdbg
        |       
        \---WEB-INF
            |   web.xml
            |   
            \---classes
                \---org
                    \---teavm
                        \---libgdx
                            \---superjumper
                                    TeaVMLauncher.class

The configuration has:

<minifying>false</minifying>
<debugInformationGenerated>true</debugInformationGenerated>
<sourceMapsGenerated>true</sourceMapsGenerated>
<sourceFilesCopied>true</sourceFilesCopied>

while the minifying doesn't matter, source code does not appear anyway.

konsoletyper commented 5 years ago

This might be due to Maven does not know where to get sources. It usually happens on multimodule projects. When building module A which depends on module B, both on the same project, A does not 'see' B content, it 'sees' B as a regular artifact, thus it's impossible to obrain B sources unless you set up maven-source-plugin. Instead, you can use IDEA code server, which is not documented yet.

eriklumme commented 4 years ago

This also happens when using optimizationLevel SIMPLE, as then it uses the lazyPipeline() method for building, and this never sets the writtenClasses field. This seems to have been fixed in the 0.7.x dev branch, though.

Edit: Can confirm, with SIMPLE it works in 0.7.0-dev-1128.