Skip to content
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

skips generation if nothing has changed #5414

Merged
merged 1 commit into from Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion biz.aQute.bndlib/src/aQute/bnd/build/ProjectGenerate.java
Expand Up @@ -341,6 +341,10 @@ private Set<File> getOutputDirs(boolean toClear) {
}

public boolean needsBuild() {
return needsBuild(project.getSelfAndAncestors());
}

public boolean needsBuild(List<File> ancestors) {
for (Entry<String, GeneratorSpec> e : project.instructions.generate()
.entrySet()) {

Expand All @@ -361,7 +365,7 @@ public boolean needsBuild() {
if (sourceFiles.isEmpty())
return true; // error handling

sourceFiles.addAll(project.getSelfAndAncestors());
sourceFiles.addAll(ancestors);

long latestModifiedSource = sourceFiles.stream()
.mapToLong(File::lastModified)
Expand Down
@@ -0,0 +1,5 @@
-generate:\
src/main/resources/model/test.genmodel;\
generate="geckoEMF 1>out.log 2>out.log";\
genmodel="src/main/resources/model/test.genmodel";\
output=src/main/java
@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress package

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
46 changes: 46 additions & 0 deletions maven/bnd-generate-maven-plugin/src/it/generate-no-rerun/pom.xml
@@ -0,0 +1,46 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>biz.aQute.bnd-test</groupId>
<artifactId>generate</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.geckoprojects.emf</groupId>
<artifactId>org.gecko.emf.osgi.api</artifactId>
<version>4.1.1.202202162308</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-generate-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<externalPlugins>
<dependency>
<groupId>org.geckoprojects.emf</groupId>
<artifactId>org.gecko.emf.osgi.codegen</artifactId>
<version>4.1.1.202202162308</version>
</dependency>
</externalPlugins>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>bnd-generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,23 @@
import aQute.bnd.build.Workspace
import aQute.bnd.build.model.BndEditModel
import aQute.bnd.osgi.Processor
import aQute.bnd.properties.Document
import aQute.bnd.version.MavenVersion
import aQute.lib.io.IO

import java.util.jar.Attributes
import java.util.jar.JarFile;

def baseVersion = new MavenVersion(bndVersion).toReleaseVersion()

// Check the ecore file exist!
File ecore = new File(basedir,"src/main/resources/model/test.ecore")
assert ecore.isFile()

// Check the genmodel file exist!
File genmodel = new File(basedir,"src/main/resources/model/test.genmodel")
assert genmodel.isFile()

// Check the if some code generated file exist!
File testClass = new File(basedir,"src/main/java/aQute/bnd/maven/model/test/TestShouldNotBeDeleted.java")
assert testClass.isFile()
@@ -0,0 +1,30 @@
import aQute.bnd.build.Workspace
import aQute.bnd.build.model.BndEditModel
import aQute.bnd.osgi.Processor
import aQute.bnd.properties.Document
import aQute.bnd.version.MavenVersion
import aQute.lib.io.IO

import java.util.jar.Attributes
import java.util.jar.JarFile;

def baseVersion = new MavenVersion(bndVersion).toReleaseVersion()

// Check the ecore file exist!
File ecore = new File(basedir,"src/main/resources/model/test.ecore")
assert ecore.isFile()

// Check the genmodel file exist!
File genmodel = new File(basedir,"src/main/resources/model/test.genmodel")
assert genmodel.isFile()

// Check the pomfile exist!
File pom = new File(basedir,"pom.xml")
assert pom.isFile()

// Check the if some code generated file exist!
File testClass = new File(basedir,"src/main/java/aQute/bnd/maven/model/test/TestShouldNotBeDeleted.java")
assert testClass.isFile()

genmodel.setLastModified(testClass.lastModified() - 10000L);
pom.setLastModified(testClass.lastModified() - 10000L);
@@ -0,0 +1,18 @@
/**
*/
package aQute.bnd.maven.model.test;

import org.eclipse.emf.ecore.EObject;

/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Test</b></em>'.
* <!-- end-user-doc -->
*
*
* @see aQute.bnd.maven.model.test.TestPackage#getTest()
* @model
* @generated
*/
public interface Test extends EObject {
} // Test
@@ -0,0 +1,42 @@
/**
*/
package aQute.bnd.maven.model.test;

import org.eclipse.emf.ecore.EFactory;

/**
* <!-- begin-user-doc -->
* The <b>Factory</b> for the model.
* It provides a create method for each non-abstract class of the model.
* <!-- end-user-doc -->
* @see aQute.bnd.maven.model.test.TestPackage
* @generated
*/
public interface TestFactory extends EFactory {
/**
* The singleton instance of the factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
TestFactory eINSTANCE = aQute.bnd.maven.model.test.impl.TestFactoryImpl.init();

/**
* Returns a new object of class '<em>Test</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return a new object of class '<em>Test</em>'.
* @generated
*/
Test createTest();

/**
* Returns the package supported by this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the package supported by this factory.
* @generated
*/
TestPackage getTestPackage();

} //TestFactory
@@ -0,0 +1,105 @@
/**
*/
package aQute.bnd.maven.model.test;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;

/**
* <!-- begin-user-doc -->
* The <b>Package</b> for the model.
* It contains accessors for the meta objects to represent
* <ul>
* <li>each class,</li>
* <li>each feature of each class,</li>
* <li>each operation of each class,</li>
* <li>each enum,</li>
* <li>and each data type</li>
* </ul>
* <!-- end-user-doc -->
* @see aQute.bnd.maven.model.test.TestFactory
* @model kind="package"
* @generated
*/
public interface TestPackage extends EPackage {
/**
* The package name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
String eNAME = "test";

/**
* The package namespace URI.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
String eNS_URI = "https://bndtools.org/model/test/1.0";

/**
* The package namespace name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
String eNS_PREFIX = "test";

/**
* The singleton instance of the package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
TestPackage eINSTANCE = aQute.bnd.maven.model.test.impl.TestPackageImpl.init();

/**
* The meta object id for the '{@link aQute.bnd.maven.model.test.impl.TestImpl <em>Test</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see aQute.bnd.maven.model.test.impl.TestImpl
* @see aQute.bnd.maven.model.test.impl.TestPackageImpl#getTest()
* @generated
*/
int TEST = 0;

/**
* The number of structural features of the '<em>Test</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int TEST_FEATURE_COUNT = 0;

/**
* The number of operations of the '<em>Test</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int TEST_OPERATION_COUNT = 0;


/**
* Returns the meta object for class '{@link aQute.bnd.maven.model.test.Test <em>Test</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the meta object for class '<em>Test</em>'.
* @see aQute.bnd.maven.model.test.Test
* @generated
*/
EClass getTest();

/**
* Returns the factory that creates the instances of the model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the factory that creates the instances of the model.
* @generated
*/
TestFactory getTestFactory();

} //TestPackage
@@ -0,0 +1,18 @@
/**
*/
package aQute.bnd.maven.model.test;

import org.eclipse.emf.ecore.EObject;

/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Test</b></em>'.
* <!-- end-user-doc -->
*
*
* @see aQute.bnd.maven.model.test.TestPackage#getTest()
* @model
* @generated
*/
public interface TestShouldNotBeDeleted extends EObject {
} // Test