=UTF-8
3 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.feature/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.feature/build.properties:
--------------------------------------------------------------------------------
1 | bin.includes = feature.xml,\
2 | feature.properties,\
3 | license.html
4 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.feature/feature.properties:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Copyright (c) 2015 Red Hat, Inc. and others.
3 | # All rights reserved. This program and the accompanying materials
4 | # are made available under the terms of the Eclipse Public License v1.0
5 | # which accompanies this distribution, and is available at
6 | # http://www.eclipse.org/legal/epl-v10.html
7 | #
8 | # Contributors:
9 | # JBoss by Red Hat - Initial implementation.
10 | ##############################################################################
11 | # feature.properties
12 | # contains externalized strings for feature.xml
13 | # "%foo" in feature.xml corresponds to the key "foo" in this file
14 | # java.io.Properties file (ISO 8859-1 with "\" escapes)
15 | # This file should be translated.
16 |
17 | # "featureName" property - name of the feature
18 | featureName=M2E Polyglot Support Experiment
19 |
20 | # "providerName" property - name of the company that provides the feature
21 | providerName=JBoss by Red Hat
22 |
23 | # "updateSiteName" property - label for the update site
24 | updateSiteName=JBossTools Update Site
25 |
26 | # "description" property - description of the feature
27 | description=This feature provides *higly experimental* support for Maven Polyglot within Eclipse.
28 |
29 | # "copyright" property - text of the "Feature Update Copyright"
30 | copyright=Copyright (c) 2015 Red Hat, Inc. and others.\n\
31 | All rights reserved. This program and the accompanying materials\n\
32 | are made available under the terms of the Eclipse Public License v1.0\n\
33 | which accompanies this distribution, and is available at\n\
34 | http\://www.eclipse.org/legal/epl-v10.html\n\nContributors\:\n\
35 | JBoss by Red Hat - Initial implementation.
36 | ############### end of copyright property ####################################
37 |
38 | # "licenseURL" property - URL of the "Feature License"
39 | # do not translate value - just change to point to a locale-specific HTML page
40 | licenseURL=license.html
41 |
42 | # START NON-TRANSLATABLE
43 | # "license" property - text of the "Feature Update License"
44 | # should be plain text version of license agreement pointed to be "licenseURL"
45 | license=Red Hat, Inc. licenses these features and plugins to you under \
46 | certain open source licenses (or aggregations of such licenses), which \
47 | in a particular case may include the Eclipse Public License, the GNU \
48 | Lesser General Public License, and/or certain other open source \
49 | licenses. For precise licensing details, consult the corresponding \
50 | source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive, \
51 | Raleigh NC 27606 USA.
52 | # END NON-TRANSLATABLE
53 | ########### end of license property ##########################################
54 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.feature/feature.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %description
6 |
7 |
8 |
9 | %copyright
10 |
11 |
12 |
13 | %license
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.feature/license.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Red Hat, Inc. licenses these features and plugins to you under
6 | certain open source licenses (or aggregations of such licenses), which
7 | in a particular case may include the Eclipse Public License, the GNU
8 | Lesser General Public License, and/or certain other open source
9 | licenses. For precise licensing details, consult the corresponding
10 | source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive,
11 | Raleigh NC 27606 USA.
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.feature/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | org.jboss.tools.maven.polyglot.poc
6 | org.jboss.tools.maven.polyglot.poc
7 | 0.0.1-SNAPSHOT
8 |
9 | org.jboss.tools.maven.polyglot.poc.feature
10 | eclipse-feature
11 | ${projectName} :: feature
12 |
13 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.feature/sourceTemplateFeature/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jbosstools/m2e-polyglot-poc/0fbc97aa8eb2a94362248f6ad1f9a1d1d21824db/org.jboss.tools.maven.polyglot.poc.feature/sourceTemplateFeature/.gitkeep
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.site/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.jboss.tools.maven.polyglot.poc.site
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.site/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.site/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.site/category.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.site/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | org.jboss.tools.maven.polyglot.poc
6 | org.jboss.tools.maven.polyglot.poc
7 | 0.0.1-SNAPSHOT
8 |
9 | org.jboss.tools.maven.polyglot.poc.site
10 | eclipse-repository
11 | ${projectName} :: update site
12 |
13 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.tests/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.tests/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.jboss.tools.maven.polyglot.poc.tests
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.ManifestBuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.pde.SchemaBuilder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.m2e.core.maven2Nature
31 | org.eclipse.pde.PluginNature
32 | org.eclipse.jdt.core.javanature
33 |
34 |
35 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.tests/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.tests/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4 | org.eclipse.jdt.core.compiler.compliance=1.7
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=1.7
8 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.tests/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.tests/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: M2E Polyglot Support Experiment UI Plugin Test Fragment
4 | Bundle-SymbolicName: org.jboss.tools.maven.polyglot.poc.tests
5 | Bundle-Version: 0.0.1.qualifier
6 | Fragment-Host: org.jboss.tools.maven.polyglot.poc.core;bundle-version="0.0.1"
7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.7
8 | Require-Bundle: org.eclipse.jdt.junit4.runtime;bundle-version="1.1.0",
9 | org.junit;bundle-version="4.11"
10 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.tests/build.properties:
--------------------------------------------------------------------------------
1 | source.. = src/main/java/
2 | output.. = target/classes/
3 | bin.includes = META-INF/,\
4 | .
5 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.tests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | org.jboss.tools.maven.polyglot.poc
5 | org.jboss.tools.maven.polyglot.poc
6 | 0.0.1-SNAPSHOT
7 |
8 | 4.0.0
9 | org.jboss.tools.maven.polyglot.poc.tests
10 | eclipse-test-plugin
11 | ${projectName} :: tests
12 |
13 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.tests/src/main/java/org/jboss/tools/maven/polyglot/poc/updater/internal/core/ActivatorTest.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 Red Hat, Inc.
3 | * Distributed under license by Red Hat, Inc. All rights reserved.
4 | * This program is made available under the terms of the
5 | * Eclipse Public License v1.0 which accompanies this distribution,
6 | * and is available at http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Red Hat, Inc. - initial API and implementation
10 | ******************************************************************************/
11 | package org.jboss.tools.maven.polyglot.poc.updater.internal.core;
12 |
13 | import static org.junit.Assert.assertEquals;
14 |
15 | import org.jboss.tools.maven.polyglot.poc.translator.internal.core.PolyglotSupportActivator;
16 | import org.junit.Test;
17 |
18 | /**
19 | * Sample integration test. In Eclipse, right-click > Run As > JUnit-Plugin.
20 | * In Maven CLI, run "mvn integration-test".
21 | */
22 | public class ActivatorTest {
23 |
24 | @Test
25 | public void veryStupidTest() {
26 | assertEquals("org.jboss.tools.maven.polyglot.poc.core",PolyglotSupportActivator.PLUGIN_ID);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.jboss.tools.maven.polyglot.poc.core
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.m2e.core.maven2Builder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.m2e.core.maven2Nature
31 | org.eclipse.pde.PluginNature
32 | org.eclipse.jdt.core.javanature
33 |
34 |
35 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4 | org.eclipse.jdt.core.compiler.compliance=1.8
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=1.8
8 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/.settings/org.jboss.ide.eclipse.as.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.jboss.ide.eclipse.as.core.singledeployable.deployableList=
3 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: M2E Polyglot Support Experiment UI Plugin
4 | Bundle-SymbolicName: org.jboss.tools.maven.polyglot.poc.ui;singleton:=true
5 | Bundle-Version: 0.0.1.qualifier
6 | Bundle-Activator: org.jboss.tools.maven.polyglot.poc.internal.ui.PolyglotSupportUIActivator
7 | Require-Bundle: org.eclipse.ui,
8 | org.eclipse.core.runtime,
9 | org.eclipse.core.resources,
10 | org.eclipse.m2e.core,
11 | org.slf4j.api,
12 | org.eclipse.m2e.maven.runtime,
13 | org.jboss.tools.maven.polyglot.poc.core
14 | Bundle-ActivationPolicy: lazy
15 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8
16 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/build.properties:
--------------------------------------------------------------------------------
1 | source.. = src/main/java/
2 | output.. = target/classes/
3 | bin.includes = plugin.xml,\
4 | META-INF/,\
5 | .
6 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 |
14 |
15 |
16 |
17 |
20 |
21 |
22 |
23 |
25 |
28 |
31 |
33 |
44 |
45 |
46 |
47 |
48 |
50 |
53 |
54 |
55 |
57 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | org.jboss.tools.maven.polyglot.poc
5 | org.jboss.tools.maven.polyglot.poc
6 | 0.0.1-SNAPSHOT
7 |
8 | 4.0.0
9 | org.jboss.tools.maven.polyglot.poc.ui
10 | eclipse-plugin
11 | ${projectName} :: ui
12 |
13 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/src/main/java/org/jboss/tools/maven/polyglot/poc/internal/ui/PolyglotSupportUIActivator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 Red Hat, Inc.
3 | * Distributed under license by Red Hat, Inc. All rights reserved.
4 | * This program is made available under the terms of the
5 | * Eclipse Public License v1.0 which accompanies this distribution,
6 | * and is available at http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Red Hat, Inc. - initial API and implementation
10 | ******************************************************************************/
11 | package org.jboss.tools.maven.polyglot.poc.internal.ui;
12 |
13 | import org.eclipse.core.runtime.Plugin;
14 | import org.eclipse.core.runtime.preferences.InstanceScope;
15 | import org.eclipse.jface.preference.IPreferenceStore;
16 | import org.eclipse.ui.IStartup;
17 | import org.eclipse.ui.preferences.ScopedPreferenceStore;
18 | import org.jboss.tools.maven.polyglot.poc.internal.core.PolyglotSupportActivator;
19 | import org.jboss.tools.maven.polyglot.poc.internal.core.preferences.IPolyglotPreferenceConstants;
20 | import org.osgi.framework.BundleContext;
21 |
22 | /**
23 | * The activator class controls the plug-in life cycle
24 | */
25 | public class PolyglotSupportUIActivator extends Plugin implements IStartup {
26 |
27 | // The plug-in ID
28 | public static final String PLUGIN_ID = "org.jboss.tools.maven.polyglot.poc.ui";
29 |
30 | // The shared instance
31 | private static PolyglotSupportUIActivator plugin;
32 |
33 | private IPreferenceStore preferenceStore;
34 |
35 | public void start(BundleContext context) throws Exception {
36 | super.start(context);
37 | //forces activation of core plugin
38 | getPreferenceStore().getBoolean(IPolyglotPreferenceConstants.ENABLE_AUTOMATIC_POM_TRANSLATION);
39 | getPreferenceStore().getString(IPolyglotPreferenceConstants.POLYGLOT_TRANSLATION_PLUGIN_VERSION);
40 | plugin = this;
41 | }
42 |
43 | public void stop(BundleContext context) throws Exception {
44 | plugin = null;
45 | preferenceStore = null;
46 | super.stop(context);
47 | }
48 |
49 | /**
50 | * @return the shared instance
51 | */
52 | public static PolyglotSupportUIActivator getDefault() {
53 | return plugin;
54 | }
55 |
56 | @Override
57 | public void earlyStartup() {
58 | }
59 |
60 | public IPreferenceStore getPreferenceStore() {
61 | if (preferenceStore == null) {
62 | preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE,PolyglotSupportActivator.PLUGIN_ID);
63 | }
64 | return preferenceStore;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/src/main/java/org/jboss/tools/maven/polyglot/poc/internal/ui/preferences/MavenPolyglotPreferencePage.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************
2 | * Copyright (c) 2015 Red Hat, Inc. and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * JBoss by Red Hat - Initial implementation.
10 | ************************************************************************************/
11 | package org.jboss.tools.maven.polyglot.poc.internal.ui.preferences;
12 |
13 | import org.eclipse.jface.preference.BooleanFieldEditor;
14 | import org.eclipse.jface.preference.FieldEditorPreferencePage;
15 | import org.eclipse.jface.preference.StringFieldEditor;
16 | import org.eclipse.ui.IWorkbench;
17 | import org.eclipse.ui.IWorkbenchPreferencePage;
18 | import org.jboss.tools.maven.polyglot.poc.internal.core.preferences.IPolyglotPreferenceConstants;
19 | import org.jboss.tools.maven.polyglot.poc.internal.ui.PolyglotSupportUIActivator;
20 |
21 | /**
22 | * @author Fred Bricon
23 | */
24 | public class MavenPolyglotPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
25 |
26 | public MavenPolyglotPreferencePage() {
27 | super(GRID);
28 | setPreferenceStore(PolyglotSupportUIActivator.getDefault().getPreferenceStore());
29 | }
30 |
31 | public void init(IWorkbench workbench) {
32 | }
33 |
34 | public void createFieldEditors() {
35 | addField(new BooleanFieldEditor(IPolyglotPreferenceConstants.ENABLE_AUTOMATIC_POM_TRANSLATION,
36 | "Enable automatic polyglot pom translation. pom.xml will be overwritten!",
37 | getFieldEditorParent()));
38 | addField(new StringFieldEditor(IPolyglotPreferenceConstants.POLYGLOT_TRANSLATION_PLUGIN_VERSION,
39 | "Optional version of the polyglot-translate-plugin",
40 | getFieldEditorParent()));
41 | }
42 |
43 | @Override
44 | public boolean performOk() {
45 | if (super.performOk()) {
46 | }
47 | System.err.println(getPreferenceStore().needsSaving());
48 | return true;
49 | }
50 | }
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/src/main/java/org/jboss/tools/maven/polyglot/poc/internal/ui/translation/Language.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 Red Hat, Inc.
3 | * Distributed under license by Red Hat, Inc. All rights reserved.
4 | * This program is made available under the terms of the
5 | * Eclipse Public License v1.0 which accompanies this distribution,
6 | * and is available at http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Red Hat, Inc. - initial API and implementation
10 | ******************************************************************************/
11 | package org.jboss.tools.maven.polyglot.poc.internal.ui.translation;
12 |
13 | /**
14 | * @author Fred Bricon
15 | */
16 | public enum Language {
17 |
18 | atom,
19 | //clojure("clj"), clojure seems broken
20 | groovy,
21 | ruby("rb"),
22 | scala,
23 | yaml;
24 |
25 | private String fileExtension;
26 | private String mavenPluginId;
27 |
28 | Language() {
29 | this.fileExtension = name();
30 | this.mavenPluginId = "polyglot-"+name();
31 | }
32 |
33 | Language(String extension) {
34 | this();
35 | this.fileExtension = extension;
36 | }
37 |
38 | public String getFileExtension() {
39 | return fileExtension;
40 | }
41 |
42 | public String getMavenPluginId() {
43 | return mavenPluginId;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/src/main/java/org/jboss/tools/maven/polyglot/poc/internal/ui/translation/PolyglotTranslaterJob.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 Red Hat, Inc.
3 | * Distributed under license by Red Hat, Inc. All rights reserved.
4 | * This program is made available under the terms of the
5 | * Eclipse Public License v1.0 which accompanies this distribution,
6 | * and is available at http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Red Hat, Inc. - initial API and implementation
10 | ******************************************************************************/
11 | package org.jboss.tools.maven.polyglot.poc.internal.ui.translation;
12 |
13 | import java.io.BufferedWriter;
14 | import java.io.File;
15 | import java.io.FileInputStream;
16 | import java.io.FileOutputStream;
17 | import java.io.OutputStreamWriter;
18 | import java.io.PrintWriter;
19 | import java.io.StringReader;
20 | import java.io.Writer;
21 | import java.util.ArrayList;
22 | import java.util.Collections;
23 | import java.util.List;
24 | import java.util.Set;
25 |
26 | import org.apache.maven.artifact.Artifact;
27 | import org.apache.maven.artifact.DefaultArtifact;
28 | import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
29 | import org.codehaus.plexus.util.xml.Xpp3Dom;
30 | import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
31 | import org.codehaus.plexus.util.xml.Xpp3DomWriter;
32 | import org.eclipse.core.resources.IFile;
33 | import org.eclipse.core.resources.IResource;
34 | import org.eclipse.core.runtime.CoreException;
35 | import org.eclipse.core.runtime.IProgressMonitor;
36 | import org.eclipse.core.runtime.IStatus;
37 | import org.eclipse.core.runtime.Path;
38 | import org.eclipse.core.runtime.Status;
39 | import org.eclipse.m2e.core.MavenPlugin;
40 | import org.eclipse.m2e.core.project.IMavenProjectFacade;
41 | import org.jboss.tools.maven.polyglot.poc.internal.core.ArtifactSearcher;
42 | import org.jboss.tools.maven.polyglot.poc.internal.core.ModulesCollector;
43 | import org.jboss.tools.maven.polyglot.poc.internal.core.PomTranslatorJob;
44 | import org.jboss.tools.maven.polyglot.poc.internal.ui.PolyglotSupportUIActivator;
45 |
46 | /**
47 | * @author Fred Bricon
48 | */
49 | public class PolyglotTranslaterJob extends PomTranslatorJob {
50 |
51 | private IMavenProjectFacade facade;
52 | private Language language;
53 | private boolean addExtension;
54 | private File mvnExtensionsDir;
55 |
56 | public PolyglotTranslaterJob(IMavenProjectFacade facade, Language language, boolean addExtension, File mvnExtensionsDir, String translatePluginVersion) {
57 | super(Collections.singletonList(facade.getPom()), translatePluginVersion);
58 | this.facade = facade;
59 | this.language = language;
60 | this.addExtension = addExtension;
61 | this.mvnExtensionsDir = mvnExtensionsDir;
62 | }
63 |
64 | @Override
65 | protected IStatus run(IProgressMonitor monitor) {
66 | try {
67 | if (addExtension) {
68 | Artifact extension = findLatestExtensionFor(language.getMavenPluginId(), monitor);
69 | monitor.worked(1);
70 | addExtension(mvnExtensionsDir, extension);
71 | monitor.worked(1);
72 | }
73 |
74 | IMavenProjectFacade[] allFacades = MavenPlugin.getMavenProjectRegistry().getProjects();
75 | Set modules = new ModulesCollector(facade, allFacades).getModules(monitor);
76 | List facades = new ArrayList<>(modules.size()+1);
77 | facades.add(facade);
78 | facades.addAll(modules);
79 | for (IMavenProjectFacade f : facades) {
80 | IFile output = f.getPom().getParent().getFile(new Path("pom."+language.getFileExtension()));
81 | translate(f.getPom(), f.getPom(), output, monitor);
82 | facade.getProject().refreshLocal(IResource.DEPTH_ZERO, monitor);
83 | monitor.worked(1);
84 | }
85 | } catch (Exception e) {
86 | e.printStackTrace();
87 | if (e instanceof CoreException) {
88 | return ((CoreException)e).getStatus();
89 | }
90 | return new Status(IStatus.ERROR, PolyglotSupportUIActivator.PLUGIN_ID, e.getMessage());
91 | }
92 | return Status.OK_STATUS;
93 | }
94 |
95 | private void addExtension(File mvnExtensionsDir, Artifact extension) throws Exception {
96 | mvnExtensionsDir.mkdirs();
97 | File mvnExtension = new File(mvnExtensionsDir, "extensions.xml");
98 | Xpp3Dom dom = null;
99 | if (mvnExtension.exists()) {//TODO could make check more robust
100 | try (FileInputStream fis = new FileInputStream(mvnExtension)) {
101 | dom = Xpp3DomBuilder.build(fis, "UTF-8");
102 | }
103 | } else {
104 | dom = Xpp3DomBuilder.build(new StringReader("\n"));
105 | }
106 | Xpp3Dom[] extensions = dom.getChildren("extension");
107 | if (extensions != null && extensions.length > 0) {
108 | for (Xpp3Dom ex : extensions) {
109 | String groupId = ex.getChild("groupId").getValue();
110 | String artifactId = ex.getChild("artifactId").getValue();
111 | if (extension.getArtifactId().equals(artifactId) && extension.getGroupId().equals(groupId)) {
112 | //nothing to do
113 | return;
114 | }
115 | }
116 | }
117 | Xpp3Dom newExtension = new Xpp3Dom("extension");
118 | addNode(newExtension, "groupId", extension.getGroupId());
119 | addNode(newExtension, "artifactId", extension.getArtifactId());
120 | addNode(newExtension, "version", extension.getVersion());
121 | dom.addChild(newExtension);
122 |
123 | try (Writer writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(mvnExtension),"UTF-8")))) {
124 | Xpp3DomWriter.write(new PrettyPrintXMLWriter(writer), dom);
125 | }
126 | }
127 |
128 | private Artifact findLatestExtensionFor(String pluginId, IProgressMonitor monitor) {
129 | final Artifact extension = new DefaultArtifact("io.takari.polyglot", pluginId, "0.3.0", null, "jar", "", null);
130 | try {
131 | String latestVersion = ArtifactSearcher.getLatestVersion(extension, monitor);
132 | if (latestVersion != null) {
133 | extension.setVersion(latestVersion);
134 | }
135 | } catch (CoreException e) {
136 | e.printStackTrace();
137 | }
138 | return extension;
139 | }
140 |
141 | private static void addNode(Xpp3Dom parent, String key, String value) {
142 | Xpp3Dom node = new Xpp3Dom(key);
143 | node.setValue(value);
144 | parent.addChild(node);
145 | }
146 |
147 | }
148 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/src/main/java/org/jboss/tools/maven/polyglot/poc/internal/ui/translation/PolyglotTranslaterWizard.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 Red Hat, Inc.
3 | * Distributed under license by Red Hat, Inc. All rights reserved.
4 | * This program is made available under the terms of the
5 | * Eclipse Public License v1.0 which accompanies this distribution,
6 | * and is available at http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Red Hat, Inc. - initial API and implementation
10 | ******************************************************************************/
11 | package org.jboss.tools.maven.polyglot.poc.internal.ui.translation;
12 |
13 | import java.io.File;
14 | import java.lang.reflect.InvocationTargetException;
15 |
16 | import org.eclipse.core.runtime.IProgressMonitor;
17 | import org.eclipse.core.runtime.IStatus;
18 | import org.eclipse.jface.dialogs.MessageDialog;
19 | import org.eclipse.jface.operation.IRunnableWithProgress;
20 | import org.eclipse.jface.wizard.Wizard;
21 | import org.eclipse.m2e.core.project.IMavenProjectFacade;
22 | import org.jboss.tools.maven.polyglot.poc.internal.core.preferences.IPolyglotPreferenceConstants;
23 | import org.jboss.tools.maven.polyglot.poc.internal.ui.PolyglotSupportUIActivator;
24 |
25 | /**
26 | * @author Fred Bricon
27 | */
28 | public class PolyglotTranslaterWizard extends Wizard {
29 |
30 | private PolyglotTranslaterWizardPage translaterPage;
31 | private IMavenProjectFacade facade;
32 |
33 | public PolyglotTranslaterWizard(IMavenProjectFacade facade) {
34 | this.facade = facade;
35 | setNeedsProgressMonitor(true);
36 | }
37 |
38 | @Override
39 | public void addPages() {
40 | translaterPage = new PolyglotTranslaterWizardPage(facade);
41 | addPage(translaterPage);
42 | }
43 |
44 | @Override
45 | public boolean performFinish() {
46 | final String versionOrNull = PolyglotSupportUIActivator.getDefault().getPreferenceStore().getString(IPolyglotPreferenceConstants.POLYGLOT_TRANSLATION_PLUGIN_VERSION);
47 | final String version = versionOrNull == null ? "" : versionOrNull.trim();
48 |
49 | final Language language = translaterPage.getLanguage();
50 | final boolean isAddExtension = translaterPage.isAddExtension();
51 | final File mvnExtensionsDir = translaterPage.getMvnExtensionsDir();
52 | IRunnableWithProgress op = new IRunnableWithProgress() {
53 | public void run(IProgressMonitor monitor) throws InvocationTargetException {
54 | monitor.beginTask("Project Translation", 3);
55 | try {
56 | // No, this is not how Jobs are supposed to be used
57 | final IStatus result = new PolyglotTranslaterJob(facade, language, isAddExtension, mvnExtensionsDir, version)
58 | .run(monitor);
59 | if (!result.isOK()) {
60 | throw new InvocationTargetException(result.getException());
61 | }
62 | } catch (Exception e) {
63 | e.printStackTrace();
64 | throw new InvocationTargetException(e);
65 | } finally {
66 | monitor.done();
67 | }
68 | }
69 | };
70 |
71 | try {
72 | getContainer().run(true, true, op);
73 | } catch (InterruptedException e) {
74 | return false;
75 | } catch (InvocationTargetException e) {
76 | Throwable realException = e.getTargetException();
77 | MessageDialog.openError(getShell(), "Translation failed", realException.getMessage());
78 | return false;
79 | }
80 | return true;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/src/main/java/org/jboss/tools/maven/polyglot/poc/internal/ui/translation/PolyglotTranslaterWizardPage.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 Red Hat, Inc.
3 | * Distributed under license by Red Hat, Inc. All rights reserved.
4 | * This program is made available under the terms of the
5 | * Eclipse Public License v1.0 which accompanies this distribution,
6 | * and is available at http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Red Hat, Inc. - initial API and implementation
10 | ******************************************************************************/
11 | package org.jboss.tools.maven.polyglot.poc.internal.ui.translation;
12 |
13 | import java.io.File;
14 | import java.util.Arrays;
15 | import java.util.stream.Collectors;
16 |
17 | import org.eclipse.jface.wizard.WizardPage;
18 | import org.eclipse.m2e.core.project.IMavenProjectFacade;
19 | import org.eclipse.swt.SWT;
20 | import org.eclipse.swt.layout.GridData;
21 | import org.eclipse.swt.layout.GridLayout;
22 | import org.eclipse.swt.widgets.Combo;
23 | import org.eclipse.swt.widgets.Composite;
24 | import org.eclipse.swt.widgets.Label;
25 |
26 | /**
27 | * @author Fred Bricon
28 | */
29 | public class PolyglotTranslaterWizardPage extends WizardPage {
30 |
31 | private boolean addExtension = true;
32 | private File mvnExtensionsDir;
33 |
34 | private Combo languagesCombo;
35 |
36 | public boolean isAddExtension() {
37 | return addExtension;
38 | }
39 |
40 | public File getMvnExtensionsDir() {
41 | return mvnExtensionsDir;
42 | }
43 |
44 | public Language getLanguage() {
45 | return Language.valueOf(languagesCombo.getText());
46 | }
47 |
48 | protected PolyglotTranslaterWizardPage(IMavenProjectFacade facade) {
49 | super("Translate Project to Polyglot Maven");
50 | setTitle("Translate "+facade.getProject().getName() + " to Polyglot Maven");
51 | mvnExtensionsDir = new File(facade.getPomFile().getParentFile(), ".mvn");
52 | }
53 |
54 | @Override
55 | public void createControl(Composite parent) {
56 | Composite container = new Composite(parent, SWT.NULL);
57 | setControl(container);
58 | container.setLayout(new GridLayout(2, false));
59 |
60 | Label lblTranslateProjectTo = new Label(container, SWT.NONE);
61 | lblTranslateProjectTo.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
62 | lblTranslateProjectTo.setText("Translate project pom.xml to");
63 |
64 | languagesCombo = new Combo(container, SWT.READ_ONLY);
65 | GridData gd_combo = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
66 | gd_combo.widthHint = 100;
67 | languagesCombo.setLayoutData(gd_combo);
68 | languagesCombo.setItems(getLanguages());
69 | languagesCombo.setText(Language.groovy.name());
70 | }
71 |
72 | private String[] getLanguages() {
73 | return Arrays.asList(Language.values())
74 | .stream()
75 | .map(lang -> lang.name())
76 | .collect(Collectors.toList())
77 | .toArray(new String[Language.values().length]);
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/org.jboss.tools.maven.polyglot.poc.ui/src/main/java/org/jboss/tools/maven/polyglot/poc/internal/ui/translation/TranslateToPolyglotProjectHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 Red Hat, Inc.
3 | * Distributed under license by Red Hat, Inc. All rights reserved.
4 | * This program is made available under the terms of the
5 | * Eclipse Public License v1.0 which accompanies this distribution,
6 | * and is available at http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Red Hat, Inc. - initial API and implementation
10 | ******************************************************************************/
11 | package org.jboss.tools.maven.polyglot.poc.internal.ui.translation;
12 |
13 | import org.eclipse.core.commands.AbstractHandler;
14 | import org.eclipse.core.commands.ExecutionEvent;
15 | import org.eclipse.core.commands.ExecutionException;
16 | import org.eclipse.core.resources.IProject;
17 | import org.eclipse.core.resources.IResource;
18 | import org.eclipse.core.runtime.IAdaptable;
19 | import org.eclipse.core.runtime.NullProgressMonitor;
20 | import org.eclipse.jface.viewers.ISelection;
21 | import org.eclipse.jface.viewers.IStructuredSelection;
22 | import org.eclipse.jface.wizard.WizardDialog;
23 | import org.eclipse.m2e.core.MavenPlugin;
24 | import org.eclipse.m2e.core.project.IMavenProjectFacade;
25 | import org.eclipse.swt.widgets.Display;
26 | import org.eclipse.swt.widgets.Shell;
27 | import org.eclipse.ui.handlers.HandlerUtil;
28 |
29 | /**
30 | * @author Fred Bricon
31 | */
32 | public class TranslateToPolyglotProjectHandler extends AbstractHandler {
33 |
34 | @Override
35 | public Object execute(ExecutionEvent event) throws ExecutionException {
36 | final IProject project = getSelectedProject(event);
37 | if (project == null) {
38 | return null;
39 | }
40 | final Shell shell = HandlerUtil.getActiveShell(event);
41 | Display.getDefault().asyncExec(new Runnable() {
42 |
43 | @Override
44 | public void run() {
45 | IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project, new NullProgressMonitor());
46 | if (facade == null) {
47 | return;
48 | }
49 | PolyglotTranslaterWizard wizard = new PolyglotTranslaterWizard(facade);
50 | WizardDialog wizardDialog = new WizardDialog(shell, wizard);
51 | wizardDialog.setPageSize(150, 100);
52 | wizardDialog.open();
53 | }
54 | });
55 | return null;
56 | }
57 |
58 | private IProject getSelectedProject(ExecutionEvent event) {
59 | ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
60 | if (currentSelection instanceof IStructuredSelection) {
61 | Object o = ((IStructuredSelection)currentSelection).getFirstElement();
62 | if (o instanceof IResource) {
63 | return ((IResource)o).getProject();
64 | } else if (o instanceof IAdaptable) {
65 | return (IProject)((IAdaptable)o).getAdapter(IProject.class);
66 | }
67 | }
68 | return null;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | org.jboss.tools.maven.polyglot.poc
5 | org.jboss.tools.maven.polyglot.poc
6 | 0.0.1-SNAPSHOT
7 | pom
8 | ${projectName} :: parent
9 | ${projectName}
10 |
11 |
12 | M2E Polyglot Support Experiment
13 | UTF-8
14 | UTF-8
15 | 1.1.0
16 | ${tycho.version}
17 |
18 | -Xmx512m
19 |
20 |
21 |
22 |
23 | oxygen
24 | p2
25 | http://download.eclipse.org/releases/oxygen
26 |
27 |
28 |
29 |
30 |
31 | org.eclipse.tycho
32 | tycho-maven-plugin
33 | ${tycho.version}
34 | true
35 |
36 |
37 | org.eclipse.tycho
38 | target-platform-configuration
39 | ${tycho.version}
40 |
41 | p2
42 | consider
43 | true
44 |
45 |
46 |
47 | org.eclipse.tycho
48 | tycho-source-plugin
49 | ${tycho.version}
50 |
51 |
52 | attach-source
53 |
54 | plugin-source
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.eclipse.tycho
65 | tycho-packaging-plugin
66 | ${tycho.version}
67 |
68 | yyyyMMdd-HHmm
69 |
70 |
71 |
72 | org.eclipse.tycho
73 | tycho-surefire-plugin
74 | ${tycho.version}
75 |
76 | true
77 | ${tycho.test.jvmArgs}
78 |
79 | 60
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | macosx
88 |
89 | mac
90 |
91 |
92 | -XstartOnFirstThread
93 |
94 |
95 |
96 | source-feature
97 |
98 |
99 | feature.xml
100 |
101 |
102 |
103 |
104 |
105 | org.eclipse.tycho.extras
106 | tycho-source-feature-plugin
107 | ${tycho.extras.version}
108 |
109 |
110 | source-feature
111 | package
112 |
113 | source-feature
114 |
115 |
116 |
117 |
118 |
119 | org.eclipse.tycho
120 | tycho-p2-plugin
121 | ${tycho.version}
122 |
123 |
124 | attach-p2-metadata
125 | package
126 |
127 | p2-metadata
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 | org.jboss.tools.maven.polyglot.poc.core
138 | org.jboss.tools.maven.polyglot.poc.ui
139 |
140 | org.jboss.tools.maven.polyglot.poc.feature
141 | org.jboss.tools.maven.polyglot.poc.site
142 |
143 |
144 |
--------------------------------------------------------------------------------