-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add create, list-extensions and add-extension mojos #165
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f730111
Initial support of the setup mojo
cescoffier 8c2672a
Merge branch 'master' of github.com:protean-project/shamrock into add…
cescoffier 89ffdb2
Do not apply filtering on templates
cescoffier ddfbe6d
Add profile support
cescoffier 0eaec4e
Merge branch 'master' of github.com:protean-project/shamrock into add…
cescoffier daab74d
Implementation of the create mojo
cescoffier 83a48e9
Fix local repo location
cescoffier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<settings> | ||
<profiles> | ||
<profile> | ||
<id>it-repo</id> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
<repositories> | ||
<repository> | ||
<id>local.central</id> | ||
<url>@localRepositoryUrl@</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>local.central</id> | ||
<url>@localRepositoryUrl@</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
</profile> | ||
</profiles> | ||
</settings> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:create |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.acme</groupId> | ||
<artifactId>shamrock-setup-demo</artifactId> | ||
<version>0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import org.jboss.shamrock.maven.it.SetupVerifier | ||
stuartwdouglas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
String base = basedir | ||
File pomFile = new File(base, "pom.xml") | ||
|
||
SetupVerifier.verifySetup(pomFile) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:create |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ | ||
~ Copyright (c) 2016-2018 Red Hat, Inc. | ||
~ | ||
~ Red Hat licenses this file to you under the Apache License, version | ||
~ 2.0 (the "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
~ implied. See the License for the specific language governing | ||
~ permissions and limitations under the License. | ||
--> | ||
|
||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.acme</groupId> | ||
<artifactId>shamrock-setup-demo</artifactId> | ||
<version>0.1-SNAPSHOT</version> | ||
</project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import org.jboss.shamrock.maven.it.SetupVerifier | ||
|
||
String base = basedir | ||
File pomFile = new File(base, "pom.xml") | ||
|
||
SetupVerifier.verifySetup(pomFile) |
1 change: 1 addition & 0 deletions
1
maven/src/it/setup-with-custom-shamrock-version-it/invoker.properties
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:create -DshamrockVersion=0.0.0 |
30 changes: 30 additions & 0 deletions
30
maven/src/it/setup-with-custom-shamrock-version-it/pom.xml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.acme</groupId> | ||
<artifactId>shamrock-setup-demo</artifactId> | ||
<version>0.1-SNAPSHOT</version> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
6 changes: 6 additions & 0 deletions
6
maven/src/it/setup-with-custom-shamrock-version-it/verify.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import org.jboss.shamrock.maven.it.SetupVerifier | ||
|
||
String base = basedir | ||
File pomFile = new File(base, "pom.xml") | ||
|
||
SetupVerifier.verifySetupWithVersion(pomFile) |
50 changes: 50 additions & 0 deletions
50
maven/src/main/java/org/jboss/shamrock/maven/AddExtensionMojo.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.jboss.shamrock.maven; | ||
|
||
import org.apache.maven.model.Model; | ||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer; | ||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.apache.maven.project.MavenProject; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import static org.jboss.shamrock.maven.components.dependencies.Extensions.addExtensions; | ||
|
||
@Mojo(name = "add-extension", requiresProject = true) | ||
public class AddExtensionMojo extends AbstractMojo { | ||
|
||
/** | ||
* The Maven project which will define and configure the shamrock-maven-plugin | ||
*/ | ||
@Parameter(defaultValue = "${project}") | ||
protected MavenProject project; | ||
|
||
@Parameter(property = "extensions") | ||
private List<String> extensions; | ||
|
||
|
||
@Override | ||
public void execute() throws MojoExecutionException { | ||
Model model = project.getOriginalModel().clone(); | ||
if (addExtensions(model, extensions, getLog())) { | ||
File pomFile = project.getFile(); | ||
save(pomFile, model); | ||
} | ||
} | ||
|
||
private void save(File pomFile, Model model) throws MojoExecutionException { | ||
MavenXpp3Writer xpp3Writer = new MavenXpp3Writer(); | ||
try (FileWriter pomFileWriter = new FileWriter(pomFile)) { | ||
xpp3Writer.write(pomFileWriter, model); | ||
pomFileWriter.flush(); | ||
} catch (IOException e) { | ||
throw new MojoExecutionException("Unable to write the pom.xml file", e); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should probably be managed in the parent pom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, will fix it.