NIFI-6666 removing all modifications to the nifi-api and the newly created builder class

This closes #4475.

Signed-off-by: Andy LoPresto <alopresto@apache.org>
This commit is contained in:
Joe Witt 2020-08-12 17:11:29 -07:00 committed by Andy LoPresto
parent 3e18d5b236
commit 4417b9d64a
No known key found for this signature in database
GPG Key ID: 6EC293152D90B61D
7 changed files with 4 additions and 276 deletions

View File

@ -23,99 +23,4 @@
<artifactId>nifi-api</artifactId>
<packaging>jar</packaging>
<!-- This module should kept to having no dependencies -->
<build>
<plugins>
<plugin>
<!-- https://github.com/git-commit-id/maven-git-commit-id-plugin -->
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- This is the same as the default date time format of this plugin. -->
<!-- Because we want to parse the result we are fixing it to avoid problems. -->
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>Generate NifiBuildProperties Java class</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>${project.basedir}/src/main/code-gen/NifiBuildProperties.java.template</file>
<outputFile>${project.build.directory}/generated-sources/java/org/apache/nifi/build/NifiBuildProperties.java</outputFile>
</configuration>
</execution>
</executions>
<configuration>
<replacements>
<replacement>
<token>#maven.build.timestamp#</token>
<value>${maven.build.timestamp}</value>
</replacement>
<replacement>
<token>#project.version#</token>
<value>${project.version}</value>
</replacement>
<replacement><token>#git.branch#</token><value>${git.branch}</value></replacement>
<replacement><token>#git.build.number#</token><value>${git.build.number}</value></replacement>
<replacement><token>#git.build.number.unique#</token><value>${git.build.number.unique}</value></replacement>
<replacement><token>#git.build.time#</token><value>${git.build.time}</value></replacement>
<replacement><token>#git.build.version#</token><value>${git.build.version}</value></replacement>
<replacement><token>#git.closest.tag.commit.count#</token><value>${git.closest.tag.commit.count}</value></replacement>
<replacement><token>#git.closest.tag.name#</token><value>${git.closest.tag.name}</value></replacement>
<replacement><token>#git.commit.id#</token><value>${git.commit.id}</value></replacement>
<replacement><token>#git.commit.id.abbrev#</token><value>${git.commit.id.abbrev}</value></replacement>
<replacement><token>#git.commit.id.describe#</token><value>${git.commit.id.describe}</value></replacement>
<replacement><token>#git.commit.id.describe-short#</token><value>${git.commit.id.describe-short}</value></replacement>
<replacement><token>#git.commit.time#</token><value>${git.commit.time}</value></replacement>
<replacement><token>#git.dirty#</token><value>${git.dirty}</value></replacement>
<replacement><token>#git.total.commit.count#</token><value>${git.total.commit.count}</value></replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/java/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,93 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.
*/
package org.apache.nifi.build;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Properties;
public final class NifiBuildProperties {
private static final String MAVEN_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ssX";
private static final String GIT_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
public static final String NIFI_VERSION = "#project.version#";
public static final Instant BUILD_TIMESTAMP = parseDateTime("#maven.build.timestamp#", MAVEN_TIMESTAMP_FORMAT);
public static final String BUILD_TIMESTAMP_STR = instantToString(BUILD_TIMESTAMP);
public static final String BUILD_GIT_BRANCH = "#git.branch#";
public static final String BUILD_GIT_BUILD_NUMBER = "#git.build.number#";
public static final String BUILD_GIT_BUILD_NUMBER_UNIQUE = "#git.build.number.unique#";
public static final Instant BUILD_GIT_BUILD_TIME = parseDateTime("#git.build.time#", GIT_TIMESTAMP_FORMAT);
public static final String BUILD_GIT_BUILD_TIME_STR = instantToString(BUILD_GIT_BUILD_TIME);
public static final String BUILD_GIT_BUILD_VERSION = "#git.build.version#";
public static final String BUILD_GIT_CLOSEST_TAG_COMMIT_COUNT = "#git.closest.tag.commit.count#";
public static final String BUILD_GIT_CLOSEST_TAG_NAME = "#git.closest.tag.name#";
public static final String BUILD_GIT_COMMIT_ID = "#git.commit.id#";
public static final String BUILD_GIT_COMMIT_ID_ABBREV = "#git.commit.id.abbrev#";
public static final String BUILD_GIT_COMMIT_ID_DESCRIBE = "#git.commit.id.describe#";
public static final String BUILD_GIT_COMMIT_ID_DESCRIBE_SHORT = "#git.commit.id.describe-short#";
public static final Instant BUILD_GIT_COMMIT_TIME = parseDateTime("#git.commit.time#", GIT_TIMESTAMP_FORMAT);
public static final String BUILD_GIT_COMMIT_TIME_STR = instantToString(BUILD_GIT_COMMIT_TIME);
public static final String BUILD_GIT_DIRTY = "#git.dirty#";
public static final String BUILD_GIT_TOTAL_COMMIT_COUNT = "#git.total.commit.count#";
private static Instant parseDateTime(String dateTime, String pattern) {
// This is to reliably parse the datetime format configured in the git-commit-id-plugin
try {
return DateTimeFormatter.ofPattern(pattern).parse(dateTime, Instant::from);
} catch (DateTimeParseException dtpe) {
return Instant.EPOCH;
}
}
private static String instantToString(Instant dateTime) {
// Default zone to format the build time in.
try {
return DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneId.of("Europe/Amsterdam")).format(dateTime);
} catch (DateTimeParseException dtpe) {
return "1970-01-01T00:00:00+0000";
}
}
public static final Properties getBuildProperties() {
Properties properties = new Properties();
properties.setProperty("nifi.version", NIFI_VERSION );
properties.setProperty("nifi.build.timestamp", BUILD_TIMESTAMP_STR );
properties.setProperty("nifi.build.git.branch", BUILD_GIT_BRANCH );
properties.setProperty("nifi.build.git.build.number", BUILD_GIT_BUILD_NUMBER );
properties.setProperty("nifi.build.git.build.number.unique", BUILD_GIT_BUILD_NUMBER_UNIQUE );
properties.setProperty("nifi.build.git.build.time", BUILD_GIT_BUILD_TIME_STR );
properties.setProperty("nifi.build.git.build.version", BUILD_GIT_BUILD_VERSION );
properties.setProperty("nifi.build.git.closest.tag.commit.count", BUILD_GIT_CLOSEST_TAG_COMMIT_COUNT );
properties.setProperty("nifi.build.git.closest.tag.name", BUILD_GIT_CLOSEST_TAG_NAME );
properties.setProperty("nifi.build.git.commit.id", BUILD_GIT_COMMIT_ID );
properties.setProperty("nifi.build.git.commit.id.abbrev", BUILD_GIT_COMMIT_ID_ABBREV );
properties.setProperty("nifi.build.git.commit.id.describe", BUILD_GIT_COMMIT_ID_DESCRIBE );
properties.setProperty("nifi.build.git.commit.id.describe-short", BUILD_GIT_COMMIT_ID_DESCRIBE_SHORT );
properties.setProperty("nifi.build.git.commit.time", BUILD_GIT_COMMIT_TIME_STR );
properties.setProperty("nifi.build.git.dirty", BUILD_GIT_DIRTY );
properties.setProperty("nifi.build.git.total.commit.count", BUILD_GIT_TOTAL_COMMIT_COUNT );
return properties;
}
}

View File

@ -16,8 +16,6 @@
*/
package org.apache.nifi.registry;
import org.apache.nifi.build.NifiBuildProperties;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -58,14 +56,6 @@ public interface VariableRegistry {
.build();
map.put(desc, entry.getValue().toString());
});
NifiBuildProperties.getBuildProperties().entrySet().stream().forEach((entry) -> {
final VariableDescriptor desc = new VariableDescriptor.Builder(entry.getKey().toString())
.description("Build Property")
.sensitive(false)
.build();
map.put(desc, entry.getValue().toString());
});
}
@Override

View File

@ -1,39 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.
*/
package org.apache.nifi.build;
import org.junit.Test;
import java.time.Instant;
import static org.junit.Assert.assertNotEquals;
public class TestBuildProperties {
@Test
public void testCheckGeneratedBuildProperties() {
assertNotEquals("An error occurred in the parsed Maven build time",
Instant.EPOCH, NifiBuildProperties.BUILD_TIMESTAMP);
assertNotEquals("An error occurred in the parsed Git build time",
Instant.EPOCH, NifiBuildProperties.BUILD_GIT_BUILD_TIME);
assertNotEquals("An error occurred in the parsed Git commit time",
Instant.EPOCH, NifiBuildProperties.BUILD_GIT_COMMIT_TIME);
}
}

View File

@ -16,35 +16,6 @@
*/
package org.apache.nifi.util;
import static java.util.Objects.requireNonNull;
import static org.apache.nifi.registry.VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Predicate;
import org.apache.nifi.annotation.behavior.TriggerSerially;
import org.apache.nifi.annotation.lifecycle.OnAdded;
import org.apache.nifi.annotation.lifecycle.OnConfigurationRestored;
@ -150,9 +121,6 @@ public class StandardProcessorTestRunner implements TestRunner {
this.processorStateManager = new MockStateManager(processor);
this.variableRegistry = new MockVariableRegistry();
// Ensure the test runner has the environment and build variables
ENVIRONMENT_SYSTEM_REGISTRY.getVariableMap().forEach(this.variableRegistry::setVariable);
this.context = new MockProcessContext(processor, processorName, processorStateManager, variableRegistry);
this.kerberosContext = kerberosContext;

View File

@ -18,7 +18,6 @@ package org.apache.nifi.processors.standard;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@ -33,7 +32,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.SystemUtils;
import org.apache.nifi.build.NifiBuildProperties;
import org.apache.nifi.processors.standard.util.TestInvokeHttpCommon;
import org.apache.nifi.ssl.StandardSSLContextService;
import org.apache.nifi.util.MockFlowFile;
@ -379,7 +377,7 @@ public class TestInvokeHTTP extends TestInvokeHttpCommon {
public void testShouldSetUserAgentExplicitly() throws Exception {
addHandler(new EchoUserAgentHandler());
runner.setProperty(InvokeHTTP.PROP_USERAGENT, "Apache NiFi/${nifi.version} (git:${nifi.build.git.commit.id.describe}; https://nifi.apache.org/)");
runner.setProperty(InvokeHTTP.PROP_USERAGENT, "Apache NiFi For The Win");
runner.setProperty(InvokeHTTP.PROP_URL, url);
createFlowFiles(runner);
@ -395,8 +393,7 @@ public class TestInvokeHTTP extends TestInvokeHttpCommon {
final MockFlowFile response = runner.getFlowFilesForRelationship(InvokeHTTP.REL_RESPONSE).get(0);
String content = new String(response.toByteArray(), UTF_8);
assertTrue(content.startsWith("Apache NiFi/" + NifiBuildProperties.NIFI_VERSION + " ("));
assertFalse("Missing expression language variables: " + content, content.contains("; ;"));
assertTrue(content.startsWith("Apache NiFi For The Win"));
response.assertAttributeEquals(InvokeHTTP.STATUS_CODE, "200");
response.assertAttributeEquals(InvokeHTTP.STATUS_MESSAGE, "OK");

View File

@ -42,7 +42,7 @@ public class TestFreeFormTextRecordSetWriter {
runner.setProperty(writer, SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY, SchemaAccessUtils.SCHEMA_TEXT_PROPERTY);
runner.setProperty(writer, SchemaAccessUtils.SCHEMA_TEXT, outputSchemaText);
runner.setProperty(writer, FreeFormTextRecordSetWriter.TEXT, "ID: ${ID}, Name: ${NAME}, Age: ${AGE}, Country: ${COUNTRY}, Username: ${login.name}");
runner.setProperty(writer, FreeFormTextRecordSetWriter.TEXT, "ID: ${ID}, Name: ${NAME}, Age: ${AGE}, Country: ${COUNTRY}, Username: ${user.name}");
return runner;
}
@ -54,7 +54,7 @@ public class TestFreeFormTextRecordSetWriter {
runner.enableControllerService(writer);
Map<String, String> attributes = new HashMap<>();
attributes.put("login.name", "jdoe64");
attributes.put("user.name", "jdoe64");
runner.enqueue("", attributes);
runner.run();
// In addition to making sure a flow file was output successfully, also check nothing got rolled back into the incoming queue. May be a moot point as there is a