AAR Uploads Maven Library tool

Source: Internet
Author: User
Tags gettext

Requirement: Local AAR file uploaded to Maven library

Refer to my previous blog Gradle uploading local files to a remote MAVEN library (Nexus server)

Here is the Java graphical tool code

 PackageCom.jinkejoy.build_aar;Importjava.awt.FlowLayout;Importjava.awt.event.ActionEvent;ImportJava.awt.event.ActionListener;ImportJava.io.File;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException;ImportJavax.swing.JButton;ImportJavax.swing.JFileChooser;ImportJavax.swing.JFrame;ImportJavax.swing.JLabel;ImportJavax.swing.JOptionPane;ImportJavax.swing.JTextField; Public classUploadaarfile {PrivateJFrame JFrame; PrivateJTextField Aar_path; PrivateJButton Aarpath_button; PrivateFile Aar_file; PrivateJTextField Main_path; PrivateJButton Main_button; PrivateFile Main_file; PrivateJTextField groupId; PrivateJTextField Artifactid; PrivateJTextField version; PrivateJButton upload;  Public Static voidMain (string[] args) {NewUploadaarfile (); }     PublicUploadaarfile () {Openfilewindow (); }    Private voidOpenfilewindow () {jFrame=NewJFrame (); Jframe.settitle ("Uploading AAR to Maven library"); Jframe.setbounds (500, 500, 700, 160); Jframe.setvisible (true); FlowLayout Layout=NewFlowLayout ();        Layout.setalignment (Flowlayout.left); //Select AAR fileJLabel Filepath_label =NewJLabel ("AAR Local Path:"); Aar_path=NewJTextField (48); Aarpath_button=NewJButton ("Browse"); //Prefix package nameJLabel Groupid_label =NewJLabel ("prefix Package name:"); GroupId=NewJTextField (25); //AAR nameJLabel Aar_label =NewJLabel ("AAR file name:"); Artifactid=NewJTextField (25); //versionJLabel Version_label =NewJLabel ("AAR version number:"); Version=NewJTextField (25); //Master BagJLabel Main_label =NewJLabel ("Parent Package path:"); Main_path=NewJTextField (50); Main_button=NewJButton ("Browse"); //UploadUpload =NewJButton ("Upload");        Jframe.setdefaultcloseoperation (Jframe.exit_on_close);        Jframe.setlayout (layout); Jframe.setresizable (false);        Jframe.add (Main_label);        Jframe.add (Main_path);        Jframe.add (Main_button);        Jframe.add (Filepath_label);        Jframe.add (Aar_path);        Jframe.add (Aarpath_button);        Jframe.add (Groupid_label);        Jframe.add (GROUPID);        Jframe.add (Aar_label);        Jframe.add (Artifactid);        Jframe.add (Version_label);        Jframe.add (version);        Jframe.add (upload);        Findaarfile ();        Findmainfile ();    Uploadaar (); }    Private voidFindmainfile () {Main_button.addactionlistener (NewActionListener () {@Override Public voidactionperformed (ActionEvent actionevent) {JFileChooser chooser=NewJFileChooser ();                Chooser.setfileselectionmode (jfilechooser.files_and_directories); Chooser.showdialog (NewJLabel (), "select"); Main_file=Chooser.getselectedfile ();            Main_path.settext (Main_file.getabsolutepath (). toString ());    }        }); }    Private voidFindaarfile () {Aarpath_button.addactionlistener (NewActionListener () {@Override Public voidactionperformed (ActionEvent actionevent) {JFileChooser chooser=NewJFileChooser ();                Chooser.setfileselectionmode (jfilechooser.files_and_directories); Chooser.showdialog (NewJLabel (), "select"); Aar_file=Chooser.getselectedfile ();            Aar_path.settext (Aar_file.getabsolutepath (). toString ());    }        }); }    Private voidUploadaar () {Upload.addactionlistener (NewActionListener () {@Override Public voidactionperformed (ActionEvent actionevent) {Uploadaarimpl ();    }        }); }    Private voidUploadaarimpl () {if(Checkinput ())return;        CachePath ();    Gradleupload (); }    Private voidCachePath () {String cache= "Mainpath=" + main_path.gettext (). toString (). replace ("\ \", "\\\\") + "\ n" + "aarpath=" + aar_path.gettext (). ToString (). replace ("\ \", "\\\\") + "\ n" + "groupid=" + groupid.gettext (). ToString (). replace ("\ \", "\\\\" ) + "\ n" + "artifactid=" + artifactid.gettext (). toString (). replace ("\ \", "\\\\") + "\ n" + "V ersion= "+ version.gettext (). toString (). replace (" \ \ "," \\\\ "); File Cachefile=NewFile (Main_path.gettext (). toString () + "/aarparam.properties"); if(!cachefile.exists ()) {            Try{cachefile.createnewfile (); } Catch(IOException e) {e.printstacktrace (); }        }        Try{FileOutputStream FOP=NewFileOutputStream (Cachefile);            Fop.write (Cache.getbytes ());            Fop.flush ();        Fop.close (); } Catch(FileNotFoundException e) {e.printstacktrace (); } Catch(IOException e) {e.printstacktrace (); }    }    Private voidgradleupload () {String command= "cmd/c start Gradlew clean uploadarchives"; File Cmdpath=NewFile (Main_path.gettext (). toString ()); Runtime Runtime=Runtime.getruntime (); Try{Process Process= runtime.exec (Command,NULL, Cmdpath); } Catch(IOException e) {e.printstacktrace (); }    }    Private BooleanCheckinput () {if("". Equals (Aar_path.gettext (). toString ())) {Joptionpane.showmessagedialog (JFrame,"Please enter the Aar file path"); return true; }        if("". Equals (Main_path.gettext (). toString ())) {Joptionpane.showmessagedialog (JFrame,"Please enter the parent package path"); return true; }        if("". Equals (Groupid.gettext (). toString ())) {Joptionpane.showmessagedialog (JFrame,"Please enter the prefix package name"); return true; }        if("". Equals (Artifactid.gettext (). toString ())) {Joptionpane.showmessagedialog (JFrame,"Please enter the AAR name"); return true; }        if("". Equals (Version.gettext (). toString ())) {Joptionpane.showmessagedialog (JFrame,"Please enter the AAR version number"); return true; }        return false; }}

Jar package to run program reference Android Studio play executable jar package

AAR Uploads Maven Library tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.