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

Usage in Maven Antrun Plugin #56

Open
russellhoff opened this issue Mar 12, 2019 · 0 comments
Open

Usage in Maven Antrun Plugin #56

russellhoff opened this issue Mar 12, 2019 · 0 comments

Comments

@russellhoff
Copy link

I've got several computers and I want to execute certain commands for each of them:

  • Stop pasada service.
  • Copy through SCP the new version of asada into the computer.
  • Start pasada service.

To do so, I'm using maven-antrun-plugin, which looks like the following code:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
            <id>scp-to-remote</id>
            <phase>package</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <target>
                    <sshexec trust="true" failonerror="true"
                        host="asa2071.dyndns.org"
                        username="pi" 
                        password="mypass"
                        command="sudo systemctl stop pasada"
                        timeout="120000" />	
                    <scp 
                        localFile="${project.basedir}/target/pasada-2.0.0.RELEASE.jar"
                        remoteToFile="pi@asa2071.dyndns.org:/home/pi/asada/pasada/pasada.jar" verbose="true"
                        password="mypass" trust="true">
                    </scp>
                    <sshexec trust="true" failonerror="true"
                        host="asa2071.dyndns.org"
                        username="pi"
                        password="mypass"
                        command="sudo systemctl start pasada"
                        timeout="120000" />	
                </target>
            </configuration>
        </execution>
    </executions>
    <!-- libraries for scp impl -->
    <!-- antrun doesn't use os's scp -->
    <dependencies>
        <dependency>
            <groupId>com.jcraft</groupId>
            <artifactId>jsch</artifactId>
            <version>0.1.53</version>
        </dependency>
        <dependency>
            <groupId>ant</groupId>
            <artifactId>ant-jsch</artifactId>
            <version>1.6.5</version>
        </dependency>
    </dependencies>
</plugin>

The previous code is working well when invoking mvn package.

I've found your plugin and I'd like to integrate maven-antrun-plugin with it. So far, I've written the following code:

<plugin>
    <groupId>com.soebes.maven.plugins</groupId>
    <artifactId>iterator-maven-plugin</artifactId>
    <version>0.5.1</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>iterator</goal>
            </goals>
            <configuration>
                <content>2071,2076</content>
                <pluginExecutors>
                    <pluginExecutor>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-antrun-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>scp-to-remote</id>
                                    <phase>package</phase>
                                    <goals>
                                        <goal>run</goal>
                                    </goals>
                                    <configuration>
                                        <target>
                                            <sshexec trust="true" failonerror="true"
                                                host="asa@item@.dyndns.org"
                                                username="pi" 
                                                password="mypass"
                                                command="sudo systemctl stop pasada"
                                                timeout="120000" />	
                                            <scp 
                                                localFile="${project.basedir}/target/pasada-2.0.0.RELEASE.jar"
                                                remoteToFile="pi@asa@item@.dyndns.org:/home/pi/asada/pasada/pasada.jar" verbose="true"
                                                password="mypass" trust="true">
                                            </scp>
                                            <sshexec trust="true" failonerror="true"
                                                host="asa@item@.dyndns.org"
                                                username="pi"
                                                password="mypass"
                                                command="sudo systemctl start pasada"
                                                timeout="120000" />	
                                        </target>
                                    </configuration>
                                </execution>
                            </executions>
                            <dependencies>
                                <dependency>
                                    <groupId>com.jcraft</groupId>
                                    <artifactId>jsch</artifactId>
                                    <version>0.1.53</version>
                                </dependency>
                                <dependency>
                                    <groupId>ant</groupId>
                                    <artifactId>ant-jsch</artifactId>
                                    <version>1.6.5</version>
                                </dependency>
                            </dependencies>
                        </plugin>
                    </pluginExecutor>
                </pluginExecutors>
            </configuration>
        </execution>
    </executions>
</plugin>

However, when running mvn package I get the following message:

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.ingartek.efimat:canbus-receiver >-----------------
[INFO] Building canbus-receiver 2.0.0.RELEASE
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for net.sourceforge.jFuzzyLogic:jFuzzyLogic:jar:2.0.7 is missing, no dependency information available
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ canbus-receiver ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 16 resources
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ canbus-receiver ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 61 source files to D:\workspaces\workspace-efimat\canbus-receiver\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ canbus-receiver ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\workspaces\workspace-efimat\canbus-receiver\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ canbus-receiver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ canbus-receiver ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.ingartek.efimat.canbus_receiver.AppTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.057 s - in com.ingartek.efimat.canbus_receiver.AppTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ canbus-receiver ---
[INFO] Building jar: D:\workspaces\workspace-efimat\canbus-receiver\target\canbus-receiver-2.0.0.RELEASE.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.3.RELEASE:repackage (repackage) @ canbus-receiver ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- iterator-maven-plugin:0.5.1:iterator (default) @ canbus-receiver ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.382 s
[INFO] Finished at: 2019-03-12T15:59:29+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.soebes.maven.plugins:iterator-maven-plugin:0.5.1:iterator (default) on project canbus-receiver: Unable to parse configuration of mojo com.soebes.maven.plugins:iterator-maven-plugin:0.5.1:iterator for parameter target: Cannot find 'target' in class java.lang.Object -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException

I don't understand the error message.

Would it be possible to make it work?

Thank you so much.

PS: let me know whether you need the whole pom.xml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant