This repository has been archived by the owner on Apr 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
XtextGenerateMojo.java
69 lines (59 loc) · 2.42 KB
/
XtextGenerateMojo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*******************************************************************************
* Copyright (c) 2020 Jan Rosczak and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.xtext.maven;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Sets.newLinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.eclipse.xtext.ISetup;
/**
* Generates sources of all contributing {@link ISetup} language instances
*
* @author Jan Rosczak - Initial contribution and API
*/
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true)
public class XtextGenerateMojo extends AbstractXtextGeneratorMojo {
/**
* Project classpath.
*/
@Parameter(defaultValue = "${project.compileClasspathElements}", readonly = true, required = true)
private List<String> classpathElements;
@Override
public Set<String> getClasspathElements() {
Set<String> classpathElements = newLinkedHashSet();
classpathElements.addAll(this.classpathElements);
classpathElements.remove(getProject().getBuild().getOutputDirectory());
classpathElements.remove(getProject().getBuild().getTestOutputDirectory());
Set<String> nonEmptyElements = newLinkedHashSet(filter(classpathElements, emptyStringFilter()));
return nonEmptyElements;
}
@Override
protected void configureMavenOutputs() {
for (Language language : getLanguages()) {
addCompileSourceRoots(language);
}
}
/**
* Project source roots. List of folders, where the source models are
* located.<br>
* The default value is a reference to the project's
* ${project.compileSourceRoots}.<br>
* When adding a new entry the default value will be overwritten not extended.
*/
@Parameter(defaultValue = "${project.compileSourceRoots}", required = true)
private List<String> sourceRoots;
@Override
protected List<String> getSourceRoots() {
return sourceRoots;
}
}