Skip to content

Commit

Permalink
Simplify to just archive configuration (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
jskov authored Apr 25, 2024
1 parent 790da4d commit c888f5d
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 556 deletions.
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# buildinfo-gradle
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jskov_buildinfo-gradle&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jskov_buildinfo-gradle)

A Gradle plugin that enables [reproducible builds](https://reproducible-builds.org/) by providing [buildinfo](https://reproducible-builds.org/docs/jvm) when publishing Maven artifacts.
A small Gradle plugin that enables [reproducible builds](https://reproducible-builds.org/) by [configuring archive tasks](https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives) to be reproducible.

The plugin also configures [reproducible archive tasks](https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives).
The only thing this Plugin provides is a slight simplification of the build files.

## Using the Plugin

Expand All @@ -23,21 +23,6 @@ And make sure the plugin can be fetched from MavenCentral:
}
}

## Open Source vs Expectancy of Work

This project is Open Source and I am happy for you to use the plugin, report bugs and suggest changes.

But while the source code is free, it does not come bundled with promises or guarantees of free work.

I will try to fix reported bugs (if I agree with them), but will commit to no time tables.

If you are itching to make some changes (to this repository), please open an issue first, so we can discuss.
I do not want you to waste your time!

If this is not agreeable, you are more than welcome to fork the project and do your own thing.

Open Source, Yay!

## Development

For testing snapshot builds in other projects:
Expand Down
24 changes: 0 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ gradlePlugin {
implementationClass = 'dk.mada.buildinfo.BuildinfoPlugin'
}
}

testSourceSets sourceSets.test
}

publishing {
Expand Down Expand Up @@ -85,25 +83,3 @@ project.afterEvaluate { p ->
}
}
}

// Makes it possible to run Plugin tests
tasks.eclipse {
dependsOn('processResources')
doLast {
project.delete("build/pluginUnderTestMetadata")
project.mkdir("build/pluginUnderTestMetadata")
project.file("./build/pluginUnderTestMetadata/plugin-under-test-metadata.properties") <<
"implementation-classpath=${project.rootDir}/bin/main:${project.rootDir}/build/resources/main\n"
}
}

test {
useJUnitPlatform()

inputs.file("src/test/data/plugin/expected-buildinfo.txt")

testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}
27 changes: 17 additions & 10 deletions src/main/java/dk/mada/buildinfo/BuildinfoPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.logging.Logger;
import org.gradle.api.tasks.bundling.AbstractArchiveTask;

import dk.mada.buildinfo.tasks.GenerateBuildInfo;

/**
* Plugin providing a generateBuildInfo task.
*
* The plugin also configures archive tasks to be reproducible.
* Plugin configures archive tasks to be reproducible.
*/
public final class BuildinfoPlugin implements Plugin<Project> {

Expand All @@ -22,12 +19,22 @@ public BuildinfoPlugin() {

@Override
public void apply(Project project) {
project.getTasks().register("generateBuildInfo", GenerateBuildInfo.class)
.configure(GenerateBuildInfo::lazyConfiguration);
Logger logger = project.getLogger();

if (project.getParent() != null) {
logger.warn("Plugin should only be applied on the main project");
return;
}

project.getTasks().withType(AbstractArchiveTask.class).configureEach(jar -> {
jar.setReproducibleFileOrder(true);
jar.setPreserveFileTimestamps(false);
project.allprojects(aProject -> {
aProject.afterEvaluate(postEvaluatedProject -> {
logger.info("Configure jars in evaluated {}", postEvaluatedProject);
postEvaluatedProject.getTasks().withType(AbstractArchiveTask.class).configureEach(jar -> {
logger.info("Making {} reproducible", jar.getName());
jar.setReproducibleFileOrder(true);
jar.setPreserveFileTimestamps(false);
});
});
});
}
}
Loading

0 comments on commit c888f5d

Please sign in to comment.