Skip to content

Commit

Permalink
[all] Change the output directory for SARL.
Browse files Browse the repository at this point in the history
The new output directory is "src/main/generated-sources/sarl".

see #240

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Nov 10, 2015
1 parent 61a225d commit 0d6a33d
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 43 deletions.
Expand Up @@ -79,7 +79,7 @@ describe "Create First Project" {
*
* * `src/main/java`: for your Java classes;
* * `src/main/sarl`: for your SARL scripts;
* * `src/main/generated-sources/xtend`: for the Java codes generated by the SARL compiler (you should not change them yourself);
* * `src/main/generated-sources/sarl`: for the Java codes generated by the SARL compiler (you should not change them yourself);
* * `src/main/resources`: for the files that are not SARL nor Java code.
*
* <p>The default output folder is `target/classes`.
Expand All @@ -95,7 +95,7 @@ describe "Create First Project" {
fact "Step 2: Configuration of the source folders" {
SARLConfig::FOLDER_SOURCE_JAVA should be "src/main/java"
SARLConfig::FOLDER_SOURCE_SARL should be "src/main/sarl"
SARLConfig::FOLDER_SOURCE_GENERATED should be "src/main/generated-sources/xtend"
SARLConfig::FOLDER_SOURCE_GENERATED should be "src/main/generated-sources/sarl"
SARLConfig::FOLDER_RESOURCES should be "src/main/resources"
SARLConfig::FOLDER_BIN should be "target/classes"
"./new_sarl_project_screen_3.png" should beAccessibleFrom this
Expand Down Expand Up @@ -170,7 +170,7 @@ describe "Create First Project" {
*/
fact "Edit the Maven configuration" {
// Check if the SARL code is generated in the expected folder
SARLConfig::FOLDER_SOURCE_GENERATED should be "src/main/generated-sources/xtend"
SARLConfig::FOLDER_SOURCE_GENERATED should be "src/main/generated-sources/sarl"
// The checks are valid only if the macro replacements were done.
// The replacements are done by Maven.
// So, Eclipse Junit tools do not make the replacements.
Expand Down Expand Up @@ -243,7 +243,7 @@ describe "Create First Project" {
*
* @filter(.*)
*/
fact "Configuration a runtime environment (optional)" {
fact "Configuration of a runtime environment (optional)" {
// The checks are valid only if the macro replacements were done.
// The replacements are done by Maven.
// So, Eclipse Junit tools do not make the replacements.
Expand Down
2 changes: 1 addition & 1 deletion plugins/io.sarl.core/build.properties
@@ -1,6 +1,6 @@
source.. = src/main/java/,\
src/main/sarl/,\
src/main/generated-sources/xtend/
src/main/generated-sources/sarl/
bin.includes = META-INF/,\
.,\
OSGI-INF/
Expand Down
12 changes: 9 additions & 3 deletions plugins/io.sarl.core/pom.xml
Expand Up @@ -36,8 +36,8 @@
<configuration>
<sources>
<source>src/main/sarl</source>
<source>src/main/generated-sources/xtend/</source>
<source>src/test/generated-sources/xtend/</source>
<source>src/main/generated-sources/sarl/</source>
<source>src/test/generated-sources/sarl/</source>
</sources>
</configuration>
</execution>
Expand All @@ -55,9 +55,15 @@
</goals>
<configuration>
<filesets>
<fileset>
<directory>src/main/generated-sources/sarl</directory>
</fileset>
<fileset>
<directory>src/main/generated-sources/xtend</directory>
</fileset>
<fileset>
<directory>src/test/generated-sources/sarl</directory>
</fileset>
<fileset>
<directory>src/test/generated-sources/xtend</directory>
</fileset>
Expand Down Expand Up @@ -87,7 +93,7 @@
<setup>io.sarl.lang.SARLStandaloneSetup</setup>
<outputConfigurations>
<outputConfiguration>
<outputDirectory>src/main/generated-sources/xtend/</outputDirectory>
<outputDirectory>src/main/generated-sources/sarl/</outputDirectory>
</outputConfiguration>
</outputConfigurations>
</language>
Expand Down
Expand Up @@ -603,13 +603,16 @@ public void performFinish(IProgressMonitor monitor) throws CoreException, Interr
configureJavaProject(newProjectCompliance, new SubProgressMonitor(monitor, 1));

IPath generationFolder = findGenerationSourcePath();
if (generationFolder != null) {
SARLPreferences.setSpecificSARLConfigurationFor(
getJavaProject().getProject(), generationFolder);
} else {
SARLPreferences.setSystemSARLConfigurationFor(
getJavaProject().getProject());
}
if (generationFolder == null) {
IStatus status = SARLEclipsePlugin.getDefault().createStatus(
IStatus.ERROR,
MessageFormat.format(
Messages.BuildSettingWizardPage_0,
SARLConfig.FOLDER_SOURCE_GENERATED));
throw new CoreException(status);
}
SARLPreferences.setSpecificSARLConfigurationFor(
getJavaProject().getProject(), generationFolder);
} catch (Throwable e) {
if (this.fCurrProject != null) {
removeProvisonalProject();
Expand Down
Expand Up @@ -34,11 +34,37 @@ public class Messages extends NLS {

private static final String BUNDLE_NAME = "io.sarl.eclipse.wizards.newproject.messages"; //$NON-NLS-1$

public static String BuildSettingWizardPage_0;

public static String JavaProjectWizard_op_error_create_message;

public static String JavaProjectWizard_op_error_title;

public static String MainProjectPage_0;public static String SARLProjectCreationWizard_0;
public static String MainProjectPage_0;public static String NewJavaProjectWizardPageTwo_DeleteCorruptProjectFile_message;

public static String NewJavaProjectWizardPageTwo_error_message;

public static String NewJavaProjectWizardPageTwo_error_remove_message;

public static String NewJavaProjectWizardPageTwo_error_remove_title;

public static String NewJavaProjectWizardPageTwo_error_title;

public static String NewJavaProjectWizardPageTwo_monitor_init_build_path;

public static String NewJavaProjectWizardPageTwo_operation_create;

public static String NewJavaProjectWizardPageTwo_operation_initialize;

public static String NewJavaProjectWizardPageTwo_operation_remove;

public static String NewJavaProjectWizardPageTwo_problem_backup;

public static String NewJavaProjectWizardPageTwo_problem_restore_classpath;

public static String NewJavaProjectWizardPageTwo_problem_restore_project;

public static String SARLProjectCreationWizard_0;

public static String SARLProjectNewWizard_0;
public static String SARLProjectNewWizard_1;
Expand Down
Expand Up @@ -62,6 +62,7 @@
import io.sarl.eclipse.properties.RuntimeEnvironmentPropertyPage;
import io.sarl.eclipse.runtime.ISREInstall;
import io.sarl.eclipse.util.Utilities;
import io.sarl.lang.SARLConfig;
import io.sarl.lang.ui.preferences.SARLPreferences;

/**
Expand Down Expand Up @@ -167,35 +168,23 @@ private static String toOSString(IPath path) {
protected boolean validateSARLSpecificElements(IJavaElement element) {
IJavaProject javaProject = (IJavaProject) element;
// Check if the "SARL" generation directory is a source folder.
IPath outputPath;
IPath generalPreferencePath;
IPath projectSpecificPath = SARLPreferences.getSARLOutputPathFor(javaProject.getProject());
IPath outputPath = SARLPreferences.getSARLOutputPathFor(javaProject.getProject());

generalPreferencePath = SARLPreferences.getGlobalSARLOutputPath();

if (projectSpecificPath != null) {
outputPath = projectSpecificPath;
generalPreferencePath = null;
} else {
generalPreferencePath = SARLPreferences.getGlobalSARLOutputPath();
outputPath = generalPreferencePath;
if (outputPath == null) {
String message = MessageFormat.format(
Messages.BuildSettingWizardPage_0,
SARLConfig.FOLDER_SOURCE_GENERATED);
IStatus status = SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, message);
handleFinishException(getShell(), new InvocationTargetException(new CoreException(status)));
return false;
}
assert (outputPath != null);
if (!hasSourcePath(javaProject, outputPath)) {
if (generalPreferencePath == null) {
generalPreferencePath = SARLPreferences.getGlobalSARLOutputPath();
}
assert (generalPreferencePath != null);
String message = MessageFormat.format(
Messages.SARLProjectCreationWizard_0,
toOSString(outputPath),
toOSString(projectSpecificPath),
toOSString(generalPreferencePath),
buildInvalidOutputPathMessageFragment(javaProject));
IStatus status = SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, message);

handleFinishException(getShell(), new InvocationTargetException(new CoreException(status)));

return false;
}
return true;
Expand Down
@@ -1,7 +1,20 @@
BuildSettingWizardPage_0=The source folder for the generated sources is not defined. The source folder '{0}' should be defined for example.
JavaProjectWizard_op_error_create_message=
JavaProjectWizard_op_error_title=
MainProjectPage_0=SRE
SARLProjectCreationWizard_0=The SARL output path {0} for the generated sources is not a source folder in the project. The source folders are:\n{3}Project-specific path={1}\nGeneral preference path={2}
NewJavaProjectWizardPageTwo_DeleteCorruptProjectFile_message=
NewJavaProjectWizardPageTwo_error_message=
NewJavaProjectWizardPageTwo_error_remove_message=
NewJavaProjectWizardPageTwo_error_remove_title=
NewJavaProjectWizardPageTwo_error_title=
NewJavaProjectWizardPageTwo_monitor_init_build_path=
NewJavaProjectWizardPageTwo_operation_create=
NewJavaProjectWizardPageTwo_operation_initialize=
NewJavaProjectWizardPageTwo_operation_remove=
NewJavaProjectWizardPageTwo_problem_backup=
NewJavaProjectWizardPageTwo_problem_restore_classpath=
NewJavaProjectWizardPageTwo_problem_restore_project=
SARLProjectCreationWizard_0=The SARL output path ''{0}'' for the generated sources is not a source folder in the project. The source folders are:\n{1}
SARLProjectNewWizard_0=New SARL Project
SARLProjectNewWizard_1=Create a SARL Project.
SARLProjectNewWizard_2=Define the SARL build settings.
Expand Down
11 changes: 8 additions & 3 deletions plugins/io.sarl.lang.ui/META-INF/MANIFEST.MF
Expand Up @@ -23,14 +23,19 @@ Require-Bundle: io.sarl.lang;bundle-version="1.0.0";visibility:=reexport,
org.eclipse.jdt.debug.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Activator: io.sarl.lang.ui.internal.SARLActivator
Export-Package: io.sarl.lang.ui.highlighting;x-friends:="io.sarl.lang.ui.tests",
Export-Package: io.sarl.lang.ui;x-friends:="io.sarl.lang.ui.tests",
io.sarl.lang.ui.contentassist,
io.sarl.lang.ui.contentassist.antlr,
io.sarl.lang.ui.contentassist.antlr.internal;x-friends:="io.sarl.lang.ui.tests",
io.sarl.lang.ui.highlighting;x-friends:="io.sarl.lang.ui.tests",
io.sarl.lang.ui.images;x-friends:="io.sarl.lang.ui.tests",
io.sarl.lang.ui.internal,
io.sarl.lang.ui.labeling;x-friends:="io.sarl.lang.ui.tests",
io.sarl.lang.ui.outline;x-friends:="io.sarl.lang.ui.tests",
io.sarl.lang.ui.preferences,
io.sarl.lang.ui.quickfix;x-friends:="io.sarl.lang.ui.tests",
io.sarl.lang.ui.quickfix.acceptors;x-friends:="io.sarl.lang.ui.tests",
io.sarl.lang.ui.contentassist,
io.sarl.lang.ui.contentassist.antlr
io.sarl.lang.ui.tasks;x-friends:="io.sarl.lang.ui.tests",
io.sarl.lang.ui.validation;x-friends:="io.sarl.lang.ui.tests",
org.eclipse.xtend.core.ui.contentassist;x-friends:="io.sarl.lang.ui.tests"
Import-Package: org.apache.log4j
4 changes: 2 additions & 2 deletions plugins/io.sarl.lang/src/io/sarl/lang/SARLConfig.java
Expand Up @@ -42,15 +42,15 @@ public final class SARLConfig {

/** Path of the generated source files.
*/
public static final String FOLDER_SOURCE_GENERATED = "src/main/generated-sources/xtend"; //$NON-NLS-1$
public static final String FOLDER_SOURCE_GENERATED = "src/main/generated-sources/sarl"; //$NON-NLS-1$

/** Path of the Java source files.
*/
public static final String FOLDER_TEST_SOURCE_SARL = "src/test/sarl"; //$NON-NLS-1$

/** Path of the SARL source files.
*/
public static final String FOLDER_TEST_SOURCE_GENERATED = "src/test/generated-sources/xtend"; //$NON-NLS-1$
public static final String FOLDER_TEST_SOURCE_GENERATED = "src/test/generated-sources/sarl"; //$NON-NLS-1$

/** Path of the generated source files that should be no more used when creating
* new projects. This value is the default generation folder form Xtext.
Expand Down
Expand Up @@ -45,7 +45,7 @@ public class CompileMojoTest extends AbstractMojoTest {
public void compile() throws Exception {
Verifier verifier = executeMojo("prj1", "compile");
Path path = FileSystems.getDefault().getPath(
"src", "main", "generated-sources", "xtend",
"src", "main", "generated-sources", "sarl",
"io", "sarl", "maven", "compiler", "tests", "MyAgent.java");
assertNotNull(path);
verifier.assertFilePresent(path.toString());
Expand Down

0 comments on commit 0d6a33d

Please sign in to comment.