forked from rockcrafters/java-rockcraft-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rockcrafters#21 from vpa1977/maven-plugin
chore: refactor plugin into common and gradle part
- Loading branch information
Showing
20 changed files
with
442 additions
and
225 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Add 'documentation' label to any changes within 'docs' folder or any subfolders | ||
documentation: | ||
- changed-files: | ||
- any-glob-to-any-file: docs/** | ||
- changed-files: | ||
- any-glob-to-any-file: docs/** |
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
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
67 changes: 67 additions & 0 deletions
67
rockcraft-gradle/src/main/java/com/canonical/rockcraft/gradle/CreateRockcraftTask.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,67 @@ | ||
/** | ||
* Copyright 2024 Canonical Ltd. | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* <p> | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.canonical.rockcraft.gradle; | ||
|
||
import com.canonical.rockcraft.builder.RockCrafter; | ||
import com.canonical.rockcraft.builder.RockProjectSettings; | ||
import com.canonical.rockcraft.builder.RockcraftOptions; | ||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.tasks.TaskAction; | ||
|
||
import javax.inject.Inject; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
|
||
/** | ||
* This task writes <i>rockcraft.yaml</i> file for the application. | ||
*/ | ||
public abstract class CreateRockcraftTask extends DefaultTask { | ||
|
||
private final RockcraftOptions options; | ||
|
||
/** | ||
* Constructs the CreateRockcraft task | ||
* @param options - plugin options | ||
*/ | ||
@Inject | ||
public CreateRockcraftTask(RockcraftOptions options) { | ||
this.options = options; | ||
} | ||
|
||
private RockcraftOptions getOptions() { | ||
return options; | ||
} | ||
|
||
/** | ||
* Task action to write <i>rockcraft.yaml</i> | ||
*/ | ||
@TaskAction | ||
public void writeRockcraft() { | ||
HashSet<File> artifacts = new HashSet<File>(); | ||
for (var conf : getProject().getConfigurations()) { | ||
artifacts.addAll(conf.getArtifacts().getFiles().getFiles().stream().filter(x -> x.getName().endsWith("jar")).toList()); | ||
} | ||
|
||
try { | ||
var buildDir = getProject().getLayout().getBuildDirectory(); | ||
var settings = new RockProjectSettings(getProject().getName(), String.valueOf(getProject().getVersion()), getProject().getProjectDir().toPath()); | ||
RockCrafter crafter = new RockCrafter(settings, getOptions(), buildDir.getAsFile().get(), new ArrayList<File>(artifacts)); | ||
crafter.writeRockcraft(); | ||
} catch (IOException e) { | ||
throw new UnsupportedOperationException("Failed to write rockcraft.yaml: " + e.getMessage()); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.