-
Notifications
You must be signed in to change notification settings - Fork 8
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 #893 from eclipse-passage/575183
575183 license status check with all options must have headless version
- Loading branch information
Showing
28 changed files
with
792 additions
and
39 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
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
43 changes: 43 additions & 0 deletions
43
...sage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/LicenseConditions.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,43 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.base.conditions; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Collection; | ||
import java.util.function.Supplier; | ||
|
||
import org.eclipse.passage.lic.api.ServiceInvocationResult; | ||
import org.eclipse.passage.lic.api.conditions.ConditionPack; | ||
import org.eclipse.passage.lic.api.conditions.mining.LicenseReadingService; | ||
import org.eclipse.passage.lic.base.BaseServiceInvocationResult; | ||
|
||
public final class LicenseConditions implements Supplier<ServiceInvocationResult<Collection<ConditionPack>>> { | ||
|
||
private final Path file; | ||
private final Supplier<ServiceInvocationResult<LicenseReadingService>> provider; | ||
|
||
public LicenseConditions(Path file, Supplier<ServiceInvocationResult<LicenseReadingService>> provider) { | ||
this.file = file; | ||
this.provider = provider; | ||
} | ||
|
||
@Override | ||
public ServiceInvocationResult<Collection<ConditionPack>> get() { | ||
ServiceInvocationResult<LicenseReadingService> reader = provider.get(); | ||
if (!reader.data().isPresent()) { | ||
return new BaseServiceInvocationResult<>(reader.diagnostic()); | ||
} | ||
return reader.data().get().read(file); | ||
} | ||
|
||
} |
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
39 changes: 39 additions & 0 deletions
39
...rg.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/access/BaseOption.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,39 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.equinox.access; | ||
|
||
abstract class BaseOption<D extends Enum<?>> implements Option<D> { | ||
|
||
private final char key; | ||
private final String name; | ||
private final String description; | ||
protected final Interaction.Smart interaction; | ||
|
||
BaseOption(char key, String name, String description, Interaction.Smart interaction) { | ||
this.key = key; | ||
this.name = name; | ||
this.description = description; | ||
this.interaction = interaction; | ||
} | ||
|
||
@Override | ||
public String documentation() { | ||
return String.format("%s (%s): %s", key, name, description); //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public char key() { | ||
return key; | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...se.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/access/ConsoleInteraction.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,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.equinox.access; | ||
|
||
import java.io.IOException; | ||
|
||
public final class ConsoleInteraction implements Interaction { | ||
|
||
@Override | ||
public void prompt(String information) { | ||
System.out.printf("%s\n", information); //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public String input() { | ||
byte[] bytes = new byte[1024]; | ||
int length = 0; | ||
try { | ||
for (int symbol = System.in.read(); symbol != 13; symbol = System.in.read()) { | ||
bytes[length++] = (byte) symbol; | ||
} | ||
} catch (IOException e) { | ||
swear(e); | ||
return e.getClass().getName(); | ||
} | ||
return new String(bytes, 0, length); | ||
} | ||
|
||
@Override | ||
public void swear(Throwable thro) { | ||
thro.printStackTrace(System.err); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...e.lic.equinox/src/org/eclipse/passage/lic/equinox/access/CoverageCheckOptionDecision.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,19 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.equinox.access; | ||
|
||
enum CoverageCheckOptionDecision { | ||
|
||
proceed, quit, reassess; | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
...g.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/access/Interaction.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,63 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.equinox.access; | ||
|
||
import java.util.Optional; | ||
|
||
public interface Interaction { | ||
|
||
void prompt(String information); | ||
|
||
void swear(Throwable thro); | ||
|
||
String input(); | ||
|
||
public static final class Smart implements Interaction { | ||
private final Interaction delegate; | ||
|
||
public Smart(Interaction delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
void head(String title) { | ||
head(title, Optional.empty()); | ||
} | ||
|
||
void head(String title, String message) { | ||
head(title, Optional.of(message)); | ||
} | ||
|
||
private void head(String title, Optional<String> message) { | ||
delegate.prompt("------------------------------------"); //$NON-NLS-1$ | ||
delegate.prompt(String.format("--- %s", title)); //$NON-NLS-1$ | ||
message.ifPresent(delegate::prompt); | ||
delegate.prompt("------------------------------------"); //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public void prompt(String information) { | ||
delegate.prompt(information); | ||
} | ||
|
||
@Override | ||
public void swear(Throwable thro) { | ||
delegate.swear(thro); | ||
} | ||
|
||
@Override | ||
public String input() { | ||
return delegate.input(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.