Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variable to tasks.json for filename without extension #1104

Closed
felixfbecker opened this issue Dec 8, 2015 · 4 comments
Closed

Add variable to tasks.json for filename without extension #1104

felixfbecker opened this issue Dec 8, 2015 · 4 comments
Assignees
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@felixfbecker
Copy link
Contributor

Like ${fileBasename}, but without the extension. Use case is I want to write a task configuration to run JUnit tests in Java (besides other tasks). My tasks.json:

{
    "version": "0.1.0",
    "isShellCommand": true,
        "suppressTaskName": true,
    "linux": {
        "command": "sh",
        "args": ["-c"]
    },
    "windows": {
        "command": "cmd",
        "args": ["/C"]
    },
    "tasks": [
        {
            "taskName": "JUnit Test",
            "args": ["java org.junit.runner.JUnitCore ${fileBasename}"],
            "isTestCommand": true
        }
    ]
}

(I'm using the workaround described in #981, but this is unrelated)
The task is supposed to run JUnit test for the currently opened file. The problem is, JUnit expects a class name, not a file name. So instead of MyTest.java I need to pass just MyTest. Please add a variable like ${fileBasenameWithoutExtension}.

@felixfbecker
Copy link
Contributor Author

I found a temporary workaround, using powershell instead of cmd:

$class = [System.IO.Path]::GetFileNameWithoutExtension('${fileBasename}'); java org.junit.runner.JUnitCore $class

@egamma egamma added feature-request Request for new features or functionality tasks Task system issues labels Dec 9, 2015
@egamma egamma modified the milestone: Backlog Dec 10, 2015
@isidorn isidorn assigned isidorn and unassigned dbaeumer Oct 28, 2016
@isidorn isidorn modified the milestones: November 2016, Backlog Oct 28, 2016
@isidorn isidorn removed the tasks Task system issues label Oct 28, 2016
@isidorn isidorn closed this as completed in 69b02b1 Nov 1, 2016
@isidorn
Copy link
Contributor

isidorn commented Nov 1, 2016

We have introduced ${fileBasenameNoExtension}
@gregvanl could you please document this in our docs for subsitituting variables?

@felixfbecker
Copy link
Contributor Author

@isidorn
Copy link
Contributor

isidorn commented Nov 29, 2016

@felixfbecker just created microsoft/vscode-docs#690

@isidorn isidorn added the verification-needed Verification of issue is requested label Dec 6, 2016
@weinand weinand added the verified Verification succeeded label Dec 7, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants