Created
February 3, 2014 16:37
-
-
Save anthonydahanne/8787256 to your computer and use it in GitHub Desktop.
m2e plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<lifecycleMappingMetadata> | |
<pluginExecutions> | |
<pluginExecution> | |
<pluginExecutionFilter> | |
<groupId>org.jvnet.localizer</groupId> | |
<artifactId>maven-localizer-plugin</artifactId> | |
<versionRange>[1.0,2.0)</versionRange> | |
<goals> | |
<goal>generate</goal> | |
</goals> | |
</pluginExecutionFilter> | |
<action> | |
<configurator> | |
<id>net.dahanne.eclipse.m2e.localizer.localizerProjectConfigurator</id> | |
</configurator> | |
</action> | |
</pluginExecution> | |
</pluginExecutions> | |
</lifecycleMappingMetadata> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.dahanne.eclipse.m2e.localizer; | |
import java.io.File; | |
import java.util.Set; | |
import org.apache.maven.plugin.MojoExecution; | |
import org.apache.maven.project.MavenProject; | |
import org.eclipse.core.resources.IProject; | |
import org.eclipse.core.runtime.IProgressMonitor; | |
import org.eclipse.m2e.core.MavenPlugin; | |
import org.eclipse.m2e.core.embedder.IMaven; | |
import org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant; | |
import org.sonatype.plexus.build.incremental.BuildContext; | |
public class LocalizerDefaultGenerateSourcesBuildParticipant extends MojoExecutionBuildParticipant { | |
public LocalizerDefaultGenerateSourcesBuildParticipant(MojoExecution execution) { | |
super(execution, true); | |
} | |
@Override | |
public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception { | |
IMaven maven = MavenPlugin.getMaven(); | |
BuildContext buildContext = getBuildContext(); | |
// execute mojo | |
Set<IProject> result = super.build(kind, monitor); | |
// tell m2e builder to refresh generated files | |
MavenProject mavenProject = getSession().getCurrentProject(); | |
File generated = maven.getMojoParameterValue(mavenProject, getMojoExecution(), "generated-sources", File.class, monitor); | |
if (generated != null) { | |
buildContext.refresh(generated); | |
} | |
return result; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.dahanne.eclipse.m2e.localizer; | |
import java.io.File; | |
import org.apache.maven.plugin.MojoExecution; | |
import org.eclipse.core.runtime.CoreException; | |
import org.eclipse.core.runtime.IProgressMonitor; | |
import org.eclipse.m2e.core.lifecyclemapping.model.IPluginExecutionMetadata; | |
import org.eclipse.m2e.core.project.IMavenProjectFacade; | |
import org.eclipse.m2e.core.project.configurator.AbstractBuildParticipant; | |
import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest; | |
import org.eclipse.m2e.jdt.AbstractSourcesGenerationProjectConfigurator; | |
public class LocalizerProjectConfigurator extends AbstractSourcesGenerationProjectConfigurator { | |
@Override | |
public AbstractBuildParticipant getBuildParticipant(IMavenProjectFacade projectFacade, MojoExecution execution, | |
IPluginExecutionMetadata executionMetadata) { | |
return new LocalizerDefaultGenerateSourcesBuildParticipant(execution); | |
} | |
@Override | |
@SuppressWarnings("deprecation") | |
protected File[] getSourceFolders(ProjectConfigurationRequest request, MojoExecution mojoExecution, IProgressMonitor monitor) throws CoreException { | |
// there is no variable to reference aidl generated classes, so we have | |
// to guess | |
File aidlGeneratedSourcesFolder = new File(request.getProject().getLocation().toOSString() + "/../" | |
+ request.getMavenProjectFacade().getOutputLocation().toOSString() + "/../generated-sources/localizer"); | |
// not yet implemented in android maven plugin (as of 3.0.0-alpha13) | |
File[] generatedSourcesFolders = new File[] { | |
getParameterValue("generated-sources", File.class, request.getMavenSession(), mojoExecution), | |
aidlGeneratedSourcesFolder }; | |
return generatedSourcesFolders; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<?eclipse version="3.4"?> | |
<plugin> | |
<extension | |
point="org.eclipse.m2e.core.projectConfigurators"> | |
<configurator | |
class="net.dahanne.eclipse.m2e.localizer.LocalizerProjectConfigurator" | |
id="net.dahanne.eclipse.m2e.localizer.localizerProjectConfigurator" | |
name="Localizer m2eclipse Configurator"> | |
</configurator> | |
</extension> | |
<extension | |
point="org.eclipse.m2e.core.lifecycleMappingMetadataSource"> | |
</extension> | |
</plugin> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment