BowlerHatLLC / vscode-as3mxml

ActionScript & MXML language extension for Visual Studio Code. Develop apps for Adobe AIR, Adobe Flash Player, or Apache Royale.
https://as3mxml.com/
Apache License 2.0
256 stars 39 forks source link

Support for compiling in sub directories #718

Closed velara3 closed 9 months ago

velara3 commented 9 months ago

I have a project where I have the AS file in a project sub directory and I'm having issues.

Here's the project structure:

/project
    /public
       - MyApp.as
       - asconfig.json

Here is my asconfig.json:

{
    "config": "js",
    "compilerOptions": {
        "source-path": [
            "public"
        ],
        "js-output": "bin",
        "source-map": true
    },
    "mainClass": "MyApp"
}

Here's MyApp.as:


package {
    public class MyApp {
        public var submitButton: HTMLInputElement;

        public function MyApp() {
            bindView();
        }

        public function bindView(): void {
            submitButton = document.getElementById("passwordInput") as HTMLInputElement;
        }
    }
}

Here's the console message when calling build:

Executing task: /usr/bin/java -jar /Users/user/.vscode/extensions/bowlerhatllc.vscode-as3mxml-1.19.0/bin/asconfigc.jar --sdk /Users/user/Documents/sdk/apache-royale-0.9.10-bin-js/royale-asjs --debug=true --project /Users/user/Documents/project/public/asconfig.json 

MXMLJSC
+royalelib=/Users/user/Documents/sdk/apache-royale-0.9.10-bin-js/royale-asjs/frameworks
--debug=true
+configname=js
--source-path+=public
--js-output=bin
--source-map=true
--js-output-type=jsc
--
public/MyApp.as
command line Error: unable to open '/Users/user/Documents/project/public/public'.

If I remove the source path argument or if I use a dot or a slash (for current directory) I get another error:

Main class not found in source paths: MyApp

velara3 commented 9 months ago

If I move the asconfig.json to the root of the project and then run it I get the following error:

Error: The actionscript task detection didn't contribute a task for the following configuration:
{
    "type": "actionscript",
    "debug": true,
    "asconfig": "asconfig.json",
    "group": {
        "kind": "build",
        "isDefault": true
    },
    "problemMatcher": [],
    "label": "ActionScript: compile debug - asconfig.json"
}
The task will be ignored.

Moved asconfig.json:

{
    "config": "js",
    "compilerOptions": {
        "source-path": [
            "public",
            "/public"
        ],
        "js-output": "bin",
        "source-map": true
    },
    "mainClass": "MyApp"
}
velara3 commented 9 months ago

If I move the asconfig file to the root directory, then rename the source directory to src and move the as file to the src directory then I can get it to run:

{
    "config": "js",
    "compilerOptions": {
        "source-path": [
            "src"
        ],
        "html-template": "template.html",
        "source-map": true
    },
    "mainClass": "MyApp"
}

I also added the template.html option back into to the compiler and then updated the task:

tasks:

        {
            "type": "actionscript",
            "debug": false,
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": [],
            "label": "ActionScript: compile release - asconfig.json"
        }

So it works with the default project structure but for me not with a different structure than default.

joshtynjala commented 9 months ago

I have a project where I have the AS file in a project sub directory and I'm having issues.

Adding public to the source-path of public/asconfig.json wouldn't work here because there is no public/public directory, so the error is correct. The source-path, if it is not absolute, is supposed to be relative to the directory that contains asconfig.json.

If I remove the source path argument or if I use a dot or a slash (for current directory) I get another error:

If a dot doesn't work, that's definitely a bug.

Error: The actionscript task detection didn't contribute a task for the following configuration

If the file is asconfig.json in the root directory, remove the line: "asconfig": "asconfig.json". The asconfig field in tasks.json is needed only for a non-default location. I wish that I could allow "asconfig": "asconfig.json" and no asconfig field at all to mean the same thing, but it is a limitation of VSCode's task system not to allow missing fields to be resolved dynamically.