It is not that difficult to write your own maven plugin to achieve this.

You'll probably want to depend on JSch.

File transfer via SCP/SFTP is easy with JSch, and then you can execute
the "make" command to re-index the repository... although you probably
would prefer to skip the "make" and instead invoke "createrepo"
directly...

-Stephen

P.S.
You'll probably need something like the following dependencies:
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-project</artifactId>
      <version>2.0.6</version>
    </dependency>

    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>2.0.6</version>
    </dependency>

    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <version>1.5.1</version>
    </dependency>

    <dependency>
      <groupId>com.jcraft</groupId>
      <artifactId>jsch</artifactId>
      <version>0.1.42</version>
    </dependency>

As well as these two functions (or equivalent):

    /*
     * Licensed to the Apache Software Foundation (ASF) under one
     * or more contributor license agreements.  See the NOTICE file
     * distributed with this work for additional information
     * regarding copyright ownership.  The ASF licenses this file
     * to you under the Apache License, Version 2.0 (the
     * "License"); you may not use this file except in compliance
     * with the License.  You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing,
     * software distributed under the License is distributed on an
     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     * KIND, either express or implied.  See the License for the
     * specific language governing permissions and limitations
     * under the License.
     */
    import com.jcraft.jsch.ChannelExec;
    import com.jcraft.jsch.ChannelSftp;
    import com.jcraft.jsch.JSchException;
    import com.jcraft.jsch.Session;
    import com.jcraft.jsch.SftpException;
    import org.apache.maven.plugin.logging.Log;
    import org.codehaus.plexus.util.IOUtil;
    import org.codehaus.plexus.util.StringUtils;

    public static void put( Session session, File source, String
destination, int mode, final Log log )
        throws JSchException, SftpException
    {
        ChannelSftp channel = null;
        try
        {
            channel = (ChannelSftp) session.openChannel( "sftp" );
            channel.connect();
            log.info( "Uploading " + source + " to sftp://"; +
session.getUserName() + "@" + session.getHost() + ":"
                + session.getPort() + destination );
            channel.put( source.getAbsolutePath(), destination, mode );
            channel.quit();
        }
        finally
        {
            if ( channel != null )
            {
                channel.disconnect();
            }
        }
    }

    public static void createrepo( Session session, String workingDir )
        throws JSchException, IOException, InterruptedException
    {
        GobblingInputStream stdout = null;
        GobblingInputStream stderr = null;
        ChannelExec channel = null;
        try
        {
            channel = (ChannelExec) session.openChannel( "exec" );
            channel.setCommand( "ch " + workingDir + " && createrepo" );
            stdout = new GobblingInputStream( channel.getInputStream() );
            stderr = new GobblingInputStream( channel.getErrStream() );
            channel.setInputStream( null );
            channel.connect();
            stdout.awaitClosed();
            stderr.awaitClosed();
            while ( !channel.isClosed() )
            {
                Thread.sleep( 50 );
            }
            if ( channel.getExitStatus() != 0 )
            {
                throw new IOException(
                    "Could not update yum repository
metadata\nSTDOUT:\n" + IOUtil.toString( stdout ) + "\nSTDERR:\n"
                        + IOUtil.toString( stderr ) + "\nEXIT-CODE:" +
channel.getExitStatus() );
            }
        }
        finally
        {
            if ( channel != null )
            {
                channel.disconnect();
            }
            IOUtil.close( stdout );
            IOUtil.close( stderr );
        }
    }

When you're done, give it back to the community, e.g. donate your
plugin to mojo or some other maven plugin project hosting

2009/11/6 eyal edri <[email protected]>:
> Hi guys,
>
> i'm just starting to play around with maven as a candidate for our whole
> build/deploy system for java applications.
>
> we're been programming so far using Perl,  packaging with Rpm on Fedora and
> Deploying it though a local yum repository.
>
>
> We still haven't decided if we could ditch the yum/rpm idea all together and
> swith to mvn repository,
> but in case we won't,
>
> Do you know* i**f there is a way to config mvn to upload the rpm (using
> SCP?) to the yum repository* after
> it finished building the RPM (today we use a build system based on make
> files and in the end it scp's the rpm to the repository and run make there
> to update the list of rpms).
>
> thank you.
>
> --
> Eyal Edri
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to