What's the best way to implement a shell command into my java project












0















I have a JavaFX/ Maven project.
While developing I sometimes need some Java code to run just once.



In my special case I have a directory containing configuration or temp files on the user's disk. This directory and its files will be created by the app when a new user is starting the app for the first time. In production, it will never be necessary to delete these files.
But in development, I sometimes change something in the file generation code. For example when I'm adding new configuration options. To test that I have to delete the directory manually and let my application regenerate everything to check if it still works.



In my years of coding, I had cases like that several times. And what I used to do was creating a method for this special task. Then I'm calling it from the main method and run the app.



I am sure I am not the only one and I am sure there is a better possibility.



I thought of creating some kind of command for the terminal to run my method.
Maybe a configuration in my IntelliJ which would call the method.










share|improve this question























  • Not knowing that much of maven, but in gradle you would simply write a task for it into the build script which you can execute on demand. I guess you can do the same in maven.

    – maio290
    Nov 13 '18 at 17:14











  • Thank you that already helps me a lot :)

    – primarykey123
    Nov 13 '18 at 18:03











  • I couldn't do it myself. So I figured out it's called "Mojo" what I want to create. I followed this guide maven.apache.org/guides/plugin/… to set one. I'm getting ArtifactResolutionException: Failure to find my.group:artifactId:jar:1.0 in repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. But how is it even supposed to! The artifact is the artifact itself! Also it looks like the tutorial guides to an app that's ONLY a plug

    – primarykey123
    Nov 13 '18 at 19:17
















0















I have a JavaFX/ Maven project.
While developing I sometimes need some Java code to run just once.



In my special case I have a directory containing configuration or temp files on the user's disk. This directory and its files will be created by the app when a new user is starting the app for the first time. In production, it will never be necessary to delete these files.
But in development, I sometimes change something in the file generation code. For example when I'm adding new configuration options. To test that I have to delete the directory manually and let my application regenerate everything to check if it still works.



In my years of coding, I had cases like that several times. And what I used to do was creating a method for this special task. Then I'm calling it from the main method and run the app.



I am sure I am not the only one and I am sure there is a better possibility.



I thought of creating some kind of command for the terminal to run my method.
Maybe a configuration in my IntelliJ which would call the method.










share|improve this question























  • Not knowing that much of maven, but in gradle you would simply write a task for it into the build script which you can execute on demand. I guess you can do the same in maven.

    – maio290
    Nov 13 '18 at 17:14











  • Thank you that already helps me a lot :)

    – primarykey123
    Nov 13 '18 at 18:03











  • I couldn't do it myself. So I figured out it's called "Mojo" what I want to create. I followed this guide maven.apache.org/guides/plugin/… to set one. I'm getting ArtifactResolutionException: Failure to find my.group:artifactId:jar:1.0 in repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. But how is it even supposed to! The artifact is the artifact itself! Also it looks like the tutorial guides to an app that's ONLY a plug

    – primarykey123
    Nov 13 '18 at 19:17














0












0








0








I have a JavaFX/ Maven project.
While developing I sometimes need some Java code to run just once.



In my special case I have a directory containing configuration or temp files on the user's disk. This directory and its files will be created by the app when a new user is starting the app for the first time. In production, it will never be necessary to delete these files.
But in development, I sometimes change something in the file generation code. For example when I'm adding new configuration options. To test that I have to delete the directory manually and let my application regenerate everything to check if it still works.



In my years of coding, I had cases like that several times. And what I used to do was creating a method for this special task. Then I'm calling it from the main method and run the app.



I am sure I am not the only one and I am sure there is a better possibility.



I thought of creating some kind of command for the terminal to run my method.
Maybe a configuration in my IntelliJ which would call the method.










share|improve this question














I have a JavaFX/ Maven project.
While developing I sometimes need some Java code to run just once.



In my special case I have a directory containing configuration or temp files on the user's disk. This directory and its files will be created by the app when a new user is starting the app for the first time. In production, it will never be necessary to delete these files.
But in development, I sometimes change something in the file generation code. For example when I'm adding new configuration options. To test that I have to delete the directory manually and let my application regenerate everything to check if it still works.



In my years of coding, I had cases like that several times. And what I used to do was creating a method for this special task. Then I'm calling it from the main method and run the app.



I am sure I am not the only one and I am sure there is a better possibility.



I thought of creating some kind of command for the terminal to run my method.
Maybe a configuration in my IntelliJ which would call the method.







java maven intellij-idea






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 17:13









primarykey123primarykey123

85




85













  • Not knowing that much of maven, but in gradle you would simply write a task for it into the build script which you can execute on demand. I guess you can do the same in maven.

    – maio290
    Nov 13 '18 at 17:14











  • Thank you that already helps me a lot :)

    – primarykey123
    Nov 13 '18 at 18:03











  • I couldn't do it myself. So I figured out it's called "Mojo" what I want to create. I followed this guide maven.apache.org/guides/plugin/… to set one. I'm getting ArtifactResolutionException: Failure to find my.group:artifactId:jar:1.0 in repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. But how is it even supposed to! The artifact is the artifact itself! Also it looks like the tutorial guides to an app that's ONLY a plug

    – primarykey123
    Nov 13 '18 at 19:17



















  • Not knowing that much of maven, but in gradle you would simply write a task for it into the build script which you can execute on demand. I guess you can do the same in maven.

    – maio290
    Nov 13 '18 at 17:14











  • Thank you that already helps me a lot :)

    – primarykey123
    Nov 13 '18 at 18:03











  • I couldn't do it myself. So I figured out it's called "Mojo" what I want to create. I followed this guide maven.apache.org/guides/plugin/… to set one. I'm getting ArtifactResolutionException: Failure to find my.group:artifactId:jar:1.0 in repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. But how is it even supposed to! The artifact is the artifact itself! Also it looks like the tutorial guides to an app that's ONLY a plug

    – primarykey123
    Nov 13 '18 at 19:17

















Not knowing that much of maven, but in gradle you would simply write a task for it into the build script which you can execute on demand. I guess you can do the same in maven.

– maio290
Nov 13 '18 at 17:14





Not knowing that much of maven, but in gradle you would simply write a task for it into the build script which you can execute on demand. I guess you can do the same in maven.

– maio290
Nov 13 '18 at 17:14













Thank you that already helps me a lot :)

– primarykey123
Nov 13 '18 at 18:03





Thank you that already helps me a lot :)

– primarykey123
Nov 13 '18 at 18:03













I couldn't do it myself. So I figured out it's called "Mojo" what I want to create. I followed this guide maven.apache.org/guides/plugin/… to set one. I'm getting ArtifactResolutionException: Failure to find my.group:artifactId:jar:1.0 in repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. But how is it even supposed to! The artifact is the artifact itself! Also it looks like the tutorial guides to an app that's ONLY a plug

– primarykey123
Nov 13 '18 at 19:17





I couldn't do it myself. So I figured out it's called "Mojo" what I want to create. I followed this guide maven.apache.org/guides/plugin/… to set one. I'm getting ArtifactResolutionException: Failure to find my.group:artifactId:jar:1.0 in repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. But how is it even supposed to! The artifact is the artifact itself! Also it looks like the tutorial guides to an app that's ONLY a plug

– primarykey123
Nov 13 '18 at 19:17












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286301%2fwhats-the-best-way-to-implement-a-shell-command-into-my-java-project%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286301%2fwhats-the-best-way-to-implement-a-shell-command-into-my-java-project%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma