Skip to content
Snippets Groups Projects
Commit 1925d255 authored by Konstantinos Giannoutakis's avatar Konstantinos Giannoutakis
Browse files

support for publishing application to uStore added

parent bb842547
No related branches found
No related tags found
No related merge requests found
Showing with 398 additions and 268 deletions
......@@ -5,20 +5,20 @@ Bundle-SymbolicName: org.universaal.tools.buildPlugin;singleton:=true
Bundle-Version: 0.3.0
Bundle-Activator: org.universaal.tools.buildserviceapplication.Activator
Bundle-Vendor: CERTH-ITI
Require-Bundle: org.eclipse.ui;bundle-version="3.5.2",
Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
org.eclipse.core.runtime;bundle-version="3.5.0",
org.maven.ide.eclipse;bundle-version="0.12.1",
org.maven.ide.eclipse.archetype_common;bundle-version="0.12.1",
org.maven.ide.eclipse.dependency_tree;bundle-version="0.12.1",
org.maven.ide.eclipse.maven_embedder;bundle-version="0.12.1",
org.eclipse.debug.core;bundle-version="3.5.1",
org.eclipse.debug.ui;bundle-version="3.5.2",
org.eclipse.jdt.launching;bundle-version="3.5.1",
org.eclipse.pde.core;bundle-version="3.5.101",
org.eclipse.pde.ui;bundle-version="3.5.1",
org.eclipse.equinox.launcher;bundle-version="1.0.201",
org.maven.ide.eclipse;bundle-version="0.10.0",
org.maven.ide.eclipse.archetype_common;bundle-version="0.10.0",
org.maven.ide.eclipse.dependency_tree;bundle-version="0.10.0",
org.maven.ide.eclipse.maven_embedder;bundle-version="0.10.0",
org.eclipse.debug.core;bundle-version="3.5.0",
org.eclipse.debug.ui;bundle-version="3.5.0",
org.eclipse.jdt.launching;bundle-version="3.5.0",
org.eclipse.pde.core;bundle-version="3.5.0",
org.eclipse.pde.ui;bundle-version="3.5.0",
org.eclipse.equinox.launcher;bundle-version="1.0.0",
org.eclipse.core.runtime.compatibility;bundle-version="3.2.0",
org.eclipse.jdt.core;bundle-version="3.5.2"
org.eclipse.jdt.core;bundle-version="3.5.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.eclipse.core.internal.resources,
org.eclipse.pde.core.plugin,
......
No preview for this file type
build/org.universaal.tools.buildPlugin/icons/publish.png

835 B

......@@ -16,29 +16,38 @@
</separator>
</menu>
<action
label="&amp;Upload project to Developer Depot"
label="&amp;Publish universAAL application"
icon="icons/publish.png"
class="org.universaal.tools.buildserviceapplication.actions.PublishAction"
tooltip="Publish application to uStore"
menubarPath="org.universaal.tools.build.plugin.menu/uAALGroup"
toolbarPath="uAALGroup"
id="org.universaal.tools.buildserviceapplication.actions.PublishAction">
</action>
<action
label="&amp;Upload application to Developer Depot"
icon="icons/upload.png"
class="org.universaal.tools.buildserviceapplication.actions.UploadAction"
tooltip="Upload project to Developer Depot"
tooltip="Upload application to Developer Depot"
menubarPath="org.universaal.tools.build.plugin.menu/uAALGroup"
toolbarPath="uAALGroup"
id="org.universaal.tools.buildserviceapplication.actions.UploadAction">
</action>
<action
label="&amp;Run universAAL Service"
label="&amp;Run universAAL application"
icon="icons/run.png"
class="org.universaal.tools.buildserviceapplication.actions.RunAction"
tooltip="Run universAAL Service"
tooltip="Run universAAL application"
menubarPath="org.universaal.tools.build.plugin.menu/uAALGroup"
toolbarPath="uAALGroup"
id="org.universaal.tools.buildserviceapplication.actions.RunAction" >
</action>
<action
label="&amp;Build universAAL Service"
label="&amp;Build universAAL application"
icon="icons/compile.png"
class="org.universaal.tools.buildserviceapplication.actions.BuildAction"
tooltip="Build universAAL Service"
tooltip="Build universAAL application"
menubarPath="org.universaal.tools.build.plugin.menu/uAALGroup"
toolbarPath="uAALGroup"
id="org.universaal.tools.buildserviceapplication.actions.BuildAction">
......
......@@ -57,7 +57,7 @@ public class CreateConfigurationFile {
MavenXpp3Reader xpp3Reader = new MavenXpp3Reader();
Model model = xpp3Reader.read(reader);
List<Dependency> dependencies = model.getDependencies();
System.out.println("Project dependencies:\n");
for (int i = 0; i < dependencies.size(); i++) {
Dependency dependency = dependencies.get(i);
if (dependency.getGroupId().equals(
......
package org.universaal.tools.buildserviceapplication.actions;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.cli.MavenCli;
import org.codehaus.plexus.util.Base64;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
/**
* Our sample action implements workbench action delegate. The action proxy will
* be created by the workbench and shown in the UI. When the user tries to use
* the action, this delegate will be created and execution will be delegated to
* it.
*
* @see IWorkbenchWindowActionDelegate
*/
public class PublishAction implements IWorkbenchWindowActionDelegate {
static private String NEXUS_URL = "http://srv-ustore.haifa.il.ibm.com:8081/nexus/content/repositories/";
static private String NEXUS_USERNAME = "admin";
static private String NEXUS_PASSWORD = "admin123";
private IWorkbenchWindow window;
/**
* The constructor.
*/
public PublishAction() {
}
/**
* The action has been activated. The argument of the method represents the
* 'real' action sitting in the workbench UI.
*
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action) {
UploadArtifact uploadArtifact = new UploadArtifact(NEXUS_URL,
NEXUS_USERNAME, NEXUS_PASSWORD);
uploadArtifact.upload();
}
/**
* Selection in the workbench has been changed. We can change the state of
* the 'real' action here if we want, but this can only happen after the
* delegate has been created.
*
* @see IWorkbenchWindowActionDelegate#selectionChanged
*/
public void selectionChanged(IAction action, ISelection selection) {
}
/**
* We can use this method to dispose of any system resources we previously
* allocated.
*
* @see IWorkbenchWindowActionDelegate#dispose
*/
public void dispose() {
}
/**
* We will cache window object in order to be able to provide parent shell
* for the message dialog.
*
* @see IWorkbenchWindowActionDelegate#init
*/
public void init(IWorkbenchWindow window) {
this.window = window;
}
}
\ No newline at end of file
......@@ -27,15 +27,11 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate;
* @see IWorkbenchWindowActionDelegate
*/
public class UploadAction implements IWorkbenchWindowActionDelegate {
static private String NEXUS_URL="http://a1gforge.igd.fraunhofer.de/nexus/content/repositories/";
static private String NEXUS_USERNAME="deployment";
static private String NEXUS_PASSWORD="uaal_49_nexus";
private IWorkbenchWindow window;
private String repositoryPath = "";
private boolean artifactUploaded = true;
private boolean isArtifactRelease = true;
static private String NEXUS_URL = "http://a1gforge.igd.fraunhofer.de/nexus/content/repositories/";
static private String NEXUS_USERNAME = "deployment";
static private String NEXUS_PASSWORD = "uaal_49_nexus";
private IWorkbenchWindow window;
/**
* The constructor.
*/
......@@ -50,248 +46,11 @@ public class UploadAction implements IWorkbenchWindowActionDelegate {
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action) {
if (!BuildAction.getSelectedProjectPath().equals("")) {
if (BuildAction.buildedProjects.contains(BuildAction
.getSelectedProjectPath())) {
try {
String selectedProject = BuildAction
.getSelectedProjectPath();
String projectName = selectedProject.split("/")[selectedProject
.split("/").length - 1];
if (!selectedProject.equals("")) {
isArtifactRelease = true;
if (CreateConfigurationFile.artifactVersion
.contains("SNAPSHOT")) {
isArtifactRelease = false;
}
postArtifact();
if (artifactUploaded) {
postMetadata();
if (!artifactUploaded) {
MessageDialog.openInformation(
window.getShell(),
"BuildServiceApplication",
"Uploading of artifact \""
+ projectName + "\" failed.");
} else {
MessageDialog
.openInformation(null,
"BuildServiceApplication",
"Uploading of artifact \""
+ projectName
+ "\" succeeded.");
}
} else {
MessageDialog.openInformation(window.getShell(),
"BuildServiceApplication",
"Uploading of artifact \"" + projectName
+ "\" failed.");
}
} else {
MessageDialog
.openInformation(null,
"BuildServiceApplication",
"Please select a project in the Project Explorer tab.");
}
} catch (Exception ex) {
ex.printStackTrace();
MessageDialog.openInformation(window.getShell(),
"BuildServiceApplication",
"Service/Application artifact uploading failed");
}
} else {
MessageDialog.openInformation(null, "BuildServiceApplication",
"Please build the project first.");
}
} else {
MessageDialog.openInformation(null, "BuildServiceApplication",
"Please select a project in the Project Explorer tab.");
}
}
private void postArtifact() {
artifactUploaded = true;
String[] tempString = MavenCli.DEFAULT_USER_SETTINGS_FILE
.getAbsolutePath().trim().replace("\\", "/").split("/");
repositoryPath = "";
for (int i = 0; i < tempString.length - 1; i++) {
repositoryPath = repositoryPath + tempString[i] + "\\";
}
try {
String webPage = "";
if (isArtifactRelease) {
webPage = NEXUS_URL+"releases/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ BuildAction.artifactFileName;
} else {
webPage = NEXUS_URL+"snapshots/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ BuildAction.artifactFileName;
}
String authString = NEXUS_USERNAME + ":" + NEXUS_PASSWORD;
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
URL url = new URL(webPage);
HttpURLConnection urlConnection = (HttpURLConnection) url
.openConnection();
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic "
+ authStringEnc);
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("PUT");
OutputStreamWriter out = new OutputStreamWriter(urlConnection
.getOutputStream());
File file = new File(repositoryPath + "repository/"
+ CreateConfigurationFile.groupId.replace(".", "/") + "/"
+ CreateConfigurationFile.artifactId + "/"
+ CreateConfigurationFile.artifactVersion + "/"
+ BuildAction.artifactFileName);
try {
FileInputStream fis = new FileInputStream(file);
char current;
while (fis.available() > 0) {
current = (char) fis.read();
out.write(current);
}
} catch (IOException e) {
e.printStackTrace();
}
out.close();
InputStream is = urlConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
int numCharsRead = 0;
char[] charArray = new char[1024];
StringBuffer sb = new StringBuffer();
while ((numCharsRead = isr.read(charArray)) > 0) {
sb.append(charArray, 0, numCharsRead);
}
} catch (Exception ex) {
artifactUploaded = false;
ex.printStackTrace();
}
UploadArtifact uploadArtifact = new UploadArtifact(NEXUS_URL,
NEXUS_USERNAME, NEXUS_PASSWORD);
uploadArtifact.upload();
}
private void postMetadata() {
Iterator<ArtifactMetadata> it = BuildAction.artifactMetadata.iterator();
while (it.hasNext()) {
ArtifactMetadata metadata = it.next();
metadata.getRemoteFilename();
try {
String webPage = "";
if (metadata.getRemoteFilename().endsWith(".pom")) {
if (isArtifactRelease) {
webPage = NEXUS_URL+"releases/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ metadata.getRemoteFilename();
} else {
webPage = NEXUS_URL+"snapshots/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ metadata.getRemoteFilename();
}
} else {
if (isArtifactRelease) {
webPage = NEXUS_URL+"releases/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ metadata.getRemoteFilename();
} else {
webPage = NEXUS_URL+"snapshots/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ metadata.getRemoteFilename();
}
}
String authString = NEXUS_USERNAME + ":" + NEXUS_PASSWORD;
byte[] authEncBytes = Base64
.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
URL url = new URL(webPage);
HttpURLConnection urlConnection = (HttpURLConnection) url
.openConnection();
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic "
+ authStringEnc);
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("PUT");
OutputStreamWriter out = new OutputStreamWriter(urlConnection
.getOutputStream());
File file =null;
if (metadata.getRemoteFilename().endsWith(".pom")) {
file = new File(repositoryPath + "repository/"
+ CreateConfigurationFile.groupId.replace(".", "/") + "/"
+ CreateConfigurationFile.artifactId + "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ metadata.getRemoteFilename());
}
else{
file = new File(repositoryPath + "repository/"
+ CreateConfigurationFile.groupId.replace(".", "/") + "/"
+ CreateConfigurationFile.artifactId + "/"
+ "maven-metadata-local.xml");
}
try {
FileInputStream fis = new FileInputStream(file);
char current;
while (fis.available() > 0) {
current = (char) fis.read();
out.write(current);
}
} catch (IOException e) {
e.printStackTrace();
}
out.close();
InputStream is = urlConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
int numCharsRead = 0;
char[] charArray = new char[1024];
StringBuffer sb = new StringBuffer();
while ((numCharsRead = isr.read(charArray)) > 0) {
sb.append(charArray, 0, numCharsRead);
}
} catch (Exception ex) {
artifactUploaded = false;
ex.printStackTrace();
}
}
}
/**
* Selection in the workbench has been changed. We can change the state of
* the 'real' action here if we want, but this can only happen after the
......
package org.universaal.tools.buildserviceapplication.actions;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.cli.MavenCli;
import org.codehaus.plexus.util.Base64;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchWindow;
public class UploadArtifact {
private String NEXUS_URL="";
private String NEXUS_USERNAME="";
private String NEXUS_PASSWORD="";
private IWorkbenchWindow window;
private String repositoryPath = "";
private boolean artifactUploaded = true;
private boolean isArtifactRelease = true;
public UploadArtifact(String nexusUrl, String nexusUserName, String nexusPassword){
this.NEXUS_URL=nexusUrl;
this.NEXUS_USERNAME=nexusUserName;
this.NEXUS_PASSWORD=nexusPassword;
}
public void upload(){
if (!BuildAction.getSelectedProjectPath().equals("")) {
if (BuildAction.buildedProjects.contains(BuildAction
.getSelectedProjectPath())) {
try {
String selectedProject = BuildAction
.getSelectedProjectPath();
String projectName = selectedProject.split("/")[selectedProject
.split("/").length - 1];
if (!selectedProject.equals("")) {
isArtifactRelease = true;
if (CreateConfigurationFile.artifactVersion
.contains("SNAPSHOT")) {
isArtifactRelease = false;
}
postArtifact();
if (artifactUploaded) {
postMetadata();
if (!artifactUploaded) {
MessageDialog.openInformation(
window.getShell(),
"BuildServiceApplication",
"Uploading of application \""
+ projectName + "\" failed.");
} else {
MessageDialog
.openInformation(null,
"BuildServiceApplication",
"Uploading of application \""
+ projectName
+ "\" succeeded.");
}
} else {
MessageDialog.openInformation(window.getShell(),
"BuildServiceApplication",
"Uploading of application \"" + projectName
+ "\" failed.");
}
} else {
MessageDialog
.openInformation(null,
"BuildServiceApplication",
"Please select a project in the Project Explorer tab.");
}
} catch (Exception ex) {
ex.printStackTrace();
MessageDialog.openInformation(window.getShell(),
"BuildServiceApplication",
"Application uploading failed");
}
} else {
MessageDialog.openInformation(null, "BuildServiceApplication",
"Please build the project first.");
}
} else {
MessageDialog.openInformation(null, "BuildServiceApplication",
"Please select a project in the Project Explorer tab.");
}
}
private void postArtifact() {
artifactUploaded = true;
String[] tempString = MavenCli.DEFAULT_USER_SETTINGS_FILE
.getAbsolutePath().trim().replace("\\", "/").split("/");
repositoryPath = "";
for (int i = 0; i < tempString.length - 1; i++) {
repositoryPath = repositoryPath + tempString[i] + "\\";
}
try {
String webPage = "";
if (isArtifactRelease) {
webPage = NEXUS_URL+"releases/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ BuildAction.artifactFileName;
} else {
webPage = NEXUS_URL+"snapshots/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ BuildAction.artifactFileName;
}
String authString = NEXUS_USERNAME + ":" + NEXUS_PASSWORD;
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
URL url = new URL(webPage);
HttpURLConnection urlConnection = (HttpURLConnection) url
.openConnection();
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic "
+ authStringEnc);
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("PUT");
OutputStreamWriter out = new OutputStreamWriter(urlConnection
.getOutputStream());
File file = new File(repositoryPath + "repository/"
+ CreateConfigurationFile.groupId.replace(".", "/") + "/"
+ CreateConfigurationFile.artifactId + "/"
+ CreateConfigurationFile.artifactVersion + "/"
+ BuildAction.artifactFileName);
try {
FileInputStream fis = new FileInputStream(file);
char current;
while (fis.available() > 0) {
current = (char) fis.read();
out.write(current);
}
} catch (IOException e) {
e.printStackTrace();
}
out.close();
InputStream is = urlConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
int numCharsRead = 0;
char[] charArray = new char[1024];
StringBuffer sb = new StringBuffer();
while ((numCharsRead = isr.read(charArray)) > 0) {
sb.append(charArray, 0, numCharsRead);
}
} catch (Exception ex) {
artifactUploaded = false;
ex.printStackTrace();
}
}
private void postMetadata() {
Iterator<ArtifactMetadata> it = BuildAction.artifactMetadata.iterator();
while (it.hasNext()) {
ArtifactMetadata metadata = it.next();
metadata.getRemoteFilename();
try {
String webPage = "";
if (metadata.getRemoteFilename().endsWith(".pom")) {
if (isArtifactRelease) {
webPage = NEXUS_URL+"releases/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ metadata.getRemoteFilename();
} else {
webPage = NEXUS_URL+"snapshots/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ metadata.getRemoteFilename();
}
} else {
if (isArtifactRelease) {
webPage = NEXUS_URL+"releases/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ metadata.getRemoteFilename();
} else {
webPage = NEXUS_URL+"snapshots/"
+ CreateConfigurationFile.groupId.replace(".", "/")
+ "/"
+ CreateConfigurationFile.artifactId
+ "/"
+ metadata.getRemoteFilename();
}
}
String authString = NEXUS_USERNAME + ":" + NEXUS_PASSWORD;
byte[] authEncBytes = Base64
.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
URL url = new URL(webPage);
HttpURLConnection urlConnection = (HttpURLConnection) url
.openConnection();
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic "
+ authStringEnc);
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("PUT");
OutputStreamWriter out = new OutputStreamWriter(urlConnection
.getOutputStream());
File file =null;
if (metadata.getRemoteFilename().endsWith(".pom")) {
file = new File(repositoryPath + "repository/"
+ CreateConfigurationFile.groupId.replace(".", "/") + "/"
+ CreateConfigurationFile.artifactId + "/"
+ CreateConfigurationFile.artifactVersion
+ "/"
+ metadata.getRemoteFilename());
}
else{
file = new File(repositoryPath + "repository/"
+ CreateConfigurationFile.groupId.replace(".", "/") + "/"
+ CreateConfigurationFile.artifactId + "/"
+ "maven-metadata-local.xml");
}
try {
FileInputStream fis = new FileInputStream(file);
char current;
while (fis.available() > 0) {
current = (char) fis.read();
out.write(current);
}
} catch (IOException e) {
e.printStackTrace();
}
out.close();
InputStream is = urlConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
int numCharsRead = 0;
char[] charArray = new char[1024];
StringBuffer sb = new StringBuffer();
while ((numCharsRead = isr.read(charArray)) > 0) {
sb.append(charArray, 0, numCharsRead);
}
} catch (Exception ex) {
artifactUploaded = false;
ex.printStackTrace();
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment