在Anypoint Studio 7中,是否有一种方式可以在构建完成时设置音频提示?

huangapple go评论66阅读模式
英文:

In Anypoint Studio 7, Is there any way to setup an audio cue when my build is done?

问题

我正在寻找一种方法,在Anypoint Studio 7构建项目完成后设置音频提示,因为我已经厌倦了等待构建完成,我想在构建过程中做其他事情,但也希望能够尽快返回工作以提高效率。我找到了这个有趣的页面,介绍了如何在Eclipse上设置这个功能:
https://mcuoneclipse.com/2021/04/20/play-a-sound-at-the-end-of-the-build-with-eclipse/

由于Studio是基于Eclipse的,我认为可以以相同的方式设置它,但我找不到页面上显示的“Post-Build”步骤。是否有任何方法可以访问这些步骤,或者也许有其他设置音频提示的方法?

英文:

I am looking for a way to set up an audio cue when my Anypoint Studio 7 is done building a project, as I am just fed up with having to wait so long for a build, I want to do something else during the build but also want to work efficiently by returning back to work as soon as the build is done. I have found this interesting page how to set it up on Eclipse:
https://mcuoneclipse.com/2021/04/20/play-a-sound-at-the-end-of-the-build-with-eclipse/

Since Studio is based on Eclipse, I thought I could set it up the same way, but I cant find the Post-Build steps shown on the page. Is there any way I can access those steps or is there maybe another way to setup an audio cue?

答案1

得分: 1

你分享的文章展示了Eclipse C/C++ Development Tools插件的特定功能,该插件仅用于构建C/C++项目。对于Java项目或Anypoint Studio项目,没有类似的功能。

虽然我不建议这样做,但一个替代方法是创建一个命令行脚本(在Windows中为.bat/.ps,在其他平台为.sh),该脚本将执行Maven(传递相同的参数),然后执行一个蜂鸣声命令。在Anypoint Studio首选项中,您可以更改用于执行Maven的命令,默认情况下称为mvn。应该可以将您的自定义脚本添加到相同的MAVEN_HOME/bin目录中。

我强烈建议不要修改Maven分发的脚本。这是一个不良实践,可能会在更新时导致混淆或破坏。

英文:

The article you shared showed a feature specific of the Eclipse C/C++ Development Tools plugin, which only builds C/C++ projects. There is not a similar feature for Java projects nor Anypoint Studio projects.

While I would not recommend it, an alternative could be to create a command line (.bat/.ps in Windows)/shell script (.sh for other platforms) that would execute Maven (passing the same arguments) and then execute a beep command. In Anypoint Studio preferences you can change the command used to execute Maven, which is called mvn by default. It should be possible to add your custom script in the same MAVEN_HOME/bin directory.

I strongly advice against modifying the scripts from the Maven distribution. That is a bad practice and could cause confusions if not breakings with updates.

答案2

得分: 0

我找到了一种解决方案。

有一个名为exec-maven-plugin的Maven插件,允许在构建生命周期的某些阶段运行应用程序。您可以将它添加到pom.xml中的plugins标签中:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>${basedir}/Beep.bat</executable>
            </configuration>
        </execution>
    </executions>
</plugin>

这将在项目的根目录中的file.bat文件,与pom.xml在同一级别,一旦构建进入'package'生命周期时运行。在我的问题中,有一个链接提到如何创建这样的.bat文件。

这种方法的问题在于它关注的是Maven生命周期,而不是Anypoint Studio的生命周期。我希望文件在控制台通知我部署成功后立即执行,但似乎不是'deploy'生命周期。

我只是希望在我可以发送Postman请求,也就是达到这个控制台消息时,立即收到一个音频提示:
在Anypoint Studio 7中,是否有一种方式可以在构建完成时设置音频提示?

英文:

I found somewhat of a solution.

There is a maven plugin exec-maven-plugin that allows for running applications at certain stages of the build lifecycle. You add this in the pom.xml inside the plugins tag:

        &lt;plugin&gt;
            &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
            &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.1.0&lt;/version&gt;
            &lt;executions&gt;
                &lt;execution&gt;
                    &lt;phase&gt;package&lt;/phase&gt;
                    &lt;goals&gt;
                        &lt;goal&gt;exec&lt;/goal&gt;
                    &lt;/goals&gt;
                    &lt;configuration&gt;
                        &lt;executable&gt;${basedir}/Beep.bat&lt;/executable&gt;
                    &lt;/configuration&gt;
                &lt;/execution&gt;
            &lt;/executions&gt;
        &lt;/plugin&gt;

This will run the file.bat in the root of the project, same level as the pom.xml, as soon as the build enters the 'package' lifecycle. In my question there is a link that mentions how to make such a .bat file.

The problem with this method is that it looks at the maven lifecycle, and not the Anypoint Studio one. I want the file to be executed as soon as the console informs me that the deployment was successful, but it seems that it is not the 'deploy' lifecycle.

I just want an audio cue as soon as I can send a Postman request aka get to this console message:
在Anypoint Studio 7中,是否有一种方式可以在构建完成时设置音频提示?

huangapple
  • 本文由 发表于 2023年8月10日 20:59:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76875962.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定